Hello everyone
as i am new to mTail and the documentation on the internet is quite thin, so i come to you with question.
This is my mTail program:
# Copyright 2015 Ben Kochie <
sup...@gmail.com>. All Rights Reserved.
# This file is available under the Apache license.
# Parser for the common apache "NCSA extended/combined" log format
# LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"
counter http_requests_total by request_method, http_version, status_code, referer
counter lines_total
/^/ +
/(?P<hostname>[0-9A-Za-z\.:-]+) / + # %h
/(?P<remote_logname>[0-9A-Za-z-]+) / + # %l
/(?P<remote_username>[0-9A-Za-z-]+) / + # %u
/\[(?P<timestamp>\d{2}\/\w{3}\/\d{4}:\d{2}:\d{2}:\d{2} (\+|-)\d{4})\] / + # %t
/"(?P<request_method>[A-Z]+) (?P<URI>\S+) (?P<http_version>HTTP\/[0-9\.]+)" / + # \"%r\"
/(?P<status_code>\d{3}) / + # %>s
/((?P<response_size>\d+)|-) / + # %b
/"(?P<referer>\S+)" / + # \"%{Referer}i\"
/"(?P<user_agent>[[:print:]]+)"/ + # \"%{User-agent}i\"
/$/ {
http_requests_total[$request_method][$http_version][$status_code][$referer]++
}
/[[$status_code] == 'status_code=200'/ {
lines_total++
}
The line at the bottom with the pattern does not do what it is supposed to. It still counts all status codes. But i want only the 200 status codes to be counted.
Here are the metrics (varz) from the mTail on Port 3903:
ttp_requests_total{http_version=HTTP/1.1,referer=-,request_method=GET,status_code=200,prog=apache_metrics.mtail,instance=fabjon-VirtualBox} 2
http_requests_total{http_version=HTTP/1.1,referer=http://localhost/,request_method=GET,status_code=304,prog=apache_metrics.mtail,instance=fabjon-VirtualBox} 2
lines_total{prog=apache_metrics.mtail,instance=fabjon-VirtualBox} 4
I hope someone can help me.
Fabjon