Hi,
I guess the title says it all but using Gunicorn multiprocessing environment and creating a CollectorRegistry() that is passed into MultiProcessorCollector()... then doing generate_latest() on that registry, I get both keys for MultiProcess metrics and per Process Metrics. However, I would like to only see the MultiProcess Metrics and ignore the per Process Metrics. Is there a way to do that?
Here's my code for clarity:
```
import time
from flask import request, Response
from prometheus_client.multiprocess import MultiProcessCollector
from prometheus_client import generate_latest, CollectorRegistry, Counter, Histogram, CONTENT_TYPE_LATEST
REGISTRY = CollectorRegistry()
FLASK_REQUEST_LATENCY = Histogram(
'flask_request_latency_seconds',
'Flask Request Latency',
['method', 'endpoint'],
registry=REGISTRY
)
FLASK_REQUEST_COUNT = Counter(
'flask_request_count',
'Flask Request Count',
['method', 'endpoint', 'http_status'],
registry=REGISTRY
)
def configure_metrics(app):
MultiProcessCollector(REGISTRY)
@app.before_request
def before_request():
request.start_time = time.time()
@app.after_request
def after_request(response):
request_latency = time.time() - request.start_time
FLASK_REQUEST_LATENCY.labels(request.method, request.path).observe(request_latency)
FLASK_REQUEST_COUNT.labels(request.method, request.path, response.status_code).inc()
return response
@app.route('/metrics')
def metrics():
output = generate_latest(REGISTRY)
return Response(output, mimetype=CONTENT_TYPE_LATEST)
```
Thanks,
Mariam
Hi,
I guess the title says it all but using Gunicorn multiprocessing environment and creating a CollectorRegistry() that is passed into MultiProcessorCollector()... then doing generate_latest() on that registry, I get both keys for MultiProcess metrics and per Process Metrics. However, I would like to only see the MultiProcess Metrics and ignore the per Process Metrics. Is there a way to do that?
Here's my code for clarity:
```
import time
from flask import request, Response
from prometheus_client.multiprocess import MultiProcessCollector
from prometheus_client import generate_latest, CollectorRegistry, Counter, Histogram, CONTENT_TYPE_LATEST
REGISTRY = CollectorRegistry()
--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/a17c564b-3c60-4048-985e-f66d42fba77e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.