I am using the consul exporter to ingest the health and status of my services into Prometheus. I'd like to fire alerts when the status of services and nodes in Consul is critical and then use tags extracted from Consul when routing those alerts.
I understand from this discussion that service tags are likely to be exported as a separate metric, but I'm not sure how to join one series with another so I can leverage the tags with the health status.
For example, the following query:
max(consul_health_service_status{status="critical"}) by (service_name, status,node) == 1
could return:
{node="app-server-02",service_name="app-server",status="critical"} 1
but I'd also like 'env' from this series:
consul_service_tags{node="app-server-02",service_name="app-server",env="prod"} 1
to get joined along node and service_name to pass the following to the Alertmanager as a single series:
{node="app-server-02",service_name="app-server",status="critical",env="prod"} 1
I could then match 'env' in my routing.
Is there any way to do this? It doesn't look to me like any operations or functions give me the ability to group or join like this. As far as I can see, the tags would already need to be labels on the consul_health_service_status metric.
Prometheus supports the following built-in aggregation operators that can be used to aggregate the elements of a single instant vector, resulting in a new vector of fewer elements with aggregated values: sum (calculate sum over dimensions) min (select minimum over dimensions) max (select maximum over dimensions)
Although Prometheus is a primarily pull-based monitoring system, an additional component called the "Pushgateway" is available for pushing metrics from external applications and services. The Pushgateway is useful for collecting metrics from systems that are not compatible with the otherwise pull-based infrastructure.
io's Infrastructure Monitoring (Metrics) accounts usage is calculated based on the Unique Time Series (UTS). You can view your usage metrics in your Infrastructure Monitoring dashboard. Navigate to Metrics > Explore > Metrics browser.
Prometheus uses a very simple metric model with four metric types that are only supported in the client libraries.
You can use the argument list of group_left
to include extra labels from the right operand (parentheses and indents for clarity):
( max(consul_health_service_status{status="critical"}) by (service_name,status,node) == 1 ) + on(service_name,node) group_left(env) ( 0 * consul_service_tags )
The important part here is the operation + on(service_name,node) group_left(env)
:
+
is "abused" as a join operator (fine since 0 * consul_service_tags
always has the value 0)group_left(env)
is the modifier that includes the extra label env
from the right (consul_service_tags
)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With