GithubHelp home page GithubHelp logo

Comments (20)

SuperQ avatar SuperQ commented on June 6, 2024 1

I don't think that's feasible. I don't see a lot of of users doing selective filtering without configuring the -service flag.

from fastly-exporter.

SuperQ avatar SuperQ commented on June 6, 2024

This is meant as an additional improvement on #31. Possibly a replacement, depending on where the bottlenecks are.

CC @neufeldtech

from fastly-exporter.

peterbourgon avatar peterbourgon commented on June 6, 2024

Super cool.

from fastly-exporter.

peterbourgon avatar peterbourgon commented on June 6, 2024

So wait, given /discovery returns

[
  { "targets": ["A", "B", "C"] }
]

there's no absolute or explicit URL mapping to each of A, B, and C — I would just assert in the exporter (or a flag or something) that they map to e.g. /service/{A, B, C} which the scraping Prometheus would have to be configured to match a priori. Is that right?

from fastly-exporter.

SuperQ avatar SuperQ commented on June 6, 2024

Yes, it needs to be re-mapped by a relabel config in Prometheus no matter what. The discovery injects the target list items into the __address__ meta-label in discovery. Prometheus doesn't treat those as URLs, it treats them as host:port pairs.

from fastly-exporter.

peterbourgon avatar peterbourgon commented on June 6, 2024

@SuperQ The bottleneck is parsing the JSON from the Fastly API. By default, the exporter fetches all services available to the provided token on startup, and launches a goroutine per service to poll the API and update the relevant metrics. The -service* flags are used to control the set of services we poll, so I think that means we need to keep them. Though maybe I could play some trick — could I lazy-launch the polling goroutine for a given service only once the exporter received a request for that service? It would mean the first scrape either had a 1s+ delay, or returned an empty response; would either of those be acceptable?

from fastly-exporter.

SuperQ avatar SuperQ commented on June 6, 2024

This is why readiness checks are a thing. Discovery can just wait for the readiness endpoint to say OK.

from fastly-exporter.

peterbourgon avatar peterbourgon commented on June 6, 2024

Discovery can just wait for the readiness endpoint to say OK.

Not sure how that would work. Is readiness per-SD-target? I'm suggesting that the exporter not poll a service ID unless/until it receives a scrape request for that service ID from Prometheus.

from fastly-exporter.

SuperQ avatar SuperQ commented on June 6, 2024

The exporter shouldn't expose a newly added service to the discovery output until it has valid API connection.

from fastly-exporter.

peterbourgon avatar peterbourgon commented on June 6, 2024

Right, but the only meaningful optimization is to try to avoid polling the API and parsing the large JSON responses if we can somehow. For example, if the user starts the exporter with a configuration that makes 10 services "visible" but only has Prometheus scrape 2 of them, it would be ideal if we didn't poll/parse/present metrics for the other 8. The only way I can think of to accomplish that is to "lazy load" the per-service polling goroutines. Is that feasible? Sounds like no. That's fine.

from fastly-exporter.

peterbourgon avatar peterbourgon commented on June 6, 2024

Is there a canonical example of an exporter that supports this new capability?

from fastly-exporter.

SuperQ avatar SuperQ commented on June 6, 2024

Not that I'm aware of, this would be the first one.

from fastly-exporter.

peterbourgon avatar peterbourgon commented on June 6, 2024

So this is an interesting design conundrum. I think the right way to think about this is that we're adding /metrics endpoints that are backed by a kind of pseudo-registry: something that takes the main registry and filters based on a label. I guess you could do that by wrapping the Registry with something that takes a service ID and yields a custom Gatherer? Or am I looking at this the wrong way?

from fastly-exporter.

peterbourgon avatar peterbourgon commented on June 6, 2024

Ah! Huh.

So the other angle would be something like maintaining a separate gen.Metrics/prometheus.Registry for each service. That makes per-service /metrics endpoints easy. Could you then just use a prometheus.Gatherers to abstract over all of them to serve the existing /metrics endpoint? Would that be efficient/effective?

from fastly-exporter.

SuperQ avatar SuperQ commented on June 6, 2024

Yes, setting up a separate registry per-service makes the most sense to me.

Although, typically, an exporter like this would manage the data internally. You implement your own prometheus.Collect(ch) to send data to the Prometheus via the interface. We do something like this in the node_exporter.

from fastly-exporter.

peterbourgon avatar peterbourgon commented on June 6, 2024

#73

from fastly-exporter.

peterbourgon avatar peterbourgon commented on June 6, 2024

Ah, @SuperQ, what would the Prometheus config look like for this? Especially whatever relabel config would be necessary.

from fastly-exporter.

SuperQ avatar SuperQ commented on June 6, 2024

The scrape config and relabel is in the issue summary.

from fastly-exporter.

SuperQ avatar SuperQ commented on June 6, 2024

I tested this out locally, looks really good. It even works well with the modulo sharding so you get the best of both worlds, horizontal sharding and automatic discovery.

from fastly-exporter.

peterbourgon avatar peterbourgon commented on June 6, 2024

the issue summary

Thank you 🤦

from fastly-exporter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.