artprima / prometheus-metrics-bundle

Symfony 5/6 Prometheus Metrics Bundle
MIT License
133 stars 29 forks source link

Mixing metrics when there are more than one instance #38

Closed jmjimenez closed 3 years ago

jmjimenez commented 3 years ago

I have implemented 2 microservices:

The problem I have found is that each entry point is listing its own metrics XXXX_http_2xx_responses_total_counter BUT it is also publishing the metrics of the other microservice YYYY_http_2xx_responses_total_counter

I can see 2 possible solutions:

denisvmedia commented 3 years ago

The main problem is that you are using the same Redis database for both of your services. You should avoid this. To solve your problem you can have one of the following solutions:

jmjimenez commented 3 years ago

Thanks for your quick response!!!

I cannot use APCU because my architecture is a bit complex: each "microservice" is composed of a web server and some script listeners. If I want to collect metrics from these scripts, I cannot use APCU because as far as I know APCU is not shared between scripts and web processes

I would like to have one redis for each microservice. But this scenario will make my deployment harder (I have tried...)

In fact, I have studied the code and I think I have found a clean solution in the current implementation: redis adapter has an additional parameter 'prefix'. This prefix will be used to identify all keys stored and retrieved from redis. So, I can assign different prefixes to each of my microservices and it will make the work done

Thanks again for your help!!!!!