Prometheus
Prometheus is a monitoring solution we use at Q2 for keeping track of the stats that matter most to a running service.
There are a few gotchas in working with Prometheus that we’ve attempted to abstract away with this module. To use it will be something like this:
prometheus.get_metric(
MetricType.Counter,
'caliper_endpoints',
'Number of times called',
labels={'endpoint': self.extension_name}
).inc()
- enum q2_sdk.core.prometheus.MetricType(value)[source]
Available metric types according to Prometheus
Valid values are as follows:
- Counter = <MetricType.Counter: <class 'prometheus_client.metrics.Counter'>>
- Histogram = <MetricType.Histogram: <class 'prometheus_client.metrics.Histogram'>>
- Info = <MetricType.Info: <class 'prometheus_client.metrics.Info'>>
- Summary = <MetricType.Summary: <class 'prometheus_client.metrics.Summary'>>
- Gauge = <MetricType.Gauge: <class 'prometheus_client.metrics.Gauge'>>
- Enum = <MetricType.Enum: <class 'prometheus_client.metrics.Enum'>>
- Metric = <MetricType.Metric: <class 'prometheus_client.metrics_core.Metric'>>
- q2_sdk.core.prometheus.get_metric(metric_type, name, documentation, labels, namespace='', subsystem='', unit='', registry=<prometheus_client.registry.CollectorRegistry object>, chain=None, is_parent=False, **kwargs)[source]
Will return an instance of metric_type with given parameters as inputs, but will return an existing one if it already exists, creating a new one only if it’s the first time that metric combination has been seen.
Any key/value pairs in kwargs will be passed through to the underlying MetricType in prometheus_client.metrics (such as buckets for Histogram)
- Return type:
MetricWrapperBase