Skip to content

Commit

Permalink
Merge pull request #6 from hnlq715/hnlq715-patch-1
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
sysulq authored Jan 12, 2017
2 parents dbed074 + 1642b0a commit f39792f
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 79 deletions.
125 changes: 102 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,52 @@
#nginx-vts-exporter
# nginx-vts-exporter

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

#Dependency
## Table of Contents
* [Dependency](#dependency)
* [Download](#download)
* [Compile](#compile)
* [Run](#run)
* [Dockerized](#dockerized)
* [Environment variables](#environment-variables)
* [Docker Build](#docker-build)
* [Docker Run](#docker-run)
* [Metrics](#metrics)
* [Server main](#server main)
* [Server zones](#server zones)
* [Upstreams](#upstreams)

## Dependency

* [nginx-module-vts](https://github.com/vozlt/nginx-module-vts)
* [Prometheus](https://prometheus.io/)
* [Golang](https://golang.org/)

#Download
Binary can be downloaded from `bin` directory.
Latest version v0.0.3
## Download

```
# SHA512 Sum
16eec84a6496529ef76a83af54f659111abecca6bcb4b2edd0b327223f93e735ae4aca2078bf4c41fded831c3d116170b277d194af64074f45992191e3a7bfb6 bin/nginx-vts-exporter
```
Binary can be downloaded from [Releases](https://github.com/hnlq715/nginx-vts-exporter/releases) page.

#Compile
## Compile

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

#Run

``` shell
./build-binary.sh
```
$ nohup /bin/nginx-vts-exporter -nginx.scrape_uri=http://localhost/status/format/json

## Run

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

#Dockerized
## Dockerized

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

## Environment variables
### Environment variables

This image is configurable using different env variables

Variable name | Default | Description
Expand All @@ -45,13 +57,80 @@ METRICS_ADDR | :9913 | Metrics exportation address:port
METRICS_NS | nginx | Prometheus metrics Namespaces


##Build
### Docker Build

``` shell
./build-binary.sh
docker build -t vts-export .
```
$ ./build-binary.sh
$ docker build -t vts-export .

### Docker Run

``` shell
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]

**Metrics output example**

``` txt
# Server Connections
nginx_server_connections{status="accepted"} 70606
```

##Run
### Server zones

**Metrics details**

Nginx data | Name | Exposed informations
------------------ | ------------------------------- | ------------------------
**Requests** | `{NAMESPACE}_server_requests` | code [2xx, 3xx, 4xx, 5xx, total], host _(or domain name)_
**Bytes** | `{NAMESPACE}_server_bytes` | direction [in, out], host _(or domain name)_
**Cache** | `{NAMESPACE}_server_cache` | status [bypass, expired, hit, miss, revalidated, scarce, stale, updating], host _(or domain name)_

**Metrics output example**

``` txt
# Server Requests
nginx_server_requests{code="1xx",host="test.domain.com"} 0
# Server Bytes
nginx_server_bytes{direction="in",host="test.domain.com"} 21
# Server Cache
nginx_server_cache{host="test.domain.com",status="bypass"} 2
```
docker run -ti --rm --env NGIX_HOST="http://localhost/status/format/json" --env METRICS_NS="nginx_prod1" vts-export

### Upstreams

**Metrics details**

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

**Metrics output example**

``` txt
# Upstream Requests
nginx_upstream_requests{code="1xx",upstream="XXX-XXXXX-3000"} 0
# Upstream Bytes
nginx_upstream_bytes{direction="in",upstream="XXX-XXXXX-3000"} 0
# Upstream Response time
nginx_upstream_response{backend="10.2.15.10:3000",upstream="XXX-XXXXX-3000"} 99
```
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1
0.3
Binary file removed bin/nginx-vts-exporter
Binary file not shown.
55 changes: 0 additions & 55 deletions metrics.md

This file was deleted.

0 comments on commit f39792f

Please sign in to comment.