telegraf icon indicating copy to clipboard operation
telegraf copied to clipboard

prometheus_metric_types config option invalid in 1.28.1

Open micha3lbrown opened this issue 3 years ago • 3 comments

Relevant telegraf.conf

[[outputs.prometheus_client]]
    alias = "service"
    namepass = ["service.*"]
    namedrop = []
    fielddrop = []
    listen = ":9273"
    metric_version = 2
    export_timestamp = true
    path = "/metrics"
    expiration_interval = "60s"
    string_as_label = true
    [outputs.prometheus_client.prometheus_metric_types]
       counter = [
         "service.server.requests",
       ]

Logs from Telegraf

$ /telegraf/telegraf --version
Telegraf 1.28.1 (git: HEAD@3ea9ffbe)

$ /telegraf/telegraf --config /etc/configs/telegraf.conf --test
2023-09-26T17:49:56Z I! Loading config: /etc/configs/telegraf.conf
2023-09-26T17:49:56Z E! error loading config file /etc/configs/telegraf.conf: plugin outputs.prometheus_client: line 98: configuration specified the fields ["prometheus_metric_types"], but they weren't used

System info

Linux 5.15.X

Docker

No response

Steps to reproduce

  1. Update to Telegraf v1.28.1
  2. Verify binary running telegraf --version
  3. Verify prom endpoint exposed w/ relevant metrics
  4. Add [outputs.prometheus_client.prometheus_metric_types]
  5. Run config check w/ telegraf --config /etc/configs/telegraf.conf --test
  6. Verify error

Expected behavior

Telegraf should recognize the prometheus_metric_types block and categorize each metric listed as counter or gauge.

Actual behavior

Telegraf fails to start, failing the config check.

Additional info

Binary pulled from GH.

telegraf-1.28.1_linux_amd64.tar.gz shasum 256: 12bba32a6041efab0ca1b2877d943f7bf877cfd81cc295964b75f93ee455c143

micha3lbrown avatar Sep 26 '23 18:09 micha3lbrown

@srebhan is this suppose to be:

- [outputs.prometheus_client.prometheus_metric_types]
+ [outputs.prometheus_client.metric_types]

Docs will need to get updated, and should this also be in the serializer registry?

Thanks

powersj avatar Sep 26 '23 18:09 powersj

Thanks, adjusting the config to metric_types resolves the issue. 🙏

micha3lbrown avatar Sep 26 '23 18:09 micha3lbrown

no prob. Let me get @srebhan to confirm that is what is expected and we can update all the docs to match.

powersj avatar Sep 26 '23 18:09 powersj