• Stars
    star
    889
  • Rank 51,178 (Top 2 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 8 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Export Prometheus metrics from arbitrary unstructured log data.

Build Status Build status Coverage Status

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. Grok is heavily used in Logstash to provide log data as input for ElasticSearch.

Grok ships with about 120 predefined patterns for syslog logs, apache and other webserver logs, mysql logs, etc. It is easy to extend Grok with custom patterns.

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 run the example

Download grok_exporter-$ARCH.zip for your operating system from the releases page, extract the archive, cd grok_exporter-$ARCH, then run

./grok_exporter -config ./example/config.yml

The example log file exim-rejected-RCPT-examples.log contains log messages from the Exim mail server. The configuration in config.yml counts the total number of rejected recipients, partitioned by error message.

The exporter provides the metrics on http://localhost:9144/metrics:

screenshot.png

Configuration

Example configuration:

global:
  config_version: 3
input:
  type: file
  path: ./example/example.log
  readall: true
imports:
- type: 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}}'
    logfile: '{{base .logfile}}'
server:
  port: 9144

CONFIG.md describes the grok_exporter configuration file and shows how to define Grok patterns, Prometheus metrics, and labels. It also details how to configure file, stdin, and webhook inputs.

How to build from source

In order to compile grok_exporter from source, you need

  • Go installed and $GOPATH set.
  • gcc installed for cgo. On Ubuntu, use apt-get install build-essential.
  • Header files for the Oniguruma regular expression library, see below.

Installing the Oniguruma library on OS X

brew install oniguruma

Installing the Oniguruma library on Ubuntu Linux

sudo apt-get install libonig-dev

Installing the Oniguruma library from source

curl -sLO https://github.com/kkos/oniguruma/releases/download/v6.9.5_rev1/onig-6.9.5-rev1.tar.gz
tar xfz onig-6.9.5-rev1.tar.gz
cd onig-6.9.5
./configure
make
make install

Installing grok_exporter

git clone https://github.com/fstab/grok_exporter
cd grok_exporter
git submodule update --init --recursive
go install .

The resulting grok_exporter binary will be dynamically linked to the Oniguruma library, i.e. it needs the Oniguruma library to run. The releases are statically linked with Oniguruma, i.e. the releases don't require Oniguruma as a run-time dependency. The releases are built with hack/release.sh.

Note: Go 1.13 for Mac OS has a bug affecting the file input. It is recommended to use Go 1.12 on Mac OS until the bug is fixed. Go 1.13.5 is affected. golang/go#35767.

More Documentation

User documentation is included in the GitHub repository:

  • CONFIG.md: Specification of the config file.
  • BUILTIN.md: Definition of metrics provided out-of-the-box.

Developer notes are available on the GitHub Wiki pages:

External documentation:

Contact

  • For feature requests, bugs reports, etc: Please open a GitHub issue.
  • For bug fixes, contributions, etc: Create a pull request.
  • Questions? Contact me at [email protected].

Related Projects

Google's mtail goes in a similar direction. It uses its own pattern definition language, so it will not work out-of-the-box with existing Grok patterns. However, mtail's RE2 regular expressions are probably more CPU efficient than Grok's Oniguruma patterns. mtail reads logfiles using the fsnotify library, which might be an obstacle on operating systems other than Linux.

License

Licensed under the Apache License, Version 2.0. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

More Repositories

1

h2c

http2client
Go
272
star
2

cifs

CIFS Flexvolume Plugin for Kubernetes
Shell
211
star
3

promagent

Prometheus Monitoring for Java Web Applications without Modifying their Source Code
Java
83
star
4

prometheus-for-java-developers

Prometheus for Java Developers Demo
79
star
5

go-programming-for-java-developers

Golang Programming Workshop
72
star
6

http2-examples

Java
49
star
7

docker-aws-cli

Docker image for running the AWS command line interface.
28
star
8

diy-kubernetes

Do-It-Yourself Kubernetes in the Hetzner Cloud
HCL
14
star
9

fosdem-2023

Shell
12
star
10

docker-mutt

11
star
11

docker-weechat-otr

Run the weechat IRC client with Off-the-Record (OTR) encryption.
11
star
12

javazone-2023

Java
8
star
13

basic-ubuntu-server-setup

3
star
14

promagent-operator

Demo: Kubernetes operator for the Prometheus monitoring Java agent
Go
3
star
15

jug-oberpfalz-prometheus-java

3
star
16

exim_prometheus_exporter

Go
3
star
17

docker-grip

Docker image for viewing Markdown pages
3
star
18

quarkus-demo

Java
3
star
19

jcon-2023

Java
3
star
20

java-demo

Java Demo Application for Kubernetes
Java
2
star
21

jbcn.conf-2022

Java
2
star
22

docker-grok_exporter-compiler

Shell
2
star
23

docker-bower

develop bower projects without installing bower
Shell
2
star
24

diy-kubernetes-basic

Basic Kubernetes Setup with Terraform and Ansible
HCL
2
star
25

client_java-otel-example

Example of Pushing Prometheus Metrics to a Prometheus Server via OpenTelemetry's OTLP
Java
1
star
26

docker-prometheus-demo

Ubuntu with Prometheus downloads in /root/.
1
star
27

pam-truecrypt

C
1
star
28

docker-wildfly-http2

Shell
1
star
29

docker-ubuntu

Extended Ubuntu base image
1
star
30

devoxx-be-2022-latency

Java
1
star
31

s3diff

Compare a local directory with its back-up on Amazon S3.
Ruby
1
star
32

docker-asciidoc

1
star
33

spring-boot-2-opentelemetry-traces

Demo project showing Prometheus Exemplars for Spring Boot 2 Prometheus metrics with OpenTelemetry traces
Java
1
star
34

music-box

C
1
star
35

micrometer-config-example

Examples of How To Configure Micrometer Metrics in Spring Boot
Java
1
star
36

docker-go

Test go programs in a Linux container.
1
star
37

node-imap

An IMAP client module for node.js.
JavaScript
1
star