如何在 Zabbix 中创建一个带有基于日志条目计数的计算字段的图表?

发布于 2024-12-03 12:10:26 字数 369 浏览 5 评论 0原文

我有一个项目设置来监视致命错误,并且我想添加另一个项目,以便它计算致命错误的计数并绘制图表。

使用该键: 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

逆光下的微笑 2024-12-10 12:10:26

对我有用的:

创建用于解析日志中某些字符串的项目。

  • log["C:/Logs/log.log",ERROR]
  • 类型Zabbix代理(主动)
  • 信息类型日志

此项应显示日志中带有指定字符串“ERROR”的所有行。

其次,创建带有转义引号的计算项:

  • Key my.special.app.error.count
  • Type Calculated
  • Formula count("log[\"C:/ Logs/log.log\",ERROR]", 60)

这将计算 60 秒内日志中重复“ERROR”的次数。

现在这个项目可以被绘制、触发等。

我不太确定为什么需要解析项目,但如果没有它,这个计算项目就不起作用。

What worked for me:

Create item for parsing some string in log.

  • Key log["C:/Logs/log.log",ERROR].
  • Type Zabbix agent (active)
  • Type of information Log.

This item should show all the lines from log with specified string "ERROR".

Second, create calculated item with escaped quotation marks:

  • Key my.special.app.error.count
  • Type Calculated
  • Formula 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.

浮光之海 2024-12-10 12:10:26

以下是通过 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

你げ笑在眉眼 2024-12-10 12:10:26

这将计算自上次签入具有名称的文件以来新日志记录中正则表达式 @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]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文