Expose metrics and selectors needed for custom rate query metrics
To generate the SLI aggregations recording rules in gitlab-com/gl-infra/scalability#2602 (closed), the metric objects need to support supportsReflection().getMetricNamesAndLabels()
and supportsReflection().getMetricNamesAndSelectors()
.
All metrics except customRateQuery
has supported the method. This issue aims to implement the similar in customRateQuery
.
We could add some fields in the customRateQuery
constructor so that we know what metrics and selectors needed to be recorded. For example, sent_tcp_packets
SLI in nat
:
diff --git a/metrics-catalog/services/nat.jsonnet b/metrics-catalog/services/nat.jsonnet
index 4e7d3de4c..8f8b25cac 100644
--- a/metrics-catalog/services/nat.jsonnet
+++ b/metrics-catalog/services/nat.jsonnet
@@ -30,12 +30,18 @@ metricsCatalog.serviceDefinition({
|||,
requestRate: customRateQuery(|||
- sum by (environment) (
- avg_over_time(
- stackdriver_nat_gateway_router_googleapis_com_nat_sent_packets_count{metric_prefix="router.googleapis.com/nat", ip_protocol="6", project_id=~"gitlab-staging-1|gitlab-production"}[%(burnRate)s]
- )
- )
- |||),
+ sum by (environment) (
+ avg_over_time(
+ stackdriver_nat_gateway_router_googleapis_com_nat_sent_packets_count{metric_prefix="router.googleapis.com/nat", ip_protocol="6", project_id=~"gitlab-staging-1|gitlab-production"}[%(burnRate)s]
+ )
+ )
+ |||,
+ metric='stackdriver_nat_gateway_router_googleapis_com_nat_sent_packets_count',
+ selector={
+ metric_prefix: 'router.googleapis.com/nat',
+ ip_protocol: '6',
+ project_id: { oneOf: ['gitlab-staging-1', 'gitlab-production'] },
+ }),
// The error rate counts the number of dropped sent TCP packets by the Cloud NAT gateway
errorRate: customRateQuery(|||
The following discussion from !6612 (merged) should be addressed:
-
@reprazent started a discussion: (+1 comment) This is mostly used for stackdriver exporter metrics, which expose gauges that act as counters and so on.
I think we'll have to figure out a nice API so we can specify what needs to be recorded for this in SLI aggregations. But that can be in follow up.