fluentd_input_status_num_records_total{tag="custom.log",hostname="757214c8a91a"} 2.0 │➜ log vim fluentd.conf
fluentd_output_status_num_records_total{tag="custom.log",hostname="757214c8a91a"} 1.0
这是很常见的指标格式,如果在 Kubernetes 中,对 Pod 进行注解,纳入采集范围,就可以像其它监控指标一样使用了。
fluentd.conf
@type tail
path /data/input.txt
pos_file /data/input.pos
tag custom.log
@type none
@type prometheus
name fluentd_input_status_num_records_total
type counter
desc The total number of incoming records
tag ${tag}
hostname ${hostname}
@type grep
key message
pattern /warn/
@type copy
@type prometheus
name fluentd_output_status_num_records_total
type counter
desc The total number of outgoing records
tag ${tag}
hostname ${hostname}
@type stdout
@type prometheus
bind 0.0.0.0
port 12345
metrics_path /metrics
@type prometheus_output_monitor
interval 10
hostname ${hostname}