Comments (5)
@alfaro28 if you want to be 100 % exact your solution still does not cover the recommendation completely:
Time series that are not present until something happens are difficult to deal with
In Prometheus you must make a distinction between a metric and time series. A metrc is something like requests_total
. In this example you have one (1) metric. And it can contain multiple time series:
requests_total{handler="/". status="302"}
requests_total{handler="/". status="400"}
requests_total{handler="/foo{item_id}". status="500"}
So you would have to initialize ALL possible combinations, because technically every new value leads to a new separate time series. Though in real life it is often enough to approximate it like you did by just initializing a subset of all time series.
Transferred to this project this means that we can also only cover a subset. For example all time series only containing the metric name.
from prometheus-fastapi-instrumentator.
I'm experiencing an issue that might be related to this. Whenever I add a new metric into the instrumentator, I lose some of the "default" metrics that come with this package (that is, the ones I see when I'm not registering any custom metric).
On the left, you can see the metrics I get whenever I call the endpoint without adding any custom metrics. On the right, you can see the new metric I added, but I lose many of the metrics on the left. Why is that?
from prometheus-fastapi-instrumentator.
Hey @alfaro28, you are raising a valid point. I've run into this problem myself a few times. What I'm doing atm is just writing a custom metrics closure like in metrics.py
that also initializes all my metrics. I think I could bring that into the package itself by adding an optional parameter to the metric functions that accepts the FastAPI app. Then every metric function could decide on it's own if and how it wants to init stuff.
But this solution will never cover all corner cases without custom "metric functions" (I really should find a better name for these functions that take a few settings and return a function that actually performs stuff like incrementing metrics). The reason is that only after the first request it is known if the status codes are grouped or ungrouped for example. So in the case of the default instrumentation you can actually not initialize anything, because everything is configurable.
I guess this is a big disadvantage of the approach in this package. The gathering and preprocessing of information (what is the handler? what is the status? etc) is completely separated from the actual instrumentation.
from prometheus-fastapi-instrumentator.
I managed to workaround this issue by manually sending a request when initializing my app, I guess is not such a big deal but I just wanted to bring it up
from prometheus-fastapi-instrumentator.
@lucasalvarezlacasa how are you adding the metric? Can you share some code?
from prometheus-fastapi-instrumentator.
Related Issues (20)
- Adding metrics from routers HOT 2
- Running custom metrics in background HOT 4
- Inprogress requests causes duplicated prometheus timeseries error
- labels on highr bucket default metrics
- Having metrics values even with no endpoints activity HOT 1
- Not full metrics list HOT 1
- FastAPI app with many routers HOT 3
- Instrumentator middleware includes BackgroundTask duration in http request latency metrics
- How to properly initialize modified_status when throwing exception
- Default metrics are gone when adding a custom instrumentation HOT 3
- Allow for custom dynamic labels on default metrics HOT 1
- Remove FastAPI in favor of Starlette HOT 3
- Upgrade fastapi version to support >100.0 HOT 5
- Metrics disappear when setting PROMETHEUS_MULTIPROC_DIR HOT 1
- Security Concern HOT 3
- Inprogress metrics ignore namespace and subsystem
- Setting the `PROMETHEUS_MULTIPROC_DIR` is not mentioned in the docs
- Instrument latency without streaming duration HOT 1
- FastAPI ^0.110 and on_event HOT 2
- Incorrect http_requests_total with multiple Middleware HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prometheus-fastapi-instrumentator.