github.com/thanos-io/thanos@v0.32.5/mixin/rules/receive.libsonnet (about) 1 { 2 local thanos = self, 3 receive+:: { 4 selector: error 'must provide selector for Thanos Receive recording rules', 5 dimensions: std.join(', ', std.objectFields(thanos.targetGroups) + ['job']), 6 }, 7 prometheusRules+:: { 8 groups+: if thanos.receive == null then [] else [ 9 { 10 name: 'thanos-receive.rules', 11 rules: [ 12 { 13 record: ':grpc_server_failures_per_unary:sum_rate', 14 expr: ||| 15 ( 16 sum by (%(dimensions)s) (rate(grpc_server_handled_total{grpc_code=~"Unknown|ResourceExhausted|Internal|Unavailable|DataLoss|DeadlineExceeded", %(selector)s, grpc_type="unary"}[5m])) 17 / 18 sum by (%(dimensions)s) (rate(grpc_server_started_total{%(selector)s, grpc_type="unary"}[5m])) 19 ) 20 ||| % thanos.receive, 21 }, 22 { 23 record: ':grpc_server_failures_per_stream:sum_rate', 24 expr: ||| 25 ( 26 sum by (%(dimensions)s) (rate(grpc_server_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_server_started_total{%(selector)s, grpc_type="server_stream"}[5m])) 29 ) 30 ||| % thanos.receive, 31 }, 32 { 33 record: ':http_failure_per_request:sum_rate', 34 expr: ||| 35 ( 36 sum by (%(dimensions)s) (rate(http_requests_total{handler="receive", %(selector)s, code!~"5.."}[5m])) 37 / 38 sum by (%(dimensions)s) (rate(http_requests_total{handler="receive", %(selector)s}[5m])) 39 ) 40 ||| % thanos.receive, 41 }, 42 { 43 record: ':http_request_duration_seconds:histogram_quantile', 44 expr: ||| 45 histogram_quantile(0.99, 46 sum by (%(dimensions)s, le) (rate(http_request_duration_seconds_bucket{handler="receive", %(selector)s}[5m])) 47 ) 48 ||| % thanos.receive, 49 labels: { 50 quantile: '0.99', 51 }, 52 }, 53 { 54 record: ':thanos_receive_replication_failure_per_requests:sum_rate', 55 expr: ||| 56 ( 57 sum by (%(dimensions)s) (rate(thanos_receive_replications_total{result="error", %(selector)s}[5m])) 58 / 59 sum by (%(dimensions)s) (rate(thanos_receive_replications_total{%(selector)s}[5m])) 60 ) 61 ||| % thanos.receive, 62 }, 63 { 64 record: ':thanos_receive_forward_failure_per_requests:sum_rate', 65 expr: ||| 66 ( 67 sum by (%(dimensions)s) (rate(thanos_receive_forward_requests_total{result="error", %(selector)s}[5m])) 68 / 69 sum by (%(dimensions)s) (rate(thanos_receive_forward_requests_total{%(selector)s}[5m])) 70 ) 71 ||| % thanos.receive, 72 }, 73 { 74 record: ':thanos_receive_hashring_file_failure_per_refresh:sum_rate', 75 expr: ||| 76 ( 77 sum by (%(dimensions)s) (rate(thanos_receive_hashrings_file_errors_total{%(selector)s}[5m])) 78 / 79 sum by (%(dimensions)s) (rate(thanos_receive_hashrings_file_refreshes_total{%(selector)s}[5m])) 80 ) 81 ||| % thanos.receive, 82 }, 83 ], 84 }, 85 ], 86 }, 87 }