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

implement OpenMetrics support for real #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Oct 4, 2024

  1. implement OpenMetrics support for real

    I discovered that thanos-federate-proxy lies about its
    capabilities: it's not truly OpenMetrics compliant.
    
    The prometheus metrics scrape endpoint representation
    differs from OpenMetrics in subtle ways. This makes consumers
    that only support OpenMetrics fail to scrape anything produced
    by thanos-federate-proxy.
    
    I don't think this is a good idea, but I wanted to see if it was
    technically possible. I also don't know if this is a dumb
    contortion or if there is a better way to achieve it.
    
    thanos-federate-proxy retrieves from the upstream using
    Prometheus Query API. This API returns `model.Value`, which
    is a wire representation that does not have all the same information
    presented in a scrape endpoint (MetricsFamily). If we transformed
    to MetricsFamily _somehow_, we would be able to use the `expfmt`
    package from `prometheus/common` module that has the official bits
    for content negotiation and serialization into the
    scrape endpoint textual representation.
    
    So the challenge here
    was how to transform `model.Value` to MetricsFamily.
    I discovered Prometheus offers Metadata API, which gives us the missing
    bits. Unfortunately, Thanos does not expose this API, so this commit
    requires you to wire up the metadata API through the upstream prometheus.
    API Queries will hit Thanos, and metadata API calls will hit prometheus.
    The latter is done outside the critical path on an interval, which is currently
    hardcoded to 1 minute.
    
    No guarantees here. I'm not sure if the transformation is done correctly.
    vroldanbet committed Oct 4, 2024
    Configuration menu
    Copy the full SHA
    481efb5 View commit details
    Browse the repository at this point in the history