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

prometheus input plugin does not support query parameters in scrape url path of discovered k8s pods #10238

Closed
ahothan opened this issue Dec 7, 2021 · 1 comment
Labels
bug unexpected problem or unintended behavior

Comments

@ahothan
Copy link
Contributor

ahothan commented Dec 7, 2021

Relevent telegraf.conf

Any config that enables the prometheus input plugin with k8s discovery enabled

[[inputs.prometheus]]
monitor_kubernetes_pods = true

System info

Telegraf 1.20

Docker

No response

Steps to reproduce

A bit tricky as it requires a k8s environment with k8s pod autodiscovery

  1. bring up a k8s cluster with at least one k8s pod that is a scrape target and requires query parameters in the scrape url annotation
  2. bring up a telegraf k8s pod configured to autodiscover scrape targets
  3. scrape by the plugin will fail because the query parameters are encoded incorrectly
    ...

Expected behavior

scraping should succeed by using properly formatted URL to scrape targets that require query parameters

Actual behavior

the scrape url used by the plugin is incorrect because the "?" character is incorrectly encoded as "%3F",
as a result the scrape fails.

Additional info

This bug manifests only when telegraf runs in a k8s pod, is configured to auto discover scrape target pods and when a scrape target requires query parameters in the scrape URL.

Example of target pod annotation with query parameters in the scrape URL (here a "passcode" variable):

Annotations: 
              prometheus.io/path: /metrics?passcode=secret
              prometheus.io/scrape: true 

The plugin will issue an error scraping such target:
2021-12-07T17:12:00Z E! [inputs.prometheus] Error in plugin: error making HTTP request to http://10.42.0.143:9102/metrics%3Fpasscode=secret: Get "http://10.42.0.143:9102/metrics%3Fpasscode=secret": ...

The question mark character has been incorrectly converted to "%3F"

@ahothan ahothan added the bug unexpected problem or unintended behavior label Dec 7, 2021
@ahothan
Copy link
Contributor Author

ahothan commented Dec 8, 2021

same bug as #8008
fixed by #9662
will be in v1.21 release branch

@ahothan ahothan closed this as completed Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

1 participant