Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fluent prometheus metric-label bring unreadable code #153

Open
zhboseu opened this issue May 6, 2020 · 0 comments
Open

fluent prometheus metric-label bring unreadable code #153

zhboseu opened this issue May 6, 2020 · 0 comments

Comments

@zhboseu
Copy link

zhboseu commented May 6, 2020

  • description

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

  • fluentd conf
<source>
  @type forward
  port 24224
  bind 0.0.0.0
</source>

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

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

<filter test.log>
  @type parser
  key_name log
  reserve_time true
  reserve_data true
  emit_invalid_record_to_error true
  <parse>
    @type regexp
    expression /(?<logTime>^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}),(?<spi>.*),(?<spiDesc>.*),(?<duration>\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
  </parse>
</filter>

<match test.log>
  @type copy
  <store>
    @type stdout
  </store>
  <store>
    @type prometheus
    <metric>
        name message_log_counter
        type counter
        desc The total number of log in message.
        <labels>
            spi ${spi}
            spiDesc ${spiDesc}
        </labels>
    </metric>
    <metric>
        name message_log_gauge
        type gauge
        desc The gauge number of log in message.
        key duration
        <labels>
            spi ${spi}
            spiDesc ${spiDesc}
        </labels>
    </metric>
  </store>
</match>
  • 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant