# linecounter.mtail
counter line_count
/$/ {
line_count++
}
对于linecounter.mtail
程序,Prometheus
刮line_count{prog="linecounter.mtail",instance="bd0a0d119df6"} 2
如何labels
在metric
?
我找不到任何关于它的描述。
# linecounter.mtail
counter line_count
/$/ {
line_count++
}
对于linecounter.mtail
程序,Prometheus
刮line_count{prog="linecounter.mtail",instance="bd0a0d119df6"} 2
如何labels
在metric
?
我找不到任何关于它的描述。
标签由 mtail 根据声明的度量自动创建!
所有指标都在指标声明中,例如:
counter my_http_requests_total by log_file, request_method
假设您有一个 HTTP 服务器日志文件,其中包含GET
和POST
:
192.168.0.1 GET /foo
192.168.0.2 GET /bar
192.168.0.1 POST /bar
使用以下 Mtail 程序:
counter my_http_requests_total by log_file, request_method
/^/ +
/(?P<hostname>[0-9A-Za-z\.:-]+) / +
/(?P<request_method>[A-Z]+) / +
/(?P<URI>\S+).*/ +
/$/ {
my_http_requests_total[getfilename()][$request_method][]++
}
Prometheus 生成的指标是:
my_http_requests_total{log_file="test.log",request_method="GET",prog="test.mtail"} 4242
my_http_requests_total{log_file="test.log",request_method="POST",prog="test.mtail"} 42
--
这里有两个神奇的指标(可以使用 Prometheus 重新标记规则来破坏):
prog
是 mtail 程序名称(脚本)