如何在 Zabbix 中创建一个带有基于日志条目计数的计算字段的图表?
我有一个项目设置来监视致命错误,并且我想添加另一个项目,以便它计算致命错误的计数并绘制图表。
使用该键: log["/d2/httpd/logs/myDomain-error_log","PHP Fatal","UTF-8",100]
它正确地获取了我想要的数据,但是它不会绘制此图,我想我有对条目进行计数并获取整数格式,但这不起作用:
count(log["/d2/httpd/logs/myDomain-error_log","PHP Fatal","UTF-8",100], 60)
关于我的密钥应该是什么,或者我如何绘制这些数据以查看随着时间的推移有多少错误,有什么想法吗?
操作和触发器工作正常并执行预期的操作,但无法从中创建图表。
I have an item setup to monitor fatal errors, and I want to add another item so that it calculates the count of the fatal errors and graphs them.
Using this key:
log["/d2/httpd/logs/myDomain-error_log","PHP Fatal","UTF-8",100]
It properly gets the data that I'm wanting, however it will not graph this, I imagine I have to count the entries and get the format as an integer, but this does not work:
count(log["/d2/httpd/logs/myDomain-error_log","PHP Fatal","UTF-8",100], 60)
Any ideas of what my key should be, or how I would go about graphing this data to see over time how many errors there were?
Actions and triggers are working fine and doing what is supposed but unable to create graph out of it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对我有用的:
创建用于解析日志中某些字符串的项目。
log["C:/Logs/log.log",ERROR]
。Zabbix代理(主动)
日志
。此项应显示日志中带有指定字符串“ERROR”的所有行。
其次,创建带有转义引号的计算项:
my.special.app.error.count
Calculated
count("log[\"C:/ Logs/log.log\",ERROR]", 60)
这将计算 60 秒内日志中重复“ERROR”的次数。
现在这个项目可以被绘制、触发等。
我不太确定为什么需要解析项目,但如果没有它,这个计算项目就不起作用。
What worked for me:
Create item for parsing some string in log.
log["C:/Logs/log.log",ERROR]
.Zabbix agent (active)
Log
.This item should show all the lines from log with specified string "ERROR".
Second, create calculated item with escaped quotation marks:
my.special.app.error.count
Calculated
count("log[\"C:/Logs/log.log\",ERROR]", 60)
This would count how many times "ERROR" was repeated in log during 60 seconds.
Now this item can be graphed, triggered, etc.
I'm not really sure why parsing item is required, but without it this calculated item does not work.
以下是通过 Zabbix 监控日志文件的步骤。
1)创建一个批处理文件,例如。
//test.bat
@echo off
或 /F %%x in ('findstr /r /n "ERROR" C:\test.log ^| find /C ":"') do echo %%x
2) 将“test.log”替换为您的日志文件
3) 在 Zabbix_agentd.config 文件中进行以下更改
EnableRemoteCommands=1
DisableActive=0
UnsafeUserParameters=1
UserParameter=key.in.zabbix.frontend,c:/temp/test.bat
4) C:/ temp/test.bat 是批处理文件的路径
5) 在 Zabbix GUI 中创建一个项目,详细信息如下
Key= key.in.zabbix.frontend // 这是除 GUI 和 abbix_agentd.config 文件中的名称之外的任何名称必须相同。
Type=Zabbix_Agent 或 Zabbix_Agent(Active)
信息类型= Numeric(Unsigned)
其余均相同。
6) 重新启动Zabbix代理。并检查监控->最新值。
检查服务器上的输出
7) 为了测试,我们也可以通过命令
Go to root->zabbix 1.8.6->src->zabbix_get
Here are the steps for monitoring log file through Zabbix.
1) Create a batch file eg.
//test.bat
@echo off
or /F %%x in ('findstr /r /n "ERROR" C:\test.log ^| find /C ":"') do echo %%x
2) Replace the “test.log” with your log file
3) Do the below changes in Zabbix_agentd.config file
EnableRemoteCommands=1
DisableActive=0
UnsafeUserParameters=1
UserParameter=key.in.zabbix.frontend,c:/temp/test.bat
4) C:/temp/test.bat is the path of batch file
5) Create a Item in Zabbix GUI with following detail
Key= key.in.zabbix.frontend // This is any name but the name in GUI and abbix_agentd.config file must be same.
Type=Zabbix_Agent or Zabbix_Agent(Active)
Type of Information= Numeric(Unsigned)
Rest all are same.
6) Restart the Zabbix agent. And check in Monitoring->Latest Value.
7) For testing we can check the output on server also by command
Go to root->zabbix 1.8.6->src->zabbix_get
这将计算自上次签入具有名称的文件以来新日志记录中正则表达式
@NginxNotOK
的匹配情况,该名称在宏{$NGINX_ACCESS_LOG_FILE}
中定义:log.count[ {$NGINX_ACCESS_LOG_FILE},@NginxNotOK,,,跳过]
This will count matches of regular expression
@NginxNotOK
in new log records since last check in file with name, defined in macro{$NGINX_ACCESS_LOG_FILE}
:log.count[{$NGINX_ACCESS_LOG_FILE},@NginxNotOK,,,skip]