Best way to export hundreds external values
Hi there.
our situation is next. In managed code we use external native lib that exports some counters. a lot of counters. around 100. What will be best way to handle that? is creation of 100 metrics objects and updating them before scraping good approach? is there a way to extend data serialized by lib before they will be send to prometheus? EDT:
- is it possible to add callback like MetricServer/MetricPusher.OnSerializeFinished(Stream s) so that we could add our content just before sending?
This library is designed for instrumenting an app with metrics. It is perhaps not the ideal solution for converting metrics from some other external source into Prometheus metrics. You can still do it but it might not always be the most natural.
is creation of 100 metrics objects and updating them before scraping good approach?
Not a problem of itself, as long as you can ensure the updates are fast enough not to cause scrapes to get timed out.
is there a way to extend data serialized by lib before they will be send to prometheus?
No, this is intentionally not a part of the API surface and not a design goal of the library. The Prometheus metrics format is quite simple, so if you just want to convert some external metrics, writing some custom code to generate the Prometheus format metrics might be the easiest option for creating a converter - no need to have a library in between.
The Prometheus metrics format is quite simple, so if you just want to convert some external metrics, writing some custom code to generate the Prometheus format metrics might be the easiest option for creating a converter - no need to have a library in between
well, yes. it is true that it is quite simple. However we are using both worlds. Metrics from previous version of this lib and stuff from native. To not have setup hell with multiple ports and scraping endpoints (counters should be insync) it would be good to have one scraping endpoint that provides all information at once