github.com/thanos-io/thanos@v0.32.5/mixin/rules/query.libsonnet (about) 1 { 2 local thanos = self, 3 query+:: { 4 selector: error 'must provide selector for Thanos Query recording rules', 5 dimensions: std.join(', ', std.objectFields(thanos.targetGroups) + ['job']), 6 }, 7 prometheusRules+:: { 8 groups+: if thanos.query == null then [] else [ 9 { 10 name: 'thanos-query.rules', 11 rules: [ 12 { 13 record: ':grpc_client_failures_per_unary:sum_rate', 14 expr: ||| 15 ( 16 sum by (%(dimensions)s) (rate(grpc_client_handled_total{grpc_code=~"Unknown|ResourceExhausted|Internal|Unavailable|DataLoss|DeadlineExceeded", %(selector)s, grpc_type="unary"}[5m])) 17 / 18 sum by (%(dimensions)s) (rate(grpc_client_started_total{%(selector)s, grpc_type="unary"}[5m])) 19 ) 20 ||| % thanos.query, 21 }, 22 { 23 record: ':grpc_client_failures_per_stream:sum_rate', 24 expr: ||| 25 ( 26 sum by (%(dimensions)s) (rate(grpc_client_handled_total{grpc_code=~"Unknown|ResourceExhausted|Internal|Unavailable|DataLoss|DeadlineExceeded", %(selector)s, grpc_type="server_stream"}[5m])) 27 / 28 sum by (%(dimensions)s) (rate(grpc_client_started_total{%(selector)s, grpc_type="server_stream"}[5m])) 29 ) 30 ||| % thanos.query, 31 }, 32 { 33 record: ':thanos_query_store_apis_dns_failures_per_lookup:sum_rate', 34 expr: ||| 35 ( 36 sum by (%(dimensions)s) (rate(thanos_query_store_apis_dns_failures_total{%(selector)s}[5m])) 37 / 38 sum by (%(dimensions)s) (rate(thanos_query_store_apis_dns_lookups_total{%(selector)s}[5m])) 39 ) 40 ||| % thanos.query, 41 }, 42 { 43 record: ':query_duration_seconds:histogram_quantile', 44 expr: ||| 45 histogram_quantile(0.99, 46 sum by (%(dimensions)s, le) (rate(http_request_duration_seconds_bucket{%(selector)s, handler="query"}[5m])) 47 ) 48 ||| % thanos.query, 49 labels: { 50 quantile: '0.99', 51 }, 52 }, 53 { 54 record: ':api_range_query_duration_seconds:histogram_quantile', 55 expr: ||| 56 histogram_quantile(0.99, 57 sum by (%(dimensions)s, le) (rate(http_request_duration_seconds_bucket{%(selector)s, handler="query_range"}[5m])) 58 ) 59 ||| % thanos.query, 60 labels: { 61 quantile: '0.99', 62 }, 63 }, 64 ], 65 }, 66 ], 67 }, 68 }