docs/guides/rule-evaluations-via-query-frontend.md
This guide explains how to configure the Ruler to evaluate rules via Query Frontends instead of the Ingester/Store Gateway, and the pros and cons of rule evaluation via Query Frontend.
By default, the Ruler queries both Ingesters and Store Gateway depending on the Rule time range for evaluating rules (alerting rules or recording rules). If you have set -ruler.frontend-address, then the Ruler queries the Query Frontend for evaluation rules.
The address should be the gRPC listen address in host:port format.
You can configure via args:
-ruler.frontend-address=query-frontend.svc.cluster.local:9095
And via yaml:
ruler:
frontend_address: query-frontend.svc.cluster.local:9095
In addition, you can configure gRPC client (Ruler -> Query Frontend) config, please refer to frontend_client section in ruler config.
You can configure the query response format via -ruler.query-response-format. It is used to retrieve query results from the Query Frontend.
The supported values are protobuf and json. We recommend using protobuf(default) because the retrieved query results containing native histograms are only supported on protobuf.
When the -ruler.frontend-address is configured, the values of query stats for rule evaluation logs and metrics are all 0 in the Ruler.
You can look at the logs at the Query Frontend via enabling -frontend.enabled-ruler-query-stats (disabled by default).
Also, there are alternative metrics; you can see right-side metrics instead:
`cortex_ruler_query_seconds_total` -> `cortex_query_seconds_total{source="ruler"}`
`cortex_ruler_fetched_series_total` -> `cortex_query_fetched_series_total{source="ruler"}`
`cortex_ruler_samples_total` -> `cortex_query_samples_total{source="ruler"}`
`cortex_ruler_fetched_chunks_bytes_total` -> `cortex_query_fetched_chunks_bytes_total{source="ruler"}`
`cortex_ruler_fetched_data_bytes_total` -> `cortex_query_fetched_data_bytes_total{source="ruler"}`
If this feature is enabled, the query execute path is as follows:
Ruler -> Query Frontend -> Query Scheduler -> Querier -> Ingester/Store Gateway
There are pros and cons regarding query performance as more hops than before (Ruler -> Ingester/Store Gateway).
You can utilize the cortex_prometheus_rule_evaluation_duration_seconds metric whether to use -ruler.frontend-address.