Not able see mtail metrics on Prometheus

130 views
Skip to first unread message

Krishna Khatana

unread,
Jul 4, 2021, 10:58:38 PM7/4/21
to mtail-users
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/metrics
and 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:
      - targets: ['127.0.0.1:9090']
  - job_name: 'mtail'
    scrape_interval: 5s
    static_configs:
      - targets: [' 127.0.0.1:9101']


please help urgently as i am stuck at here, it will be a great help.

Jamie Wilkinson

unread,
Jul 5, 2021, 1:47:24 AM7/5/21
to Krishna Khatana, mtail-users
If you look at the INFO log it should tell you which variables are created by the program.

I'm assuming you're talking about the mtail's /metrics URL, not Prometheus itself?

As the variable being exported is a labelled map-type, or dimensioned variable, it won't be shown until a log line is read.  I suppose mtail could make this easier to see on the /progz page, but until there's a value to put in the label itself, mtail doesn't know what to show in /metrics.

So, if you start processing nginx logs, does it start to show up?

--
You received this message because you are subscribed to the Google Groups "mtail-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mtail-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mtail-users/39ab4e71-f4e3-42a6-8c57-d9471540469an%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages