Last active
November 22, 2019 19:46
-
-
Save KristofferRisa/a331fa981ac369b8706b10b05aae41fc to your computer and use it in GitHub Desktop.
Nginx monitor setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nginx -V 2>&1 | grep -o with-http_stub_status_module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nginx -s reload | |
curl 127.0.0.1:9090/nginx_status | |
telegraf --test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[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