
{{- $Values := (.helm).Values | default .Values }}
{{- $runbookUrl := ($Values.defaultRules).runbookUrl | default "https://runbooks.prometheus-operator.dev/runbooks" }}
{{- $clusterLabel := ($Values.global).clusterLabel | default "cluster" }}
{{- $additionalGroupByLabels := append $Values.defaultRules.additionalGroupByLabels $clusterLabel }}
{{- $groupLabels := join "," (uniq $additionalGroupByLabels) }}
{{- $grafanaAddr := include "vm-k8s-stack.grafana.addr" . }}
name: kube-apiserver-histogram.rules
rules:
- expr: {{ printf "histogram_quantile(0.99, sum(rate(apiserver_request_sli_duration_seconds_bucket{job=\"apiserver\",verb=~\"LIST|GET\",subresource!~\"proxy|attach|log|exec|portforward\"}[5m])) by(%s,le,resource)) > 0" $groupLabels }}
  condition: true
  labels:
    quantile: "0.99"
    verb: read
  record: cluster_quantile:apiserver_request_sli_duration_seconds:histogram_quantile
- expr: {{ printf "histogram_quantile(0.99, sum(rate(apiserver_request_sli_duration_seconds_bucket{job=\"apiserver\",verb=~\"POST|PUT|PATCH|DELETE\",subresource!~\"proxy|attach|log|exec|portforward\"}[5m])) by(%s,le,resource)) > 0" $groupLabels }}
  condition: true
  labels:
    quantile: "0.99"
    verb: write
  record: cluster_quantile:apiserver_request_sli_duration_seconds:histogram_quantile
condition: {{ ($Values.kubeApiServer).enabled }}
