我们已将Grok导出程序配置为监视Web服务日志中的错误。我们看到,即使没有错误,它仍然会打印过去的错误数。
我们使用了" gauge"作为度量标准类型并每5秒轮询一次日志文件。
请参阅下面的config.yml:
global:
config_version: 2
input:
type: file
path: /ZAMBAS/logs/Healthcheck/AI/ai_17_grafana.log
readall: true
poll_interval_seconds: 5
grok:
patterns_dir: ./patterns
metrics:
- type: counter
name: OutOfThreads
help: Counter metric example with labels.
match: '%{GREEDYDATA} WARN!! OUT OF THREADS: %{GREEDYDATA}'
- type: counter
name: OutOfMemory
help: Counter metric example with labels.
match: '%{GREEDYDATA}: Java heap space'
- type: gauge
name: NoMoreEndpointPrefix
help: Counter metric example with labels.
match: '%{GREEDYDATA}: APPL%{NUMBER:val1}: IO Exception: Connection refused %{GREEDYDATA}'
value: '{{.val1}}'
cumulative: false
- type: gauge
name: IOExceptionConnectionReset
help: Counter metric example with labels.
match: ' <faultstring>APPL%{NUMBER:val3}: IO Exception: Connection reset'
value: '{{.val3}}'
cumulative: false
- type: gauge
name: IOExceptionReadTimedOut
help: Counter metric example with labels.
match: ' <faultstring>APPL%{NUMBER:val4}: IO Exception: Read timed out'
value: '{{.val4}}'
cumulative: false
- type: gauge
name: FailedToConnectTo
help: Counter metric example with labels.
match: " <faultstring>RUNTIME0013: Failed to connect to '%{URI:val5}"
value: '{{.val5}}'
cumulative: false
server:
port: 9244
Output:
grok_exporter_lines_matching_total{metric="FailedToConnectTo"} 0
grok_exporter_lines_matching_total{metric="IOExceptionConnectionReset"} 0
grok_exporter_lines_matching_total{metric="IOExceptionReadTimedOut"} 3
grok_exporter_lines_matching_total{metric="NoMoreEndpointPrefix"} 0
grok_exporter_lines_matching_total{metric="OutOfMemory"} 0
grok_exporter_lines_matching_total{metric="OutOfThreads"} 0
说,1小时没有错误,仍然显示&#39; 3&#39;错误,当发生错误时,它会不断加起来。所以它总共变成了4,依此类推......继续增加:(
我希望grok只显示当前数据而不添加以前的值。
请在这里帮助我们解决我的错误。
由于 Priyotosh
答案 0 :(得分:0)
这是正确的行为。您要做的是使用Prometheus中的rate()
函数来计算每秒有多少相关的日志行。例如rate(OutOfThreads[5m])
。