/docker-grok_exporter

Dockerized grok_exporter

Primary LanguageDockerfile

grok_exporter

Export Prometheus metrics from arbitrary unstructured log data.

About Grok

Grok is a tool to parse crappy unstructured log data into something structured and queryable.

The [grok_exporter] aims at porting Grok from the ELK stack to Prometheus monitoring. The goal is to use Grok patterns for extracting Prometheus metrics from arbitrary log files.

How to use this image

You need to provide [grok_exporter] with a config file in order to function properly. For more information on proper configuration of grok_exporter please refer to its documentation.

There are various ways in which you can utilize this image, each however assumes that the log file you're trying to parse is reacheable by the grok_exporter container.

Running Solo

This assumes Prometheus is installed locally (or on another server) and therefore, the metrics endpoint that grok_exporter exposes must be reachable:

docker container run --name grok -d \
                     -p PORT:PORT \
                     -v $(pwd)/config.yml:/etc/grok_exporter/config.yml \
                     palobo/grok_exporter
  • PORT is the port defined in config file (default is 9144

Docker Compose Setup

Assuming you're using this image alonside other images (Prometheus and Grafana running in containers too), then the is slightly different since there is no need to expose the ports externally.

docker container run --name grok -d \
                     --net PROM-NETWORK \
                     -v $(pwd)/config.yml:/etc/grok_exporter/config.yml \
                     palobo/grok_exporter

Example Config

Refer to the grok_exporter documentation for all the details on how to properly configure it.

global:
    config_version: 2
input:
    type: file
    path: ./example/example.log
    readall: true
grok:
    patterns_dir: ./logstash-patterns-core/patterns
metrics:
    - type: counter
      name: grok_example_lines_total
      help: Counter metric example with labels.
      match: '%{DATE} %{TIME} %{USER:user} %{NUMBER}'
      labels:
          user: '{{.user}}'
server:
    port: 9144