Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Nginx log parser and Prometheus exporter

Go Report Card Coverage Status Build Status Mentioned in Awesome Go

This service parses incoming syslog messages from Nginx sent over UDP and converts them into Prometheus metrics exported through the built-in HTTP server.

  • If the prefix-list is specified then per-URI statistics are generated. Using this feature without URI-prefix list is dangerous because it leads to an unbounded memory usage. It's therefore enabled only with a limited prefix list.

    The URI prefix list is a plain-text file with a single prefix per line, e.g.


    URIs received from nginx are stripped of any query parameters - only the part before '?' is used.

  • It optionally supports country lookup for client IPs using MaxMind GeoIP database.

Nginx configuration snippet

log_format collector '$remote_addr|$scheme|$host|$request_method|$server_protocol|$request_uri|$status|$request_time|$request_length|$bytes_sent';
access_log syslog:server=,tag=nginx collector;

Getting it

  • Get RPM & DEB directly from releases, only linux-amd64 build currently available.

  • Build youself:

go get
cd $GOPATH/src/
go build

Usage example

If you're using RPM/DEB packages then options are set in /etc/default/nginx-prometheus

./nginx-prometheus \
-debug false \
-listenSyslog \
-listenHTTP \
-geoipCountryDB /etc/nginx-prometheus/country.mmdb \
-uriPrefixFile /etc/nginx-prometheus/uriPrefixes.txt
  • debug - prints every syslog message received if true (defaults to false)
  • listenSyslog - ip:port on which to listen for UDP Syslog messages (defaults to
  • listenHTTP - ip:port on which to listen for incoming HTTP requests from Prometheus (defaults to
  • geoipCountryDB - path to MaxMind country GeoIP database (optional)
  • uriPrefixFile - path to a URI prefix list (optional)

Grafana dashboard

Add Prometheus source to Grafana and import grafana-dashboard.json for most common graphs.