Skip to content

Instantly share code, notes, and snippets.

@KristofferRisa
Last active November 22, 2019 19:46
Show Gist options
  • Save KristofferRisa/a331fa981ac369b8706b10b05aae41fc to your computer and use it in GitHub Desktop.
Save KristofferRisa/a331fa981ac369b8706b10b05aae41fc to your computer and use it in GitHub Desktop.
Nginx monitor setup
nginx -V 2>&1 | grep -o with-http_stub_status_module
nginx -s reload
curl 127.0.0.1:9090/nginx_status
telegraf --test
#/etc/nginx/conf.d/status.conf
server {
listen 127.0.0.1:9090;
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
}
[[inputs.nginx]]
urls = ["http://127.0.0.1:9090/nginx_status"]
response_timeout = "5s"
[[inputs.logparser]]
files = ["/var/log/nginx/access.log"]
from_beginning = true
name_override = "nginx_access_log"
[inputs.logparser.grok]
patterns = ["%{CUSTOM_LOG_FORMAT}"]
custom_patterns = '''
CUSTOM_LOG_FORMAT %{CLIENT:client_ip} %{NOTSPACE:ident} %{NOTSPACE:auth} \[%{HTTPDATE:ts:ts-httpd}\]"(?:%{WORD:verb:tag} %{NOTSPACE:request}(?: HTTP/%{NUMBER:http_version:float})?|%{DATA})" %{NUM$
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment