plugins/inputs/nginx_upstream_check/README.md
This plugin gathers metrics from the Nginx web server using the upstream check module. This module periodically sends the configured requests to servers in the Nginx's upstream determining their availability.
⭐ Telegraf v1.10.0 🏷️ server, web 💻 all
Plugins support additional global and plugin configuration settings for tasks such as modifying metrics, tags, and fields, creating aliases, and configuring plugin ordering. See CONFIGURATION.md for more details.
# Read nginx_upstream_check module status information (https://github.com/yaoweibin/nginx_upstream_check_module)
[[inputs.nginx_upstream_check]]
## An URL where Nginx Upstream check module is enabled
## It should be set to return a JSON formatted response
url = "http://127.0.0.1/status?format=json"
## You can also point it at a unix socket too
# url = "http+unix:///var/run/nginx.sock:/status?format=json"
## HTTP method
# method = "GET"
## Optional HTTP headers
# headers = {"X-Special-Header" = "Special-Value"}
## Override HTTP "Host" header
# host_header = "check.example.com"
## Timeout for HTTP requests
timeout = "5s"
## Optional HTTP Basic Auth credentials
# username = "username"
# password = "pa$$word"
## Optional TLS Config
# tls_ca = "/etc/telegraf/ca.pem"
# tls_cert = "/etc/telegraf/cert.pem"
# tls_key = "/etc/telegraf/key.pem"
## Use TLS but skip chain & host verification
# insecure_skip_verify = false
The "status_code" field most likely will be the most useful one because it allows you to determine the current state of every server and, possible, add some monitoring to watch over it. InfluxDB can use string values and the "status" field can be used instead, but for most other monitoring solutions the integer code will be appropriate.
When run with:
./telegraf --config telegraf.conf --input-filter nginx_upstream_check --test
It produces:
nginx_upstream_check,host=node1,name=192.168.0.1:8080,port=0,type=http,upstream=my_backends,url=http://127.0.0.1:80/status?format\=json fall=0i,rise=100i,status="up",status_code=1i 1529088524000000000
nginx_upstream_check,host=node2,name=192.168.0.2:8080,port=0,type=http,upstream=my_backends,url=http://127.0.0.1:80/status?format\=json fall=100i,rise=0i,status="down",status_code=2i 1529088524000000000