Open lucasalvarezlacasa opened 7 months ago
Any updates, I am facing the same issue as well.
How did you set the environment variable? If you added it in the code using os.environ[key] = val
, then it needs to be placed before importing PrometheusFastApiInstrumentator
.
I'm serving my FastApi application using more than one worker. For this, I had to set
PROMETHEUS_MULTIPROC_DIR
and make sure it points to a proper directory, so that all workers can read/write metrics there.However, I noticed that the resulting
/metrics
endpoint exposes way less metrics than if I don't do this. For instance, metrics related to the garbage collector, the process information (CPU, GPU utilization), python version, etc, are not exposed anymore. All I see now are metrics related to the HTTP requests and responses.Any ideas why? Am I doing something wrong?
These are the metrics I get when running with more than one worker:
These are the ones I get when running only with one worker (and thus, not using
PROMETHEUS_MULTIPROC_DIR
):This is the code I'm using to register the instrumentator: