Hi Everyone,
Thank you so much for the help in advance, below is my program
Log format in nginx:
#log_format common '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for" $request_time $upstream_response_time ';
Mtail program:
counter http_requests_total by request_method,status
/^/ +
/(?P<remote_addr>[0-9A-Za-z\.-:]+) / +
/- / +
/(?P<remote_user>[0-9A-Za-z-]+) / +
/(?P<time_local>\[\d{2}\/\w{3}\/\d{4}:\d{2}:\d{2}:\d{2} [-|\+]\d{4}\]) / +
/"(?P<request_method>[A-Z]+) (?P<request_uri>\S+) (?P<http_version>HTTP\/[0-9\.]+)" / +
/(?P<status>\d{3}) / +
/(?P<bytes_sent>\d+) / +
/"(?P<http_referer>\S+)" / +
/"(?P<http_user_agent>[[:print:]]+)" / +
/"(?P<x_forwarded_for>[0-9A-Za-z\.-]+)" / +
/$/ {
http_requests_total[tolower($request_method)][$status]++
}
after that i am able to start mtail without any error but the issue is that i am not able to see the
http_requests_total on
http://localhost:9100/metricsand when i configured it with prometheus its same and i could not see the counter variable on prometheus as well.
mtail startup command using service :
[Unit]
Description=mtail
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
Restart=on-failure
WorkingDirectory=/usr/local/bin/
ExecStart=/usr/local/bin/mtail/mtail \
--address 127.0.0.1 --port 9101 \
--emit_prog_label=false --alsologtostderr \
--progs /etc/mtail/ \
--logs /data/nginx/logs/access.log
User=mtail
Group=mtail
[Install]
WantedBy=multi-user.target
prometheus configuration file:
global:
scrape_interval: 5s
scrape_configs:
- job_name: 'prometheus'
scrape_interval: 5s
static_configs:
- job_name: 'mtail'
scrape_interval: 5s
static_configs:
please help urgently as i am stuck at here, it will be a great help.