nginx-log-exporer

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

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

Go to latest
Published: Dec 22, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

README

Build on Linux:

git clone https://github.com/MaxZamaliev/nginx-log-exporter.git
cd nginx-log-exporter
export GOPATH=`pwd`
go get github.com/hpcloud/tail
go get github.com/prometheus/client_golang/prometheus
go get github.com/prometheus/client_golang/prometheus/promhttp
go build nginx-log-exporter.go

Prepare nginx:

Add to your nginx.conf file:
  geoip_country /usr/share/GeoIP/GeoIP.dat;
  log_format custom '$remote_addr ($geoip_country_code) - $remote_user [$time_local] "$host" "$request" '
    '$status $body_bytes_sent $request_time "$http_referer" '
    '"$http_user_agent" "$http_x_forwarded_for"';
  access_log /var/log/nginx/access.log custom;

Install on CentOS 8:

1. Copy binary file nginx-log-exporter to /usr/local/bin/

2. Create user:

useradd -M -s /bin/false nginx_exporter

3. Create file /etc/systemd/system/nginx-log_exporter.service with text:

[Unit]
Description=Prometheus nginx log Exporter
Wants=network-online.target
After=network-online.target

[Service]
User=nginx_exporter
Group=nginx_exporter
Type=simple
ExecStart=/usr/local/bin/nginx-log-exporter

[Install]
WantedBy=multi-user.target

4. Enable and start service:

systemctl enable --now nginx-log-exporter

5. Test service:

curl http://localhost:9113/metrics

Documentation

Overview

nginx-log_exporter - exports metrics for Prometheus from nginx-log

Directories

Path Synopsis
src
exporterHTTPServer
exporterHTTPServer - http server for metrics for Prometheus
exporterHTTPServer - http server for metrics for Prometheus

Jump to

Keyboard shortcuts

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