Skip to content

Simple server that scrapes Nginx vts stats and exports them via HTTP for Prometheus consumption

License

Notifications You must be signed in to change notification settings

StereoRu/nginx-vts-exporter

 
 

Repository files navigation

nginx-vts-exporter

Docker Repository on Quay

Simple server that scrapes Nginx vts stats and exports them via HTTP for Prometheus consumption

Table of Contents

Dependency

Download

Binary can be downloaded from Releases page.

Compile

This shell script above will build a temp Docker image with the binary and then export the binary inside ./bin/ directory

./build-binary.sh

Config

The application can have a configuration file. By default, it is located in /etc/nginx-vts-exporter/config.json This can be overridden via the command line option -config.file /some/path/config.json Parameters specified in the configuration file are less priority than command line parameters or environment variables. If the command-line parameter -nginx.scrape_uri http://somedomain.com/status/format/json is specified, it will be added to those listed in the configuration file. If there is no parameter nginxScrapeURIs.hostName in the configuration file, it will be taken from the data nginx-vts-module

Run

nohup /bin/nginx-vts-exporter -nginx.scrape_uri=http://localhost/status/format/json

Dockerized

To Dockerize this application yo need to pass two steps the build then the containerization.

Environment variables

This image is configurable using different env variables

Variable name Default Description
NGINX_STATUS http://localhost/status/format/json Nginx JSON format status page
METRICS_ENDPOINT /metrics Metrics endpoint exportation URI
METRICS_ADDR :9913 Metrics exportation address:port
METRICS_NS nginx Prometheus metrics Namespaces

Docker Hub Image

docker pull quay.io/stereoru/nginx-vts-exporter:master

It can be used directly instead of having to build the image yourself. (Quay.io repository stereoru/nginx-vts-exporter)

Docker Build

./build-binary.sh
docker build -t vts-export .

Docker Run

docker run  -ti --rm --env NGIX_HOST="http://localhost/status/format/json" --env METRICS_NS="nginx_prod1" vts-export

Metrics

Documents about exposed Prometheus metrics

Server main

Metrics details

Nginx data Name Exposed informations
Connections {NAMESPACE}_server_connections status [active, reading, writing, waiting, accepted, handled], hostName (server hostName or hostName from config)

Metrics output example

# Server Connections
nginx_server_connections{status="accepted", hostName="ngx_host"} 70606

Server zones

Metrics details

Nginx data Name Exposed informations
Requests {NAMESPACE}_server_requests code [2xx, 3xx, 4xx, 5xx, total], host (or domain name), hostName (server hostName or hostName from config)
Bytes {NAMESPACE}_server_bytes direction [in, out], host (or domain name), hostName (server hostName or hostName from config)
Cache {NAMESPACE}_server_cache status [bypass, expired, hit, miss, revalidated, scarce, stale, updating], host (or domain name), hostName (server hostName or hostName from config)
requestMsec {NAMESPACE}_server_requestMsec host (or domain name), hostName (server hostName or hostName from config)

Metrics output example

# Server Requests
nginx_server_requests{code="1xx",host="test.domain.com", hostName="ngx_host"} 0

# Server Bytes
nginx_server_bytes{direction="in",host="test.domain.com", hostName="ngx_host"} 21

# Server Cache
nginx_server_cache{host="test.domain.com",status="bypass", hostName="ngx_host"} 2

# Server RequestMsec
nginx_server_requestMsec{host="test.domain.com", hostName="ngx_host"} 18

Upstreams

Metrics details

Nginx data Name Exposed informations
Requests {NAMESPACE}_upstream_requests code [2xx, 3xx, 4xx, 5xx and total], upstream (or upstream name), hostName (server hostName or hostName from config)
Bytes {NAMESPACE}_upstream_bytes direction [in, out], upstream (or upstream name), hostName (server hostName or hostName from config)
Response time {NAMESPACE}_upstream_response backend (or server), in_bytes, out_bytes, upstream (or upstream name), hostName (server hostName or hostName from config)

Metrics output example

# Upstream Requests
nginx_upstream_requests{code="1xx",upstream="XXX-XXXXX-3000", hostName="ngx_host"} 0

# Upstream Bytes
nginx_upstream_bytes{direction="in",upstream="XXX-XXXXX-3000", hostName="ngx_host"} 0

# Upstream Response time
nginx_upstream_response{backend="10.2.15.10:3000",upstream="XXX-XXXXX-3000", hostName="ngx_host"} 99

About

Simple server that scrapes Nginx vts stats and exports them via HTTP for Prometheus consumption

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 77.2%
  • Python 12.3%
  • Shell 5.8%
  • Makefile 4.7%