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_scrape source's query doesn't add the [] to mapping list #22049

Closed
valleedelisle opened this issue Dec 18, 2024 · 6 comments
Closed
Labels
source: prometheus_scrape Anything `prometheus_scrape` source related type: bug A code related bug.

Comments

@valleedelisle
Copy link

A note for the community

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Problem

Result:

2024-12-18T03:55:00.342027Z DEBUG source{component_kind="source" component_id=src-metrics-prod-proxy component_type=prometheus_scrape}:http: vector::internal_events::http_client: Sending HTTP request. uri=https://myprometheus/federate?match=%7Bjob%3D%something%22%7D method=GET version=HTTP/1.1 headers={"accept": "text/plain", "user-agent": "Vector/0.43.1 (x86_64-unknown-linux-musl e30bf1f 2024-12-10 16:14:47.175528383)", "accept-encoding": "identity"} body=[empty]

Configuration

Sample config:


      src-metrics-prod-proxy:
        endpoints:
        - "https://myprometheus/federate"
        honor_labels: true
        scrape_interval_secs: 60
        scrape_timeout_secs: 45
        query:
          match:
            - '{job="something"}'
        tls:
          verify_certificate: false
          verify_hostname: false
        type: prometheus_scrape

Version

vector 0.43.1 (x86_64-unknown-linux-musl e30bf1f 2024-12-10 16:14:47.175528383)

Debug Output

No response

Example Data

No response

Additional Context

No response

References

No response

@valleedelisle valleedelisle added the type: bug A code related bug. label Dec 18, 2024
@jszwedko
Copy link
Member

HI @valleedelisle !

I think I'm missing the issue here. Could you describe the expected behavior?

@jszwedko jszwedko added the source: prometheus_scrape Anything `prometheus_scrape` source related label Dec 18, 2024
@valleedelisle
Copy link
Author

Sorry, I should have clarified this.

Prometheus is expecting a url like this:
https://myprometheus/federate?match[]=%7Bjob%3D%something%22%7D

As opposed to this:
https://myprometheus/federate?match=%7Bjob%3D%something%22%7D

@jszwedko
Copy link
Member

Ah I see. It's curious that this issue hasn't been reported before. That match feature has been there for quite a while 🤔

@sainad2222
Copy link
Contributor

I tried by modifying your source config to include [] after match, something like this and it's working after that

Sample config:


      src-metrics-prod-proxy:
        endpoints:
        - "https://myprometheus/federate"
        honor_labels: true
        scrape_interval_secs: 60
        scrape_timeout_secs: 45
        query:
          match[]:
            - '{job="something"}'
        tls:
          verify_certificate: false
          verify_hostname: false
        type: prometheus_scrape

But if we want to make it easier, I created a PR to replace match key with match[] at source while building url

@pront
Copy link
Member

pront commented Jan 6, 2025

Looking at our example:

fn query_example() -> serde_json::Value {
    serde_json::json! ({
        "match[]": [
            "{job=\"somejob\"}",
            "{__name__=~\"job:.*\"}"
        ]
    })
}

...this looks like a configuration issue, replacing this:

query:
  match:
    - '{job="something"}'

with this:

query:
  match[]:
    - '{job="something"}'

should fix it.

@jszwedko
Copy link
Member

jszwedko commented Jan 6, 2025

Agreed, I think what @pront shared is the way to do this, currently, with Vector. We have another issue tracking improvements to query string generation that will make this more straight-forward: #12073. I'll close this one, but feel free to follow along on the other.

@jszwedko jszwedko closed this as not planned Won't fix, can't repro, duplicate, stale Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
source: prometheus_scrape Anything `prometheus_scrape` source related type: bug A code related bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants