My main aim is to show log file in a prometheus server. For that, I'm using grok-exporter.
To do so, I've showed path to my log file path and changed metrics type and matches. As shown below:
global:
config_version: 3
input:
type: file
path: /tmp/model.log
readall: true # Read from the beginning of the file? False means we start at>
fail_on_missing_logfile: true
imports:
- type: grok_patterns
dir: /opt/grok-exporter/patterns
grok_patterns:
- 'METRICS [a-zA-Z ]'
metrics:
- type: gauge
name: model_log
help: Average duration of model
match: '%{DATE:date} %{TIME:time} %{METRICS:metrics} %{NUMBER:avg_hour}'
value: '{{.avg_hour}}'
labels:
metrics: '{{.metrics}}'
server:
protocol: http
port: 9144
And my log file looks like:
2021-11-09 15:18:17 avg_hour 0.9
2021-11-09 15:20:06 avg_hour 0.5
2021-11-09 15:20:06 avg_hour 0.4
When I started grok-exporter.server at 9144, only default metrics were launched.
One of them is 'grok_exporter_line_processing_errors_total'. Which shows:
grok_exporter_line_processing_errors_total{metrics="model_log"} 0
which means I've zero error.
But, I couldn't see my metric 'model_log' in the server. Maybe I've wrong grok pattern types, or grok couldn't access to the model_log at '/tmp/'. But if that's true, error should be appeared.
UPDATE: When I write on command line:
journalctl -eu grok-exporter
there's an error:
... status =255/EXCEPTION
grok-exporter.service failed with results 'exit-code'
...
Failed to load ~/config.yml: invalid configuration: yaml: line 21: could not find expected ':'
...
But the:
systemctl status grok-exporter.service
is active running. What might be the problem? I think there's no problem with ':' in line 21.