Git Product home page Git Product logo

nginx_exporter's Introduction

Nginx Exporter for Prometheus

This Prometheus Exporter retrieves nginx stats and exports them via HTTP for Prometheus consumption.

To run it:

./nginx_exporter [flags]

Help on flags:

./nginx_exporter --help

Using Docker

docker pull fish/nginx-exporter

docker run -d -p 9113:9113 fish/nginx-exporter \
    -nginx.scrape_uri=http://172.17.42.1/nginx_status

In production you should use a tagged release: https://hub.docker.com/r/fish/nginx-exporter/tags/

Alternatives

While nginx natively only provides the small set of metrics this exporter provides, nginx-module-vts adds extensive metrics that can be consumed by:

nginx_exporter's People

Contributors

0x46616c6b avatar discordianfish avatar fffonion avatar hunterlau2020 avatar jforest avatar ledgr avatar marctc avatar matsumana avatar sdurrheimer avatar wjkohnen avatar zipkid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nginx_exporter's Issues

Can I specify several scrape_uri at the same time to scrape multiple servers?

Now I can just specify one uri by:
./nginx_exporter -nginx.scrape_uri http://<ip>:<port>/nginx_status -telemetry.address :<metric_port>

But in the nginx.conf, I setup several servers by:

server {
        listen 1234;
        ---other loacations here----
        location /nginx_status {
            stub_status on;
            access_log logs/access1.log;
        }
    }
server {
        listen 5678;
        ---other loacations here----
        location /nginx_status {
            stub_status on;
            access_log logs/access2.log;
        }
    }

It seemd like I have to run TWO nginx_exporter. Is there any way to scrape all metrics among different servers by just run ONE nginx_exporter? Just like:
./nginx_exporter -nginx.scrape_uri http://<ip>:<port>/nginx_status http://<ip1>:<port1>/nginx_status http://<ip2>:<port2>/nginx_status

or just use a config file like:

# scrape.yaml
...
scrape_uri:
  - http://<ip>:<port>/nginx_status
  - http://<ip1>:<port1>/nginx_status
  - http://<ip2>:<port2>/nginx_status
...

Make fails to compile

Running make yields the following output:

Go version 1.4.2 required but not found in PATH.
About to download and install go1.4.2 to /home/user/tmp/nginx_exporter/.build/go1.4.2
Abort now if you want to manually install it system-wide instead.

mkdir -p /home/user/tmp/nginx_exporter/.build/go1.4.2
curl -L https://golang.org/dl/go1.4.2.linux-amd64.tar.gz | tar -C /home/user/tmp/nginx_exporter/.build/go1.4.2 --strip 1 -xz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    87  100    87    0     0    463      0 --:--:-- --:--:-- --:--:--   465
100 59.5M  100 59.5M    0     0  15.5M      0  0:00:03  0:00:03 --:--:-- 17.4M
mkdir -p /home/user/tmp/nginx_exporter/.build/gopath/src/github.com/prometheus/
ln -s /home/user/tmp/nginx_exporter /home/user/tmp/nginx_exporter/.build/gopath/src/github.com/prometheus/nginx_exporter
GOROOT=/home/user/tmp/nginx_exporter/.build/go1.4.2 GOPATH=/home/user/tmp/nginx_exporter/.build/gopath /home/user/tmp/nginx_exporter/.build/go1.4.2/bin/go get -d
touch dependencies-stamp
GOROOT=/home/user/tmp/nginx_exporter/.build/go1.4.2 GOPATH=/home/user/tmp/nginx_exporter/.build/gopath /home/user/tmp/nginx_exporter/.build/go1.4.2/bin/go build  -o nginx_exporter
# github.com/prometheus/client_golang/prometheus
.build/gopath/src/github.com/prometheus/client_golang/prometheus/go_collector.go:226: ms.GCCPUFraction undefined (type *runtime.MemStats has no field or method GCCPUFraction)
Makefile.COMMON:98: recipe for target 'nginx_exporter' failed
make: *** [nginx_exporter] Error 2

It can easily be fixed by setting GO_VERSION=1.8.

New Docker images fail to start for us?

Hi,

Quick bug report to ensure impact is minimalized. It may be the case that the latest version of the Docker images (from a couple of hours ago) fail with this:

/bin/nginx_exporter: relocation error: /lib/libpthread.so.0: symbol h_errno, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference

HTH,
Ed

json.Unmarshal failed

2017/06/02 14:10:54 json.Unmarshal failed invalid character 'A' looking for beginning of value
2017/06/02 14:11:24 json.Unmarshal failed invalid character 'A' looking for beginning of value
2017/06/02 14:11:54 json.Unmarshal failed invalid character 'A' looking for beginning of value

Looks like it expects the status to be in JSON format ? I guess this is only available in the Plus version of Nginx ?

Consider creating release

Would be great if you created some releases with binaries, such that there is no need for downloading and compiling self.

Error starting latest build

Getting the following error if i try to start the latest container:

/bin/nginx_exporter: relocation error: /lib/libpthread.so.0: symbol h_errno, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference

nginx_exporter failing with "panic: inconsistent label cardinality"

My go version: nginx_exporter@test1:~/nginx_exporter_repo$ go version go version go1.6.2 linux/amd64

My linux version: nginx_exporter@test1:~/nginx_exporter_repo$ cat /etc/issue Debian GNU/Linux 8 \n \l

My error:

nginx_exporter@test1:~/nginx_exporter_repo$ ./nginx_exporter -log.level debug -nginx.scrape_uri http://localhost:19114/nginx_status -telemetry.address :9114
INFO[0000] Starting Server: :9114                        file=nginx_exporter.go line=174
panic: inconsistent label cardinality

goroutine 29 [running]:
panic(0x7f63e0, 0xc820011580)
	/usr/lib/go-1.6/src/runtime/panic.go:481 +0x3e6
github.com/prometheus/client_golang/prometheus.MustNewConstMetric(0xc8200e8070, 0x1, 0x4049000000000000, 0xc820174040, 0x1, 0x1, 0x0, 0x0)
	/home/nginx_exporter/gocode/src/github.com/prometheus/client_golang/prometheus/value.go:172 +0xd0
main.(*Exporter).collect(0xc8200ce190, 0xc8200f0240, 0x0, 0x0)
	/home/nginx_exporter/nginx_exporter_repo/nginx_exporter.go:119 +0x998
main.(*Exporter).Collect(0xc8200ce190, 0xc8200f0240)
	/home/nginx_exporter/nginx_exporter_repo/nginx_exporter.go:160 +0xa1
github.com/prometheus/client_golang/prometheus.(*Registry).Gather.func2(0xc8200d64e0, 0xc8200f0240, 0x7f945fab5298, 0xc8200ce190)
	/home/nginx_exporter/gocode/src/github.com/prometheus/client_golang/prometheus/registry.go:382 +0x58
created by github.com/prometheus/client_golang/prometheus.(*Registry).Gather
	/home/nginx_exporter/gocode/src/github.com/prometheus/client_golang/prometheus/registry.go:383 +0x360

Seems related to the latest merge, but I'm not a go expert :/

Add LICENSE file?

I'd like to package this for a linux distribution, but to do so will require some indication of what open source license it is under.

go test fails

go test prints:

--- FAIL: TestNginxStatus (0.00s)
	nginx_exporter_test.go:41: expected closed channel

Monitor multi nginx.scrape_uri

Hi, I have the US of monitor multi nginx.scrape_uri, It seems not support monitor config like

-nginx.scrape_uri=http://172.0.0.101/ngx_status
-nginx.scrape_uri=http://172.0.0.102/ngx_status

So , I have to hard code and initial docker with these config

nginx-exporter1:
image: fish/nginx-exporter
ports:
- 9113:9113
command:
- -nginx.scrape_uri=http://172.0.0.101/ngx_status

nginx-exporter2:
image: fish/nginx-exporter
ports:
- 9114:9113
command:
- -nginx.scrape_uri=http://172.0.0.102/ngx_status

So, is there any best practice for this kind of scenario?

Docker image?

Thanks for creating this! Is it available on the Docker Hub? Or is that in the works?

Build failing on OSX with 'tar: Unrecognized archive format'

Probably because there was no OSX 10.11.6 back when Go 1.4.2 was built.

...
curl -L https://golang.org/dl/go1.4.2.darwin-amd64-osx10.11.6.tar.gz | tar -C /build/nginx_exporter/.build/go1.4.2 --strip 1 -xz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    99  100    99    0     0    275      0 --:--:-- --:--:-- --:--:--   276
100   127  100   127    0     0    163      0 --:--:-- --:--:-- --:--:--     0
tar: Unrecognized archive format
tar: Error exit delayed from previous errors.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.