fluent / fluent-plugin-prometheus

A fluent plugin that collects metrics and exposes for Prometheus.
Apache License 2.0
258 stars 79 forks source link

fluent prometheus metric-label bring unreadable code #153

Open zhboseu opened 4 years ago

zhboseu commented 4 years ago

In our scenario, fluentd-plugin-prometheus was used to collect metrics, some metrics label parsed from regexp, while some fields are not ASCII. Result show unreadble code

@type prometheus port 24231 bind 0.0.0.0 metrics_path /metrics aggregated_metrics_path /aggregated_metrics

<filter **> @type record_transformer char_encoding utf-8

@type parser key_name log reserve_time true reserve_data true emit_invalid_record_to_error true @type regexp expression /(?^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}),(?.*),(?.*),(?\d+)$/ time_key logTime time_format %Y-%m-%d %H:%M:%S.%L keep_time_key true null_empty_string true types duration:integer,spiDesc:string @type copy @type stdout @type prometheus name message_log_counter type counter desc The total number of log in message. spi ${spi} spiDesc ${spiDesc} name message_log_gauge type gauge desc The gauge number of log in message. key duration spi ${spi} spiDesc ${spiDesc}

- reproduce scription

echo '{"log":"2020-05-05 11:17:53.755,test,テスト,49"}' |fluent-cat test.log



- result

we get correct stdout 
> 2020-05-06 15:00:18.062825596 +0800 test.log: {"log":"2020-05-05 11:17:53.755,test,テスト,49","logTime":"2020-05-05 11:17:53.755","spi":"test","spiDesc":"テスト","duration":49}

but metric labels are unreadble
> \# TYPE message_log_counter counter
> \# HELP message_log_counter The total number of log in message.
> message_log_counter{spi="test",spiDesc="銉嗐偣銉�"} 1.0
> \# TYPE message_log_gauge gauge
> \# HELP message_log_gauge The gauge number of log in message.
> message_log_gauge{spi="test",spiDesc="銉嗐偣銉�"} 49.0

what's wrong?

- version
fluent-plugin-prometheus 1.7.3
fluentd 1.10.3
ruby 2.7.1p83