Hello
I'm using grok exporter and here is what I want to achieve: I have a Java application whose log entry is in below format:
'%{NUMBER} %{JAVACLASS} %{JAVALOGMESSAGE} %{JAVATHREAD} %{TOMCAT_DATESTAMP} %{LOGLEVEL} %{JAVAMETHOD}'
I want to configure Prometheus alert for any 'ERROR' entry in the log level. Here is how the grok_exporter config.yml file look like:
====================
global:
config_version: 2
input:
type: file
path: ./example/test.log
readall: true # Read from the beginning of the file? False means we start at the end of the file and read only new lines.
grok:
patterns_dir: ./patterns
metrics:
- type: counter
name: error_test
help: Counter metric example
match: '%{NUMBER} %{JAVACLASS} %{JAVALOGMESSAGE} %{JAVATHREAD} %{TOMCAT_DATESTAMP} %{LOGLEVEL:severity} %{JAVAMETHOD}'
labels:
grok_field_name: severity
prometheus_label: severity
server:
host: 0.0.0.0
port: 9144
============================
The test log file has 4 log lines with one log line having log level as ERROR. I did try accessing
http://IP:9144/metrics and I see the below but there is no metric created on Prometheus(grok_exporter is installed on Prometheus itself).
grok_exporter_line_processing_errors_total{metric="error_test"} 0
# HELP grok_exporter_lines_matching_total Number of lines matched for each metric. Note that one line can be matched by multiple metrics.
# TYPE grok_exporter_lines_matching_total counter
grok_exporter_lines_matching_total{metric="error_test"} 0
# HELP grok_exporter_lines_processing_time_microseconds_total Processing time in microseconds for each metric. Divide by grok_exporter_lines_matching_total to get the average processing time for one log line.
# TYPE grok_exporter_lines_processing_time_microseconds_total counter
grok_exporter_lines_processing_time_microseconds_total{metric="error_test"} 0
# HELP grok_exporter_lines_total Total number of log lines processed by grok_exporter.
# TYPE grok_exporter_lines_total counter
grok_exporter_lines_total{status="ignored"} 4
grok_exporter_lines_total{status="matched"} 0
Why is it so? What changes should I make to have the metric reflected on Prometheus? Can someone please help.
Thanks