1- #nginx-vts-exporter
1+ # nginx-vts-exporter
22
33Simple server that scrapes Nginx vts stats and exports them via HTTP for Prometheus consumption
44
5- #Dependency
5+ ## Table of Contents
6+ * [ Dependency] ( #dependency )
7+ * [ Download] ( #download )
8+ * [ Compile] ( #compile )
9+ * [ Run] ( #run )
10+ * [ Dockerized] ( #dockerized )
11+ * [ Environment variables] ( #environment-variables )
12+ * [ Docker Build] ( #docker-build )
13+ * [ Docker Run] ( #docker-run )
14+ * [ Metrics] ( #metrics )
15+ * [ Server main] (#server main)
16+ * [ Server zones] (#server zones)
17+ * [ Upstreams] ( #upstreams )
18+
19+ ## Dependency
620
721* [ nginx-module-vts] ( https://github.com/vozlt/nginx-module-vts )
822* [ Prometheus] ( https://prometheus.io/ )
923* [ Golang] ( https://golang.org/ )
1024
11- #Download
12- Binary can be downloaded from ` bin ` directory.
13- Latest version v0.0.3
25+ ## Download
1426
15- ```
16- # SHA512 Sum
17- 16eec84a6496529ef76a83af54f659111abecca6bcb4b2edd0b327223f93e735ae4aca2078bf4c41fded831c3d116170b277d194af64074f45992191e3a7bfb6 bin/nginx-vts-exporter
18- ```
27+ Binary can be downloaded from [ Releases] ( https://github.com/hnlq715/nginx-vts-exporter/releases ) page.
1928
20- #Compile
29+ ## Compile
2130
22- ```
23- $ ./build-binary.sh
24- ```
2531This shell script above will build a temp Docker image with the binary and then
2632export the binary inside ./bin/ directory
2733
28- #Run
29-
34+ ``` shell
35+ ./build-binary.sh
3036```
31- $ nohup /bin/nginx-vts-exporter -nginx.scrape_uri=http://localhost/status/format/json
37+
38+ ## Run
39+
40+ ``` shell
41+ nohup /bin/nginx-vts-exporter -nginx.scrape_uri=http://localhost/status/format/json
3242```
3343
34- #Dockerized
44+ ## Dockerized
45+
3546To Dockerize this application yo need to pass two steps the build then the containerization.
3647
37- ## Environment variables
48+ ### Environment variables
49+
3850This image is configurable using different env variables
3951
4052Variable name | Default | Description
@@ -45,13 +57,80 @@ METRICS_ADDR | :9913 | Metrics exportation address:port
4557METRICS_NS | nginx | Prometheus metrics Namespaces
4658
4759
48- ##Build
60+ ### Docker Build
61+
62+ ``` shell
63+ ./build-binary.sh
64+ docker build -t vts-export .
4965```
50- $ ./build-binary.sh
51- $ docker build -t vts-export .
66+
67+ ### Docker Run
68+
69+ ``` shell
70+ docker run -ti --rm --env NGIX_HOST=" http://localhost/status/format/json" --env METRICS_NS=" nginx_prod1" vts-export
71+ ```
72+
73+ ## Metrics
74+
75+ Documents about exposed Prometheus metrics
76+
77+ ### Server main
78+
79+ ** Metrics details**
80+
81+ Nginx data | Name | Exposed informations
82+ ------------------ | ------------------------------- | ------------------------
83+ ** Connections** | ` {NAMESPACE}_server_connections ` | status [ active, reading, writing, waiting, accepted, handled]
84+
85+ ** Metrics output example**
86+
87+ ``` txt
88+ # Server Connections
89+ nginx_server_connections{status="accepted"} 70606
5290```
5391
54- ##Run
92+ ### Server zones
93+
94+ ** Metrics details**
95+
96+ Nginx data | Name | Exposed informations
97+ ------------------ | ------------------------------- | ------------------------
98+ ** Requests** | ` {NAMESPACE}_server_requests ` | code [ 2xx, 3xx, 4xx, 5xx, total] , host _ (or domain name)_
99+ ** Bytes** | ` {NAMESPACE}_server_bytes ` | direction [ in, out] , host _ (or domain name)_
100+ ** Cache** | ` {NAMESPACE}_server_cache ` | status [ bypass, expired, hit, miss, revalidated, scarce, stale, updating] , host _ (or domain name)_
101+
102+ ** Metrics output example**
103+
104+ ``` txt
105+ # Server Requests
106+ nginx_server_requests{code="1xx",host="test.domain.com"} 0
107+
108+ # Server Bytes
109+ nginx_server_bytes{direction="in",host="test.domain.com"} 21
110+
111+ # Server Cache
112+ nginx_server_cache{host="test.domain.com",status="bypass"} 2
55113```
56- docker run -ti --rm --env NGIX_HOST="http://localhost/status/format/json" --env METRICS_NS="nginx_prod1" vts-export
114+
115+ ### Upstreams
116+
117+ ** Metrics details**
118+
119+ Nginx data | Name | Exposed informations
120+ ------------------ | ------------------------------- | ------------------------
121+ ** Requests** | ` {NAMESPACE}_upstream_requests ` | code [ 2xx, 3xx, 4xx, 5xx and total] , upstream _ (or upstream name)_
122+ ** Bytes** | ` {NAMESPACE}_upstream_bytes ` | direction [ in, out] , upstream _ (or upstream name)_
123+ ** Response time** | ` {NAMESPACE}_upstream_response ` | backend (or server), in_bytes, out_bytes, upstream _ (or upstream name)_
124+
125+ ** Metrics output example**
126+
127+ ``` txt
128+ # Upstream Requests
129+ nginx_upstream_requests{code="1xx",upstream="XXX-XXXXX-3000"} 0
130+
131+ # Upstream Bytes
132+ nginx_upstream_bytes{direction="in",upstream="XXX-XXXXX-3000"} 0
133+
134+ # Upstream Response time
135+ nginx_upstream_response{backend="10.2.15.10:3000",upstream="XXX-XXXXX-3000"} 99
57136```
0 commit comments