nginx-log-consumer

command module
v0.0.0-...-df27b73 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2018 License: BSD-2-Clause Imports: 11 Imported by: 0

README

Export metrics from nginx access logs to Stackdriver

A small command-line utility for exporting metrics inferred from nginx access logs to custom Stackdriver metrics. Currently only supports HTTP response status code counts, but should be straightforward to extend.

Requirements

Dependencies

Run:

go get -u cloud.google.com/go/monitoring/apiv3

to pull the monitoring API package into your GOPATH. This should also pull in other dependencies, like the instance metadata service.

Log format

It is expected that nginx has been configured to write logs as json with ISO 8601 timestamps. For example:

log_format json_combined escape=json '{ "time": "$time_iso8601", '
    '"remote_addr": "$remote_addr", '
    '"remote_user": "$remote_user", '
    '"request": "$request", '
    '"status": "$status", '
    '"body_bytes_sent": "$body_bytes_sent", '
    '"request_time": "$request_time", '
    '"http_referrer": "$http_referer", '
    '"http_user_agent": "$http_user_agent" }';
access_log /var/log/nginx/access.log json_combined;

As noted above, only the time and status fields are examined for now.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL