// Copyright (c) 2023 Volvo Car Corporation
// SPDX-License-Identifier: Apache-2.0

// Code generated by lingon. EDIT AS MUCH AS YOU LIKE.

package promstack

import (
	v1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/util/intstr"
)

var KubePromtheusStackKubeAlertmanagerRulesPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-alertmanager.rules",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "alertmanager.rules",
				Rules: []v1.Rule{
					{
						Alert: "AlertmanagerFailedReload",
						Annotations: map[string]string{
							"description": "Configuration has failed to load for {{ $labels.namespace }}/{{ $labels.pod}}.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/alertmanager/alertmanagerfailedreload",
							"summary":     "Reloading an Alertmanager configuration has failed.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
# Without max_over_time, failed scrapes could create false negatives, see
# https://www.robustperception.io/alerting-on-gauges-in-prometheus-2-0 for details.
max_over_time(alertmanager_config_last_reload_successful{job="kube-promtheus-stack-kube-alertmanager",namespace="monitoring"}[5m]) == 0
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "AlertmanagerMembersInconsistent",
						Annotations: map[string]string{
							"description": "Alertmanager {{ $labels.namespace }}/{{ $labels.pod}} has only found {{ $value }} members of the {{$labels.job}} cluster.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/alertmanager/alertmanagermembersinconsistent",
							"summary":     "A member of an Alertmanager cluster has not found all other cluster members.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
# Without max_over_time, failed scrapes could create false negatives, see
# https://www.robustperception.io/alerting-on-gauges-in-prometheus-2-0 for details.
  max_over_time(alertmanager_cluster_members{job="kube-promtheus-stack-kube-alertmanager",namespace="monitoring"}[5m])
< on (namespace,service,cluster) group_left
  count by (namespace,service,cluster) (max_over_time(alertmanager_cluster_members{job="kube-promtheus-stack-kube-alertmanager",namespace="monitoring"}[5m]))
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "AlertmanagerFailedToSendAlerts",
						Annotations: map[string]string{
							"description": "Alertmanager {{ $labels.namespace }}/{{ $labels.pod}} failed to send {{ $value | humanizePercentage }} of notifications to {{ $labels.integration }}.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/alertmanager/alertmanagerfailedtosendalerts",
							"summary":     "An Alertmanager instance failed to send notifications.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  rate(alertmanager_notifications_failed_total{job="kube-promtheus-stack-kube-alertmanager",namespace="monitoring"}[5m])
/
  rate(alertmanager_notifications_total{job="kube-promtheus-stack-kube-alertmanager",namespace="monitoring"}[5m])
)
> 0.01
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("5m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "AlertmanagerClusterFailedToSendAlerts",
						Annotations: map[string]string{
							"description": "The minimum notification failure rate to {{ $labels.integration }} sent from any instance in the {{$labels.job}} cluster is {{ $value | humanizePercentage }}.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/alertmanager/alertmanagerclusterfailedtosendalerts",
							"summary":     "All Alertmanager instances in a cluster failed to send notifications to a critical integration.",
						},
						Expr: intstr.IntOrString{
							StrVal: "min by (namespace,service, integration) (\n  rate(alertmanager_notifications_failed_total{job=\"kube-promtheus-stack-kube-alertmanager\",namespace=\"monitoring\", integration=~`.*`}[5m])\n/\n  rate(alertmanager_notifications_total{job=\"kube-promtheus-stack-kube-alertmanager\",namespace=\"monitoring\", integration=~`.*`}[5m])\n)\n> 0.01",
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("5m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "AlertmanagerClusterFailedToSendAlerts",
						Annotations: map[string]string{
							"description": "The minimum notification failure rate to {{ $labels.integration }} sent from any instance in the {{$labels.job}} cluster is {{ $value | humanizePercentage }}.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/alertmanager/alertmanagerclusterfailedtosendalerts",
							"summary":     "All Alertmanager instances in a cluster failed to send notifications to a non-critical integration.",
						},
						Expr: intstr.IntOrString{
							StrVal: "min by (namespace,service, integration) (\n  rate(alertmanager_notifications_failed_total{job=\"kube-promtheus-stack-kube-alertmanager\",namespace=\"monitoring\", integration!~`.*`}[5m])\n/\n  rate(alertmanager_notifications_total{job=\"kube-promtheus-stack-kube-alertmanager\",namespace=\"monitoring\", integration!~`.*`}[5m])\n)\n> 0.01",
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("5m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "AlertmanagerConfigInconsistent",
						Annotations: map[string]string{
							"description": "Alertmanager instances within the {{$labels.job}} cluster have different configurations.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/alertmanager/alertmanagerconfiginconsistent",
							"summary":     "Alertmanager instances within the same cluster have different configurations.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
count by (namespace,service,cluster) (
  count_values by (namespace,service,cluster) ("config_hash", alertmanager_config_hash{job="kube-promtheus-stack-kube-alertmanager",namespace="monitoring"})
)
!= 1
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("20m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "AlertmanagerClusterDown",
						Annotations: map[string]string{
							"description": "{{ $value | humanizePercentage }} of Alertmanager instances within the {{$labels.job}} cluster have been up for less than half of the last 5m.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/alertmanager/alertmanagerclusterdown",
							"summary":     "Half or more of the Alertmanager instances within the same cluster are down.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  count by (namespace,service,cluster) (
    avg_over_time(up{job="kube-promtheus-stack-kube-alertmanager",namespace="monitoring"}[5m]) < 0.5
  )
/
  count by (namespace,service,cluster) (
    up{job="kube-promtheus-stack-kube-alertmanager",namespace="monitoring"}
  )
)
>= 0.5
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("5m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "AlertmanagerClusterCrashlooping",
						Annotations: map[string]string{
							"description": "{{ $value | humanizePercentage }} of Alertmanager instances within the {{$labels.job}} cluster have restarted at least 5 times in the last 10m.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/alertmanager/alertmanagerclustercrashlooping",
							"summary":     "Half or more of the Alertmanager instances within the same cluster are crashlooping.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  count by (namespace,service,cluster) (
    changes(process_start_time_seconds{job="kube-promtheus-stack-kube-alertmanager",namespace="monitoring"}[10m]) > 4
  )
/
  count by (namespace,service,cluster) (
    up{job="kube-promtheus-stack-kube-alertmanager",namespace="monitoring"}
  )
)
>= 0.5
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("5m")),
						Labels: map[string]string{"severity": "critical"},
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeConfigReloadersPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-config-reloaders",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "config-reloaders",
				Rules: []v1.Rule{
					{
						Alert: "ConfigReloaderSidecarErrors",
						Annotations: map[string]string{
							"description": "Errors encountered while the {{$labels.pod}} config-reloader sidecar attempts to sync config in {{$labels.namespace}} namespace. As a result, configuration for service running in {{$labels.pod}} may be stale and cannot be updated anymore.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus-operator/configreloadersidecarerrors",
							"summary":     "config-reloader sidecar has not had a successful reload for 10m",
						},
						Expr: intstr.IntOrString{
							StrVal: `max_over_time(reloader_last_reload_successful{namespace=~".+"}[5m]) == 0`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "warning"},
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeEtcdPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-etcd",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "etcd",
				Rules: []v1.Rule{
					{
						Alert: "etcdMembersDown",
						Annotations: map[string]string{
							"description": `etcd cluster "{{ $labels.job }}": members are down ({{ $value }}).`,
							"summary":     "etcd cluster members are down.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
max without (endpoint) (
  sum without (instance) (up{job=~".*etcd.*"} == bool 0)
or
  count without (To) (
    sum without (instance) (rate(etcd_network_peer_sent_failures_total{job=~".*etcd.*"}[120s])) > 0.01
  )
)
> 0
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "etcdInsufficientMembers",
						Annotations: map[string]string{
							"description": `etcd cluster "{{ $labels.job }}": insufficient members ({{ $value }}).`,
							"summary":     "etcd cluster has insufficient number of members.",
						},
						Expr: intstr.IntOrString{
							StrVal: `sum(up{job=~".*etcd.*"} == bool 1) without (instance) < ((count(up{job=~".*etcd.*"}) without (instance) + 1) / 2)`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("3m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "etcdNoLeader",
						Annotations: map[string]string{
							"description": `etcd cluster "{{ $labels.job }}": member {{ $labels.instance }} has no leader.`,
							"summary":     "etcd cluster has no leader.",
						},
						Expr: intstr.IntOrString{
							StrVal: `etcd_server_has_leader{job=~".*etcd.*"} == 0`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("1m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "etcdHighNumberOfLeaderChanges",
						Annotations: map[string]string{
							"description": `etcd cluster "{{ $labels.job }}": {{ $value }} leader changes within the last 15 minutes. Frequent elections may be a sign of insufficient resources, high network latency, or disruptions by other components and should be investigated.`,
							"summary":     "etcd cluster has high number of leader changes.",
						},
						Expr: intstr.IntOrString{
							StrVal: `increase((max without (instance) (etcd_server_leader_changes_seen_total{job=~".*etcd.*"}) or 0*absent(etcd_server_leader_changes_seen_total{job=~".*etcd.*"}))[15m:1m]) >= 4`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("5m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "etcdHighNumberOfFailedGRPCRequests",
						Annotations: map[string]string{
							"description": `etcd cluster "{{ $labels.job }}": {{ $value }}% of requests for {{ $labels.grpc_method }} failed on etcd instance {{ $labels.instance }}.`,
							"summary":     "etcd cluster has high number of failed grpc requests.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
100 * sum(rate(grpc_server_handled_total{job=~".*etcd.*", grpc_code=~"Unknown|FailedPrecondition|ResourceExhausted|Internal|Unavailable|DataLoss|DeadlineExceeded"}[5m])) without (grpc_type, grpc_code)
  /
sum(rate(grpc_server_handled_total{job=~".*etcd.*"}[5m])) without (grpc_type, grpc_code)
  > 1
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "etcdHighNumberOfFailedGRPCRequests",
						Annotations: map[string]string{
							"description": `etcd cluster "{{ $labels.job }}": {{ $value }}% of requests for {{ $labels.grpc_method }} failed on etcd instance {{ $labels.instance }}.`,
							"summary":     "etcd cluster has high number of failed grpc requests.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
100 * sum(rate(grpc_server_handled_total{job=~".*etcd.*", grpc_code=~"Unknown|FailedPrecondition|ResourceExhausted|Internal|Unavailable|DataLoss|DeadlineExceeded"}[5m])) without (grpc_type, grpc_code)
  /
sum(rate(grpc_server_handled_total{job=~".*etcd.*"}[5m])) without (grpc_type, grpc_code)
  > 5
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("5m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "etcdGRPCRequestsSlow",
						Annotations: map[string]string{
							"description": `etcd cluster "{{ $labels.job }}": 99th percentile of gRPC requests is {{ $value }}s on etcd instance {{ $labels.instance }} for {{ $labels.grpc_method }} method.`,
							"summary":     "etcd grpc requests are slow",
						},
						Expr: intstr.IntOrString{
							StrVal: `
histogram_quantile(0.99, sum(rate(grpc_server_handling_seconds_bucket{job=~".*etcd.*", grpc_method!="Defragment", grpc_type="unary"}[5m])) without(grpc_type))
> 0.15
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "etcdMemberCommunicationSlow",
						Annotations: map[string]string{
							"description": `etcd cluster "{{ $labels.job }}": member communication with {{ $labels.To }} is taking {{ $value }}s on etcd instance {{ $labels.instance }}.`,
							"summary":     "etcd cluster member communication is slow.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
histogram_quantile(0.99, rate(etcd_network_peer_round_trip_time_seconds_bucket{job=~".*etcd.*"}[5m]))
> 0.15
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "etcdHighNumberOfFailedProposals",
						Annotations: map[string]string{
							"description": `etcd cluster "{{ $labels.job }}": {{ $value }} proposal failures within the last 30 minutes on etcd instance {{ $labels.instance }}.`,
							"summary":     "etcd cluster has high number of proposal failures.",
						},
						Expr: intstr.IntOrString{
							StrVal: `rate(etcd_server_proposals_failed_total{job=~".*etcd.*"}[15m]) > 5`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "etcdHighFsyncDurations",
						Annotations: map[string]string{
							"description": `etcd cluster "{{ $labels.job }}": 99th percentile fsync durations are {{ $value }}s on etcd instance {{ $labels.instance }}.`,
							"summary":     "etcd cluster 99th percentile fsync durations are too high.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
histogram_quantile(0.99, rate(etcd_disk_wal_fsync_duration_seconds_bucket{job=~".*etcd.*"}[5m]))
> 0.5
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "etcdHighFsyncDurations",
						Annotations: map[string]string{
							"description": `etcd cluster "{{ $labels.job }}": 99th percentile fsync durations are {{ $value }}s on etcd instance {{ $labels.instance }}.`,
							"summary":     "etcd cluster 99th percentile fsync durations are too high.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
histogram_quantile(0.99, rate(etcd_disk_wal_fsync_duration_seconds_bucket{job=~".*etcd.*"}[5m]))
> 1
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "etcdHighCommitDurations",
						Annotations: map[string]string{
							"description": `etcd cluster "{{ $labels.job }}": 99th percentile commit durations {{ $value }}s on etcd instance {{ $labels.instance }}.`,
							"summary":     "etcd cluster 99th percentile commit durations are too high.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
histogram_quantile(0.99, rate(etcd_disk_backend_commit_duration_seconds_bucket{job=~".*etcd.*"}[5m]))
> 0.25
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "etcdDatabaseQuotaLowSpace",
						Annotations: map[string]string{
							"description": `etcd cluster "{{ $labels.job }}": database size exceeds the defined quota on etcd instance {{ $labels.instance }}, please defrag or increase the quota as the writes to etcd will be disabled when it is full.`,
							"summary":     "etcd cluster database is running full.",
						},
						Expr: intstr.IntOrString{
							StrVal: "(last_over_time(etcd_mvcc_db_total_size_in_bytes[5m]) / last_over_time(etcd_server_quota_backend_bytes[5m]))*100 > 95",
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "etcdExcessiveDatabaseGrowth",
						Annotations: map[string]string{
							"description": `etcd cluster "{{ $labels.job }}": Predicting running out of disk space in the next four hours, based on write observations within the past four hours on etcd instance {{ $labels.instance }}, please check as it might be disruptive.`,
							"summary":     "etcd cluster database growing very fast.",
						},
						Expr: intstr.IntOrString{
							StrVal: "predict_linear(etcd_mvcc_db_total_size_in_bytes[4h], 4*60*60) > etcd_server_quota_backend_bytes",
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "etcdDatabaseHighFragmentationRatio",
						Annotations: map[string]string{
							"description": `etcd cluster "{{ $labels.job }}": database size in use on instance {{ $labels.instance }} is {{ $value | humanizePercentage }} of the actual allocated disk space, please run defragmentation (e.g. etcdctl defrag) to retrieve the unused fragmented disk space.`,
							"runbook_url": "https://etcd.io/docs/v3.5/op-guide/maintenance/#defragmentation",
							"summary":     "etcd database size in use is less than 50% of the actual allocated storage.",
						},
						Expr: intstr.IntOrString{
							StrVal: "(last_over_time(etcd_mvcc_db_total_size_in_use_in_bytes[5m]) / last_over_time(etcd_mvcc_db_total_size_in_bytes[5m])) < 0.5 and etcd_mvcc_db_total_size_in_use_in_bytes > 104857600",
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "warning"},
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeGeneralRulesPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-general.rules",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "general.rules",
				Rules: []v1.Rule{
					{
						Alert: "TargetDown",
						Annotations: map[string]string{
							"description": `{{ printf "%.4g" $value }}% of the {{ $labels.job }}/{{ $labels.service }} targets in {{ $labels.namespace }} namespace are down.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/general/targetdown",
							"summary":     "One or more targets are unreachable.",
						},
						Expr: intstr.IntOrString{
							StrVal: "100 * (count(up == 0) BY (cluster, job, namespace, service) / count(up) BY (cluster, job, namespace, service)) > 10",
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "Watchdog",
						Annotations: map[string]string{
							"description": `This is an alert meant to ensure that the entire alerting pipeline is functional. This alert is always firing, therefore it should always be firing in Alertmanager and always fire against a receiver. There are integrations with various notification mechanisms that send a notification when this alert is not firing. For example the "DeadMansSnitch" integration in PagerDuty. `,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/general/watchdog",
							"summary":     "An alert that should always be firing to certify that Alertmanager is working properly.",
						},
						Expr: intstr.IntOrString{
							StrVal: "vector(1)",
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"severity": "none"},
					}, {
						Alert: "InfoInhibitor",
						Annotations: map[string]string{
							"description": `This is an alert that is used to inhibit info alerts. By themselves, the info-level alerts are sometimes very noisy, but they are relevant when combined with other alerts. This alert fires whenever there's a severity="info" alert, and stops firing when another alert with a severity of 'warning' or 'critical' starts firing on the same namespace. This alert should be routed to a null receiver and configured to inhibit alerts with severity="info". `,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/general/infoinhibitor",
							"summary":     "Info-level alert inhibition.",
						},
						Expr: intstr.IntOrString{
							StrVal: `ALERTS{severity = "info"} == 1 unless on(namespace) ALERTS{alertname != "InfoInhibitor", severity =~ "warning|critical", alertstate="firing"} == 1`,
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"severity": "none"},
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeK8SRulesPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-k8s.rules",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "k8s.rules",
				Rules: []v1.Rule{
					{
						Expr: intstr.IntOrString{
							StrVal: `
sum by (cluster, namespace, pod, container) (
  irate(container_cpu_usage_seconds_total{job="kubelet", metrics_path="/metrics/cadvisor", image!=""}[5m])
) * on (cluster, namespace, pod) group_left(node) topk by (cluster, namespace, pod) (
  1, max by(cluster, namespace, pod, node) (kube_pod_info{node!=""})
)
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
container_memory_working_set_bytes{job="kubelet", metrics_path="/metrics/cadvisor", image!=""}
* on (cluster, namespace, pod) group_left(node) topk by(cluster, namespace, pod) (1,
  max by(cluster, namespace, pod, node) (kube_pod_info{node!=""})
)
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "node_namespace_pod_container:container_memory_working_set_bytes",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
container_memory_rss{job="kubelet", metrics_path="/metrics/cadvisor", image!=""}
* on (cluster, namespace, pod) group_left(node) topk by(cluster, namespace, pod) (1,
  max by(cluster, namespace, pod, node) (kube_pod_info{node!=""})
)
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "node_namespace_pod_container:container_memory_rss",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
container_memory_cache{job="kubelet", metrics_path="/metrics/cadvisor", image!=""}
* on (cluster, namespace, pod) group_left(node) topk by(cluster, namespace, pod) (1,
  max by(cluster, namespace, pod, node) (kube_pod_info{node!=""})
)
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "node_namespace_pod_container:container_memory_cache",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
container_memory_swap{job="kubelet", metrics_path="/metrics/cadvisor", image!=""}
* on (cluster, namespace, pod) group_left(node) topk by(cluster, namespace, pod) (1,
  max by(cluster, namespace, pod, node) (kube_pod_info{node!=""})
)
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "node_namespace_pod_container:container_memory_swap",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
kube_pod_container_resource_requests{resource="memory",job="kube-state-metrics"}  * on (namespace, pod, cluster)
group_left() max by (namespace, pod, cluster) (
  (kube_pod_status_phase{phase=~"Pending|Running"} == 1)
)
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "cluster:namespace:pod_memory:active:kube_pod_container_resource_requests",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
sum by (namespace, cluster) (
    sum by (namespace, pod, cluster) (
        max by (namespace, pod, container, cluster) (
          kube_pod_container_resource_requests{resource="memory",job="kube-state-metrics"}
        ) * on(namespace, pod, cluster) group_left() max by (namespace, pod, cluster) (
          kube_pod_status_phase{phase=~"Pending|Running"} == 1
        )
    )
)
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "namespace_memory:kube_pod_container_resource_requests:sum",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
kube_pod_container_resource_requests{resource="cpu",job="kube-state-metrics"}  * on (namespace, pod, cluster)
group_left() max by (namespace, pod, cluster) (
  (kube_pod_status_phase{phase=~"Pending|Running"} == 1)
)
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "cluster:namespace:pod_cpu:active:kube_pod_container_resource_requests",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
sum by (namespace, cluster) (
    sum by (namespace, pod, cluster) (
        max by (namespace, pod, container, cluster) (
          kube_pod_container_resource_requests{resource="cpu",job="kube-state-metrics"}
        ) * on(namespace, pod, cluster) group_left() max by (namespace, pod, cluster) (
          kube_pod_status_phase{phase=~"Pending|Running"} == 1
        )
    )
)
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "namespace_cpu:kube_pod_container_resource_requests:sum",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
kube_pod_container_resource_limits{resource="memory",job="kube-state-metrics"}  * on (namespace, pod, cluster)
group_left() max by (namespace, pod, cluster) (
  (kube_pod_status_phase{phase=~"Pending|Running"} == 1)
)
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "cluster:namespace:pod_memory:active:kube_pod_container_resource_limits",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
sum by (namespace, cluster) (
    sum by (namespace, pod, cluster) (
        max by (namespace, pod, container, cluster) (
          kube_pod_container_resource_limits{resource="memory",job="kube-state-metrics"}
        ) * on(namespace, pod, cluster) group_left() max by (namespace, pod, cluster) (
          kube_pod_status_phase{phase=~"Pending|Running"} == 1
        )
    )
)
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "namespace_memory:kube_pod_container_resource_limits:sum",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
kube_pod_container_resource_limits{resource="cpu",job="kube-state-metrics"}  * on (namespace, pod, cluster)
group_left() max by (namespace, pod, cluster) (
 (kube_pod_status_phase{phase=~"Pending|Running"} == 1)
 )
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "cluster:namespace:pod_cpu:active:kube_pod_container_resource_limits",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
sum by (namespace, cluster) (
    sum by (namespace, pod, cluster) (
        max by (namespace, pod, container, cluster) (
          kube_pod_container_resource_limits{resource="cpu",job="kube-state-metrics"}
        ) * on(namespace, pod, cluster) group_left() max by (namespace, pod, cluster) (
          kube_pod_status_phase{phase=~"Pending|Running"} == 1
        )
    )
)
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "namespace_cpu:kube_pod_container_resource_limits:sum",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
max by (cluster, namespace, workload, pod) (
  label_replace(
    label_replace(
      kube_pod_owner{job="kube-state-metrics", owner_kind="ReplicaSet"},
      "replicaset", "$1", "owner_name", "(.*)"
    ) * on(replicaset, namespace) group_left(owner_name) topk by(replicaset, namespace) (
      1, max by (replicaset, namespace, owner_name) (
        kube_replicaset_owner{job="kube-state-metrics"}
      )
    ),
    "workload", "$1", "owner_name", "(.*)"
  )
)
`,
							Type: intstr.Type(int64(1)),
						},
						Labels: map[string]string{"workload_type": "deployment"},
						Record: "namespace_workload_pod:kube_pod_owner:relabel",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
max by (cluster, namespace, workload, pod) (
  label_replace(
    kube_pod_owner{job="kube-state-metrics", owner_kind="DaemonSet"},
    "workload", "$1", "owner_name", "(.*)"
  )
)
`,
							Type: intstr.Type(int64(1)),
						},
						Labels: map[string]string{"workload_type": "daemonset"},
						Record: "namespace_workload_pod:kube_pod_owner:relabel",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
max by (cluster, namespace, workload, pod) (
  label_replace(
    kube_pod_owner{job="kube-state-metrics", owner_kind="StatefulSet"},
    "workload", "$1", "owner_name", "(.*)"
  )
)
`,
							Type: intstr.Type(int64(1)),
						},
						Labels: map[string]string{"workload_type": "statefulset"},
						Record: "namespace_workload_pod:kube_pod_owner:relabel",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
max by (cluster, namespace, workload, pod) (
  label_replace(
    kube_pod_owner{job="kube-state-metrics", owner_kind="Job"},
    "workload", "$1", "owner_name", "(.*)"
  )
)
`,
							Type: intstr.Type(int64(1)),
						},
						Labels: map[string]string{"workload_type": "job"},
						Record: "namespace_workload_pod:kube_pod_owner:relabel",
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeKubeApiserverAvailabilityRulesPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-kube-apiserver-availability.rules",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Interval: P(v1.Duration("3m")),
				Name:     "kube-apiserver-availability.rules",
				Rules: []v1.Rule{
					{
						Expr: intstr.IntOrString{
							StrVal: "avg_over_time(code_verb:apiserver_request_total:increase1h[30d]) * 24 * 30",
							Type:   intstr.Type(int64(1)),
						},
						Record: "code_verb:apiserver_request_total:increase30d",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `sum by (cluster, code) (code_verb:apiserver_request_total:increase30d{verb=~"LIST|GET"})`,
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"verb": "read"},
						Record: "code:apiserver_request_total:increase30d",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `sum by (cluster, code) (code_verb:apiserver_request_total:increase30d{verb=~"POST|PUT|PATCH|DELETE"})`,
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"verb": "write"},
						Record: "code:apiserver_request_total:increase30d",
					}, {
						Expr: intstr.IntOrString{
							StrVal: "sum by (cluster, verb, scope) (increase(apiserver_request_slo_duration_seconds_count[1h]))",
							Type:   intstr.Type(int64(1)),
						},
						Record: "cluster_verb_scope:apiserver_request_slo_duration_seconds_count:increase1h",
					}, {
						Expr: intstr.IntOrString{
							StrVal: "sum by (cluster, verb, scope) (avg_over_time(cluster_verb_scope:apiserver_request_slo_duration_seconds_count:increase1h[30d]) * 24 * 30)",
							Type:   intstr.Type(int64(1)),
						},
						Record: "cluster_verb_scope:apiserver_request_slo_duration_seconds_count:increase30d",
					}, {
						Expr: intstr.IntOrString{
							StrVal: "sum by (cluster, verb, scope, le) (increase(apiserver_request_slo_duration_seconds_bucket[1h]))",
							Type:   intstr.Type(int64(1)),
						},
						Record: "cluster_verb_scope_le:apiserver_request_slo_duration_seconds_bucket:increase1h",
					}, {
						Expr: intstr.IntOrString{
							StrVal: "sum by (cluster, verb, scope, le) (avg_over_time(cluster_verb_scope_le:apiserver_request_slo_duration_seconds_bucket:increase1h[30d]) * 24 * 30)",
							Type:   intstr.Type(int64(1)),
						},
						Record: "cluster_verb_scope_le:apiserver_request_slo_duration_seconds_bucket:increase30d",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
1 - (
  (
    # write too slow
    sum by (cluster) (cluster_verb_scope:apiserver_request_slo_duration_seconds_count:increase30d{verb=~"POST|PUT|PATCH|DELETE"})
    -
    sum by (cluster) (cluster_verb_scope_le:apiserver_request_slo_duration_seconds_bucket:increase30d{verb=~"POST|PUT|PATCH|DELETE",le="1"})
  ) +
  (
    # read too slow
    sum by (cluster) (cluster_verb_scope:apiserver_request_slo_duration_seconds_count:increase30d{verb=~"LIST|GET"})
    -
    (
      (
        sum by (cluster) (cluster_verb_scope_le:apiserver_request_slo_duration_seconds_bucket:increase30d{verb=~"LIST|GET",scope=~"resource|",le="1"})
        or
        vector(0)
      )
      +
      sum by (cluster) (cluster_verb_scope_le:apiserver_request_slo_duration_seconds_bucket:increase30d{verb=~"LIST|GET",scope="namespace",le="5"})
      +
      sum by (cluster) (cluster_verb_scope_le:apiserver_request_slo_duration_seconds_bucket:increase30d{verb=~"LIST|GET",scope="cluster",le="30"})
    )
  ) +
  # errors
  sum by (cluster) (code:apiserver_request_total:increase30d{code=~"5.."} or vector(0))
)
/
sum by (cluster) (code:apiserver_request_total:increase30d)
`,
							Type: intstr.Type(int64(1)),
						},
						Labels: map[string]string{"verb": "all"},
						Record: "apiserver_request:availability30d",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
1 - (
  sum by (cluster) (cluster_verb_scope:apiserver_request_slo_duration_seconds_count:increase30d{verb=~"LIST|GET"})
  -
  (
    # too slow
    (
      sum by (cluster) (cluster_verb_scope_le:apiserver_request_slo_duration_seconds_bucket:increase30d{verb=~"LIST|GET",scope=~"resource|",le="1"})
      or
      vector(0)
    )
    +
    sum by (cluster) (cluster_verb_scope_le:apiserver_request_slo_duration_seconds_bucket:increase30d{verb=~"LIST|GET",scope="namespace",le="5"})
    +
    sum by (cluster) (cluster_verb_scope_le:apiserver_request_slo_duration_seconds_bucket:increase30d{verb=~"LIST|GET",scope="cluster",le="30"})
  )
  +
  # errors
  sum by (cluster) (code:apiserver_request_total:increase30d{verb="read",code=~"5.."} or vector(0))
)
/
sum by (cluster) (code:apiserver_request_total:increase30d{verb="read"})
`,
							Type: intstr.Type(int64(1)),
						},
						Labels: map[string]string{"verb": "read"},
						Record: "apiserver_request:availability30d",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
1 - (
  (
    # too slow
    sum by (cluster) (cluster_verb_scope:apiserver_request_slo_duration_seconds_count:increase30d{verb=~"POST|PUT|PATCH|DELETE"})
    -
    sum by (cluster) (cluster_verb_scope_le:apiserver_request_slo_duration_seconds_bucket:increase30d{verb=~"POST|PUT|PATCH|DELETE",le="1"})
  )
  +
  # errors
  sum by (cluster) (code:apiserver_request_total:increase30d{verb="write",code=~"5.."} or vector(0))
)
/
sum by (cluster) (code:apiserver_request_total:increase30d{verb="write"})
`,
							Type: intstr.Type(int64(1)),
						},
						Labels: map[string]string{"verb": "write"},
						Record: "apiserver_request:availability30d",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `sum by (cluster,code,resource) (rate(apiserver_request_total{job="apiserver",verb=~"LIST|GET"}[5m]))`,
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"verb": "read"},
						Record: "code_resource:apiserver_request_total:rate5m",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `sum by (cluster,code,resource) (rate(apiserver_request_total{job="apiserver",verb=~"POST|PUT|PATCH|DELETE"}[5m]))`,
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"verb": "write"},
						Record: "code_resource:apiserver_request_total:rate5m",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `sum by (cluster, code, verb) (increase(apiserver_request_total{job="apiserver",verb=~"LIST|GET|POST|PUT|PATCH|DELETE",code=~"2.."}[1h]))`,
							Type:   intstr.Type(int64(1)),
						},
						Record: "code_verb:apiserver_request_total:increase1h",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `sum by (cluster, code, verb) (increase(apiserver_request_total{job="apiserver",verb=~"LIST|GET|POST|PUT|PATCH|DELETE",code=~"3.."}[1h]))`,
							Type:   intstr.Type(int64(1)),
						},
						Record: "code_verb:apiserver_request_total:increase1h",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `sum by (cluster, code, verb) (increase(apiserver_request_total{job="apiserver",verb=~"LIST|GET|POST|PUT|PATCH|DELETE",code=~"4.."}[1h]))`,
							Type:   intstr.Type(int64(1)),
						},
						Record: "code_verb:apiserver_request_total:increase1h",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `sum by (cluster, code, verb) (increase(apiserver_request_total{job="apiserver",verb=~"LIST|GET|POST|PUT|PATCH|DELETE",code=~"5.."}[1h]))`,
							Type:   intstr.Type(int64(1)),
						},
						Record: "code_verb:apiserver_request_total:increase1h",
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeKubeApiserverBurnrateRulesPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-kube-apiserver-burnrate.rules",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "kube-apiserver-burnrate.rules",
				Rules: []v1.Rule{
					{
						Expr: intstr.IntOrString{
							StrVal: `
(
  (
    # too slow
    sum by (cluster) (rate(apiserver_request_slo_duration_seconds_count{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward"}[1d]))
    -
    (
      (
        sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward",scope=~"resource|",le="1"}[1d]))
        or
        vector(0)
      )
      +
      sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward",scope="namespace",le="5"}[1d]))
      +
      sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward",scope="cluster",le="30"}[1d]))
    )
  )
  +
  # errors
  sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"LIST|GET",code=~"5.."}[1d]))
)
/
sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"LIST|GET"}[1d]))
`,
							Type: intstr.Type(int64(1)),
						},
						Labels: map[string]string{"verb": "read"},
						Record: "apiserver_request:burnrate1d",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
(
  (
    # too slow
    sum by (cluster) (rate(apiserver_request_slo_duration_seconds_count{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward"}[1h]))
    -
    (
      (
        sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward",scope=~"resource|",le="1"}[1h]))
        or
        vector(0)
      )
      +
      sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward",scope="namespace",le="5"}[1h]))
      +
      sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward",scope="cluster",le="30"}[1h]))
    )
  )
  +
  # errors
  sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"LIST|GET",code=~"5.."}[1h]))
)
/
sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"LIST|GET"}[1h]))
`,
							Type: intstr.Type(int64(1)),
						},
						Labels: map[string]string{"verb": "read"},
						Record: "apiserver_request:burnrate1h",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
(
  (
    # too slow
    sum by (cluster) (rate(apiserver_request_slo_duration_seconds_count{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward"}[2h]))
    -
    (
      (
        sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward",scope=~"resource|",le="1"}[2h]))
        or
        vector(0)
      )
      +
      sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward",scope="namespace",le="5"}[2h]))
      +
      sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward",scope="cluster",le="30"}[2h]))
    )
  )
  +
  # errors
  sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"LIST|GET",code=~"5.."}[2h]))
)
/
sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"LIST|GET"}[2h]))
`,
							Type: intstr.Type(int64(1)),
						},
						Labels: map[string]string{"verb": "read"},
						Record: "apiserver_request:burnrate2h",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
(
  (
    # too slow
    sum by (cluster) (rate(apiserver_request_slo_duration_seconds_count{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward"}[30m]))
    -
    (
      (
        sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward",scope=~"resource|",le="1"}[30m]))
        or
        vector(0)
      )
      +
      sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward",scope="namespace",le="5"}[30m]))
      +
      sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward",scope="cluster",le="30"}[30m]))
    )
  )
  +
  # errors
  sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"LIST|GET",code=~"5.."}[30m]))
)
/
sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"LIST|GET"}[30m]))
`,
							Type: intstr.Type(int64(1)),
						},
						Labels: map[string]string{"verb": "read"},
						Record: "apiserver_request:burnrate30m",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
(
  (
    # too slow
    sum by (cluster) (rate(apiserver_request_slo_duration_seconds_count{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward"}[3d]))
    -
    (
      (
        sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward",scope=~"resource|",le="1"}[3d]))
        or
        vector(0)
      )
      +
      sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward",scope="namespace",le="5"}[3d]))
      +
      sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward",scope="cluster",le="30"}[3d]))
    )
  )
  +
  # errors
  sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"LIST|GET",code=~"5.."}[3d]))
)
/
sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"LIST|GET"}[3d]))
`,
							Type: intstr.Type(int64(1)),
						},
						Labels: map[string]string{"verb": "read"},
						Record: "apiserver_request:burnrate3d",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
(
  (
    # too slow
    sum by (cluster) (rate(apiserver_request_slo_duration_seconds_count{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward"}[5m]))
    -
    (
      (
        sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward",scope=~"resource|",le="1"}[5m]))
        or
        vector(0)
      )
      +
      sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward",scope="namespace",le="5"}[5m]))
      +
      sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward",scope="cluster",le="30"}[5m]))
    )
  )
  +
  # errors
  sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"LIST|GET",code=~"5.."}[5m]))
)
/
sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"LIST|GET"}[5m]))
`,
							Type: intstr.Type(int64(1)),
						},
						Labels: map[string]string{"verb": "read"},
						Record: "apiserver_request:burnrate5m",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
(
  (
    # too slow
    sum by (cluster) (rate(apiserver_request_slo_duration_seconds_count{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward"}[6h]))
    -
    (
      (
        sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward",scope=~"resource|",le="1"}[6h]))
        or
        vector(0)
      )
      +
      sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward",scope="namespace",le="5"}[6h]))
      +
      sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward",scope="cluster",le="30"}[6h]))
    )
  )
  +
  # errors
  sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"LIST|GET",code=~"5.."}[6h]))
)
/
sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"LIST|GET"}[6h]))
`,
							Type: intstr.Type(int64(1)),
						},
						Labels: map[string]string{"verb": "read"},
						Record: "apiserver_request:burnrate6h",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
(
  (
    # too slow
    sum by (cluster) (rate(apiserver_request_slo_duration_seconds_count{job="apiserver",verb=~"POST|PUT|PATCH|DELETE",subresource!~"proxy|attach|log|exec|portforward"}[1d]))
    -
    sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"POST|PUT|PATCH|DELETE",subresource!~"proxy|attach|log|exec|portforward",le="1"}[1d]))
  )
  +
  sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"POST|PUT|PATCH|DELETE",code=~"5.."}[1d]))
)
/
sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"POST|PUT|PATCH|DELETE"}[1d]))
`,
							Type: intstr.Type(int64(1)),
						},
						Labels: map[string]string{"verb": "write"},
						Record: "apiserver_request:burnrate1d",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
(
  (
    # too slow
    sum by (cluster) (rate(apiserver_request_slo_duration_seconds_count{job="apiserver",verb=~"POST|PUT|PATCH|DELETE",subresource!~"proxy|attach|log|exec|portforward"}[1h]))
    -
    sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"POST|PUT|PATCH|DELETE",subresource!~"proxy|attach|log|exec|portforward",le="1"}[1h]))
  )
  +
  sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"POST|PUT|PATCH|DELETE",code=~"5.."}[1h]))
)
/
sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"POST|PUT|PATCH|DELETE"}[1h]))
`,
							Type: intstr.Type(int64(1)),
						},
						Labels: map[string]string{"verb": "write"},
						Record: "apiserver_request:burnrate1h",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
(
  (
    # too slow
    sum by (cluster) (rate(apiserver_request_slo_duration_seconds_count{job="apiserver",verb=~"POST|PUT|PATCH|DELETE",subresource!~"proxy|attach|log|exec|portforward"}[2h]))
    -
    sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"POST|PUT|PATCH|DELETE",subresource!~"proxy|attach|log|exec|portforward",le="1"}[2h]))
  )
  +
  sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"POST|PUT|PATCH|DELETE",code=~"5.."}[2h]))
)
/
sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"POST|PUT|PATCH|DELETE"}[2h]))
`,
							Type: intstr.Type(int64(1)),
						},
						Labels: map[string]string{"verb": "write"},
						Record: "apiserver_request:burnrate2h",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
(
  (
    # too slow
    sum by (cluster) (rate(apiserver_request_slo_duration_seconds_count{job="apiserver",verb=~"POST|PUT|PATCH|DELETE",subresource!~"proxy|attach|log|exec|portforward"}[30m]))
    -
    sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"POST|PUT|PATCH|DELETE",subresource!~"proxy|attach|log|exec|portforward",le="1"}[30m]))
  )
  +
  sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"POST|PUT|PATCH|DELETE",code=~"5.."}[30m]))
)
/
sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"POST|PUT|PATCH|DELETE"}[30m]))
`,
							Type: intstr.Type(int64(1)),
						},
						Labels: map[string]string{"verb": "write"},
						Record: "apiserver_request:burnrate30m",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
(
  (
    # too slow
    sum by (cluster) (rate(apiserver_request_slo_duration_seconds_count{job="apiserver",verb=~"POST|PUT|PATCH|DELETE",subresource!~"proxy|attach|log|exec|portforward"}[3d]))
    -
    sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"POST|PUT|PATCH|DELETE",subresource!~"proxy|attach|log|exec|portforward",le="1"}[3d]))
  )
  +
  sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"POST|PUT|PATCH|DELETE",code=~"5.."}[3d]))
)
/
sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"POST|PUT|PATCH|DELETE"}[3d]))
`,
							Type: intstr.Type(int64(1)),
						},
						Labels: map[string]string{"verb": "write"},
						Record: "apiserver_request:burnrate3d",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
(
  (
    # too slow
    sum by (cluster) (rate(apiserver_request_slo_duration_seconds_count{job="apiserver",verb=~"POST|PUT|PATCH|DELETE",subresource!~"proxy|attach|log|exec|portforward"}[5m]))
    -
    sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"POST|PUT|PATCH|DELETE",subresource!~"proxy|attach|log|exec|portforward",le="1"}[5m]))
  )
  +
  sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"POST|PUT|PATCH|DELETE",code=~"5.."}[5m]))
)
/
sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"POST|PUT|PATCH|DELETE"}[5m]))
`,
							Type: intstr.Type(int64(1)),
						},
						Labels: map[string]string{"verb": "write"},
						Record: "apiserver_request:burnrate5m",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
(
  (
    # too slow
    sum by (cluster) (rate(apiserver_request_slo_duration_seconds_count{job="apiserver",verb=~"POST|PUT|PATCH|DELETE",subresource!~"proxy|attach|log|exec|portforward"}[6h]))
    -
    sum by (cluster) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"POST|PUT|PATCH|DELETE",subresource!~"proxy|attach|log|exec|portforward",le="1"}[6h]))
  )
  +
  sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"POST|PUT|PATCH|DELETE",code=~"5.."}[6h]))
)
/
sum by (cluster) (rate(apiserver_request_total{job="apiserver",verb=~"POST|PUT|PATCH|DELETE"}[6h]))
`,
							Type: intstr.Type(int64(1)),
						},
						Labels: map[string]string{"verb": "write"},
						Record: "apiserver_request:burnrate6h",
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeKubeApiserverHistogramRulesPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-kube-apiserver-histogram.rules",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "kube-apiserver-histogram.rules",
				Rules: []v1.Rule{
					{
						Expr: intstr.IntOrString{
							StrVal: `histogram_quantile(0.99, sum by (cluster, le, resource) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"LIST|GET",subresource!~"proxy|attach|log|exec|portforward"}[5m]))) > 0`,
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{
							"quantile": "0.99",
							"verb":     "read",
						},
						Record: "cluster_quantile:apiserver_request_slo_duration_seconds:histogram_quantile",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `histogram_quantile(0.99, sum by (cluster, le, resource) (rate(apiserver_request_slo_duration_seconds_bucket{job="apiserver",verb=~"POST|PUT|PATCH|DELETE",subresource!~"proxy|attach|log|exec|portforward"}[5m]))) > 0`,
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{
							"quantile": "0.99",
							"verb":     "write",
						},
						Record: "cluster_quantile:apiserver_request_slo_duration_seconds:histogram_quantile",
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeKubeApiserverSlosPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-kube-apiserver-slos",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "kube-apiserver-slos",
				Rules: []v1.Rule{
					{
						Alert: "KubeAPIErrorBudgetBurn",
						Annotations: map[string]string{
							"description": "The API server is burning too much error budget.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubeapierrorbudgetburn",
							"summary":     "The API server is burning too much error budget.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
sum(apiserver_request:burnrate1h) > (14.40 * 0.01000)
and
sum(apiserver_request:burnrate5m) > (14.40 * 0.01000)
`,
							Type: intstr.Type(int64(1)),
						},
						For: P(v1.Duration("2m")),
						Labels: map[string]string{
							"long":     "1h",
							"severity": "critical",
							"short":    "5m",
						},
					}, {
						Alert: "KubeAPIErrorBudgetBurn",
						Annotations: map[string]string{
							"description": "The API server is burning too much error budget.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubeapierrorbudgetburn",
							"summary":     "The API server is burning too much error budget.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
sum(apiserver_request:burnrate6h) > (6.00 * 0.01000)
and
sum(apiserver_request:burnrate30m) > (6.00 * 0.01000)
`,
							Type: intstr.Type(int64(1)),
						},
						For: P(v1.Duration("15m")),
						Labels: map[string]string{
							"long":     "6h",
							"severity": "critical",
							"short":    "30m",
						},
					}, {
						Alert: "KubeAPIErrorBudgetBurn",
						Annotations: map[string]string{
							"description": "The API server is burning too much error budget.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubeapierrorbudgetburn",
							"summary":     "The API server is burning too much error budget.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
sum(apiserver_request:burnrate1d) > (3.00 * 0.01000)
and
sum(apiserver_request:burnrate2h) > (3.00 * 0.01000)
`,
							Type: intstr.Type(int64(1)),
						},
						For: P(v1.Duration("1h")),
						Labels: map[string]string{
							"long":     "1d",
							"severity": "warning",
							"short":    "2h",
						},
					}, {
						Alert: "KubeAPIErrorBudgetBurn",
						Annotations: map[string]string{
							"description": "The API server is burning too much error budget.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubeapierrorbudgetburn",
							"summary":     "The API server is burning too much error budget.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
sum(apiserver_request:burnrate3d) > (1.00 * 0.01000)
and
sum(apiserver_request:burnrate6h) > (1.00 * 0.01000)
`,
							Type: intstr.Type(int64(1)),
						},
						For: P(v1.Duration("3h")),
						Labels: map[string]string{
							"long":     "3d",
							"severity": "warning",
							"short":    "6h",
						},
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeKubePrometheusGeneralRulesPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-kube-prometheus-general.rules",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "kube-prometheus-general.rules",
				Rules: []v1.Rule{
					{
						Expr: intstr.IntOrString{
							StrVal: "count without(instance, pod, node) (up == 1)",
							Type:   intstr.Type(int64(1)),
						},
						Record: "count:up1",
					}, {
						Expr: intstr.IntOrString{
							StrVal: "count without(instance, pod, node) (up == 0)",
							Type:   intstr.Type(int64(1)),
						},
						Record: "count:up0",
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeKubePrometheusNodeRecordingRulesPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-kube-prometheus-node-recording.rules",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "kube-prometheus-node-recording.rules",
				Rules: []v1.Rule{
					{
						Expr: intstr.IntOrString{
							StrVal: `sum(rate(node_cpu_seconds_total{mode!="idle",mode!="iowait",mode!="steal"}[3m])) BY (instance)`,
							Type:   intstr.Type(int64(1)),
						},
						Record: "instance:node_cpu:rate:sum",
					}, {
						Expr: intstr.IntOrString{
							StrVal: "sum(rate(node_network_receive_bytes_total[3m])) BY (instance)",
							Type:   intstr.Type(int64(1)),
						},
						Record: "instance:node_network_receive_bytes:rate:sum",
					}, {
						Expr: intstr.IntOrString{
							StrVal: "sum(rate(node_network_transmit_bytes_total[3m])) BY (instance)",
							Type:   intstr.Type(int64(1)),
						},
						Record: "instance:node_network_transmit_bytes:rate:sum",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `sum(rate(node_cpu_seconds_total{mode!="idle",mode!="iowait",mode!="steal"}[5m])) WITHOUT (cpu, mode) / ON(instance) GROUP_LEFT() count(sum(node_cpu_seconds_total) BY (instance, cpu)) BY (instance)`,
							Type:   intstr.Type(int64(1)),
						},
						Record: "instance:node_cpu:ratio",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `sum(rate(node_cpu_seconds_total{mode!="idle",mode!="iowait",mode!="steal"}[5m]))`,
							Type:   intstr.Type(int64(1)),
						},
						Record: "cluster:node_cpu:sum_rate5m",
					}, {
						Expr: intstr.IntOrString{
							StrVal: "cluster:node_cpu:sum_rate5m / count(sum(node_cpu_seconds_total) BY (instance, cpu))",
							Type:   intstr.Type(int64(1)),
						},
						Record: "cluster:node_cpu:ratio",
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeKubeSchedulerRulesPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-kube-scheduler.rules",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "kube-scheduler.rules",
				Rules: []v1.Rule{
					{
						Expr: intstr.IntOrString{
							StrVal: `histogram_quantile(0.99, sum(rate(scheduler_e2e_scheduling_duration_seconds_bucket{job="kube-scheduler"}[5m])) without(instance, pod))`,
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"quantile": "0.99"},
						Record: "cluster_quantile:scheduler_e2e_scheduling_duration_seconds:histogram_quantile",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `histogram_quantile(0.99, sum(rate(scheduler_scheduling_algorithm_duration_seconds_bucket{job="kube-scheduler"}[5m])) without(instance, pod))`,
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"quantile": "0.99"},
						Record: "cluster_quantile:scheduler_scheduling_algorithm_duration_seconds:histogram_quantile",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `histogram_quantile(0.99, sum(rate(scheduler_binding_duration_seconds_bucket{job="kube-scheduler"}[5m])) without(instance, pod))`,
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"quantile": "0.99"},
						Record: "cluster_quantile:scheduler_binding_duration_seconds:histogram_quantile",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `histogram_quantile(0.9, sum(rate(scheduler_e2e_scheduling_duration_seconds_bucket{job="kube-scheduler"}[5m])) without(instance, pod))`,
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"quantile": "0.9"},
						Record: "cluster_quantile:scheduler_e2e_scheduling_duration_seconds:histogram_quantile",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `histogram_quantile(0.9, sum(rate(scheduler_scheduling_algorithm_duration_seconds_bucket{job="kube-scheduler"}[5m])) without(instance, pod))`,
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"quantile": "0.9"},
						Record: "cluster_quantile:scheduler_scheduling_algorithm_duration_seconds:histogram_quantile",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `histogram_quantile(0.9, sum(rate(scheduler_binding_duration_seconds_bucket{job="kube-scheduler"}[5m])) without(instance, pod))`,
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"quantile": "0.9"},
						Record: "cluster_quantile:scheduler_binding_duration_seconds:histogram_quantile",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `histogram_quantile(0.5, sum(rate(scheduler_e2e_scheduling_duration_seconds_bucket{job="kube-scheduler"}[5m])) without(instance, pod))`,
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"quantile": "0.5"},
						Record: "cluster_quantile:scheduler_e2e_scheduling_duration_seconds:histogram_quantile",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `histogram_quantile(0.5, sum(rate(scheduler_scheduling_algorithm_duration_seconds_bucket{job="kube-scheduler"}[5m])) without(instance, pod))`,
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"quantile": "0.5"},
						Record: "cluster_quantile:scheduler_scheduling_algorithm_duration_seconds:histogram_quantile",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `histogram_quantile(0.5, sum(rate(scheduler_binding_duration_seconds_bucket{job="kube-scheduler"}[5m])) without(instance, pod))`,
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"quantile": "0.5"},
						Record: "cluster_quantile:scheduler_binding_duration_seconds:histogram_quantile",
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeKubeStateMetricsPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-kube-state-metrics",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "kube-state-metrics",
				Rules: []v1.Rule{
					{
						Alert: "KubeStateMetricsListErrors",
						Annotations: map[string]string{
							"description": "kube-state-metrics is experiencing errors at an elevated rate in list operations. This is likely causing it to not be able to expose metrics about Kubernetes objects correctly or at all.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kube-state-metrics/kubestatemetricslisterrors",
							"summary":     "kube-state-metrics is experiencing errors in list operations.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(sum(rate(kube_state_metrics_list_total{job="kube-state-metrics",result="error"}[5m])) by (cluster)
  /
sum(rate(kube_state_metrics_list_total{job="kube-state-metrics"}[5m])) by (cluster))
> 0.01
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "KubeStateMetricsWatchErrors",
						Annotations: map[string]string{
							"description": "kube-state-metrics is experiencing errors at an elevated rate in watch operations. This is likely causing it to not be able to expose metrics about Kubernetes objects correctly or at all.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kube-state-metrics/kubestatemetricswatcherrors",
							"summary":     "kube-state-metrics is experiencing errors in watch operations.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(sum(rate(kube_state_metrics_watch_total{job="kube-state-metrics",result="error"}[5m])) by (cluster)
  /
sum(rate(kube_state_metrics_watch_total{job="kube-state-metrics"}[5m])) by (cluster))
> 0.01
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "KubeStateMetricsShardingMismatch",
						Annotations: map[string]string{
							"description": "kube-state-metrics pods are running with different --total-shards configuration, some Kubernetes objects may be exposed multiple times or not exposed at all.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kube-state-metrics/kubestatemetricsshardingmismatch",
							"summary":     "kube-state-metrics sharding is misconfigured.",
						},
						Expr: intstr.IntOrString{
							StrVal: `stdvar (kube_state_metrics_total_shards{job="kube-state-metrics"}) by (cluster) != 0`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "KubeStateMetricsShardsMissing",
						Annotations: map[string]string{
							"description": "kube-state-metrics shards are missing, some Kubernetes objects are not being exposed.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kube-state-metrics/kubestatemetricsshardsmissing",
							"summary":     "kube-state-metrics shards are missing.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
2^max(kube_state_metrics_total_shards{job="kube-state-metrics"}) by (cluster) - 1
  -
sum( 2 ^ max by (cluster, shard_ordinal) (kube_state_metrics_shard_ordinal{job="kube-state-metrics"}) ) by (cluster)
!= 0
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "critical"},
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeKubeletRulesPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-kubelet.rules",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "kubelet.rules",
				Rules: []v1.Rule{
					{
						Expr: intstr.IntOrString{
							StrVal: `histogram_quantile(0.99, sum(rate(kubelet_pleg_relist_duration_seconds_bucket{job="kubelet", metrics_path="/metrics"}[5m])) by (cluster, instance, le) * on(cluster, instance) group_left(node) kubelet_node_name{job="kubelet", metrics_path="/metrics"})`,
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"quantile": "0.99"},
						Record: "node_quantile:kubelet_pleg_relist_duration_seconds:histogram_quantile",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `histogram_quantile(0.9, sum(rate(kubelet_pleg_relist_duration_seconds_bucket{job="kubelet", metrics_path="/metrics"}[5m])) by (cluster, instance, le) * on(cluster, instance) group_left(node) kubelet_node_name{job="kubelet", metrics_path="/metrics"})`,
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"quantile": "0.9"},
						Record: "node_quantile:kubelet_pleg_relist_duration_seconds:histogram_quantile",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `histogram_quantile(0.5, sum(rate(kubelet_pleg_relist_duration_seconds_bucket{job="kubelet", metrics_path="/metrics"}[5m])) by (cluster, instance, le) * on(cluster, instance) group_left(node) kubelet_node_name{job="kubelet", metrics_path="/metrics"})`,
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"quantile": "0.5"},
						Record: "node_quantile:kubelet_pleg_relist_duration_seconds:histogram_quantile",
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeKubernetesAppsPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-kubernetes-apps",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "kubernetes-apps",
				Rules: []v1.Rule{
					{
						Alert: "KubePodCrashLooping",
						Annotations: map[string]string{
							"description": `Pod {{ $labels.namespace }}/{{ $labels.pod }} ({{ $labels.container }}) is in waiting state (reason: "CrashLoopBackOff").`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubepodcrashlooping",
							"summary":     "Pod is crash looping.",
						},
						Expr: intstr.IntOrString{
							StrVal: `max_over_time(kube_pod_container_status_waiting_reason{reason="CrashLoopBackOff", job="kube-state-metrics", namespace=~".*"}[5m]) >= 1`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubePodNotReady",
						Annotations: map[string]string{
							"description": "Pod {{ $labels.namespace }}/{{ $labels.pod }} has been in a non-ready state for longer than 15 minutes.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubepodnotready",
							"summary":     "Pod has been in a non-ready state for more than 15 minutes.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
sum by (namespace, pod, cluster) (
  max by(namespace, pod, cluster) (
    kube_pod_status_phase{job="kube-state-metrics", namespace=~".*", phase=~"Pending|Unknown|Failed"}
  ) * on(namespace, pod, cluster) group_left(owner_kind) topk by(namespace, pod, cluster) (
    1, max by(namespace, pod, owner_kind, cluster) (kube_pod_owner{owner_kind!="Job"})
  )
) > 0
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeDeploymentGenerationMismatch",
						Annotations: map[string]string{
							"description": "Deployment generation for {{ $labels.namespace }}/{{ $labels.deployment }} does not match, this indicates that the Deployment has failed but has not been rolled back.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubedeploymentgenerationmismatch",
							"summary":     "Deployment generation mismatch due to possible roll-back",
						},
						Expr: intstr.IntOrString{
							StrVal: `
kube_deployment_status_observed_generation{job="kube-state-metrics", namespace=~".*"}
  !=
kube_deployment_metadata_generation{job="kube-state-metrics", namespace=~".*"}
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeDeploymentReplicasMismatch",
						Annotations: map[string]string{
							"description": "Deployment {{ $labels.namespace }}/{{ $labels.deployment }} has not matched the expected number of replicas for longer than 15 minutes.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubedeploymentreplicasmismatch",
							"summary":     "Deployment has not matched the expected number of replicas.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  kube_deployment_spec_replicas{job="kube-state-metrics", namespace=~".*"}
    >
  kube_deployment_status_replicas_available{job="kube-state-metrics", namespace=~".*"}
) and (
  changes(kube_deployment_status_replicas_updated{job="kube-state-metrics", namespace=~".*"}[10m])
    ==
  0
)
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeStatefulSetReplicasMismatch",
						Annotations: map[string]string{
							"description": "StatefulSet {{ $labels.namespace }}/{{ $labels.statefulset }} has not matched the expected number of replicas for longer than 15 minutes.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubestatefulsetreplicasmismatch",
							"summary":     "Deployment has not matched the expected number of replicas.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  kube_statefulset_status_replicas_ready{job="kube-state-metrics", namespace=~".*"}
    !=
  kube_statefulset_status_replicas{job="kube-state-metrics", namespace=~".*"}
) and (
  changes(kube_statefulset_status_replicas_updated{job="kube-state-metrics", namespace=~".*"}[10m])
    ==
  0
)
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeStatefulSetGenerationMismatch",
						Annotations: map[string]string{
							"description": "StatefulSet generation for {{ $labels.namespace }}/{{ $labels.statefulset }} does not match, this indicates that the StatefulSet has failed but has not been rolled back.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubestatefulsetgenerationmismatch",
							"summary":     "StatefulSet generation mismatch due to possible roll-back",
						},
						Expr: intstr.IntOrString{
							StrVal: `
kube_statefulset_status_observed_generation{job="kube-state-metrics", namespace=~".*"}
  !=
kube_statefulset_metadata_generation{job="kube-state-metrics", namespace=~".*"}
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeStatefulSetUpdateNotRolledOut",
						Annotations: map[string]string{
							"description": "StatefulSet {{ $labels.namespace }}/{{ $labels.statefulset }} update has not been rolled out.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubestatefulsetupdatenotrolledout",
							"summary":     "StatefulSet update has not been rolled out.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  max without (revision) (
    kube_statefulset_status_current_revision{job="kube-state-metrics", namespace=~".*"}
      unless
    kube_statefulset_status_update_revision{job="kube-state-metrics", namespace=~".*"}
  )
    *
  (
    kube_statefulset_replicas{job="kube-state-metrics", namespace=~".*"}
      !=
    kube_statefulset_status_replicas_updated{job="kube-state-metrics", namespace=~".*"}
  )
)  and (
  changes(kube_statefulset_status_replicas_updated{job="kube-state-metrics", namespace=~".*"}[5m])
    ==
  0
)
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeDaemonSetRolloutStuck",
						Annotations: map[string]string{
							"description": "DaemonSet {{ $labels.namespace }}/{{ $labels.daemonset }} has not finished or progressed for at least 15 minutes.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubedaemonsetrolloutstuck",
							"summary":     "DaemonSet rollout is stuck.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  (
    kube_daemonset_status_current_number_scheduled{job="kube-state-metrics", namespace=~".*"}
     !=
    kube_daemonset_status_desired_number_scheduled{job="kube-state-metrics", namespace=~".*"}
  ) or (
    kube_daemonset_status_number_misscheduled{job="kube-state-metrics", namespace=~".*"}
     !=
    0
  ) or (
    kube_daemonset_status_updated_number_scheduled{job="kube-state-metrics", namespace=~".*"}
     !=
    kube_daemonset_status_desired_number_scheduled{job="kube-state-metrics", namespace=~".*"}
  ) or (
    kube_daemonset_status_number_available{job="kube-state-metrics", namespace=~".*"}
     !=
    kube_daemonset_status_desired_number_scheduled{job="kube-state-metrics", namespace=~".*"}
  )
) and (
  changes(kube_daemonset_status_updated_number_scheduled{job="kube-state-metrics", namespace=~".*"}[5m])
    ==
  0
)
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeContainerWaiting",
						Annotations: map[string]string{
							"description": "pod/{{ $labels.pod }} in namespace {{ $labels.namespace }} on container {{ $labels.container}} has been in waiting state for longer than 1 hour.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubecontainerwaiting",
							"summary":     "Pod container waiting longer than 1 hour",
						},
						Expr: intstr.IntOrString{
							StrVal: `sum by (namespace, pod, container, cluster) (kube_pod_container_status_waiting_reason{job="kube-state-metrics", namespace=~".*"}) > 0`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("1h")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeDaemonSetNotScheduled",
						Annotations: map[string]string{
							"description": "{{ $value }} Pods of DaemonSet {{ $labels.namespace }}/{{ $labels.daemonset }} are not scheduled.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubedaemonsetnotscheduled",
							"summary":     "DaemonSet pods are not scheduled.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
kube_daemonset_status_desired_number_scheduled{job="kube-state-metrics", namespace=~".*"}
  -
kube_daemonset_status_current_number_scheduled{job="kube-state-metrics", namespace=~".*"} > 0
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeDaemonSetMisScheduled",
						Annotations: map[string]string{
							"description": "{{ $value }} Pods of DaemonSet {{ $labels.namespace }}/{{ $labels.daemonset }} are running where they are not supposed to run.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubedaemonsetmisscheduled",
							"summary":     "DaemonSet pods are misscheduled.",
						},
						Expr: intstr.IntOrString{
							StrVal: `kube_daemonset_status_number_misscheduled{job="kube-state-metrics", namespace=~".*"} > 0`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeJobNotCompleted",
						Annotations: map[string]string{
							"description": `Job {{ $labels.namespace }}/{{ $labels.job_name }} is taking more than {{ "43200" | humanizeDuration }} to complete.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubejobnotcompleted",
							"summary":     "Job did not complete in time",
						},
						Expr: intstr.IntOrString{
							StrVal: `
time() - max by(namespace, job_name, cluster) (kube_job_status_start_time{job="kube-state-metrics", namespace=~".*"}
  and
kube_job_status_active{job="kube-state-metrics", namespace=~".*"} > 0) > 43200
`,
							Type: intstr.Type(int64(1)),
						},
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeJobFailed",
						Annotations: map[string]string{
							"description": "Job {{ $labels.namespace }}/{{ $labels.job_name }} failed to complete. Removing failed job after investigation should clear this alert.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubejobfailed",
							"summary":     "Job failed to complete.",
						},
						Expr: intstr.IntOrString{
							StrVal: `kube_job_failed{job="kube-state-metrics", namespace=~".*"}  > 0`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeHpaReplicasMismatch",
						Annotations: map[string]string{
							"description": "HPA {{ $labels.namespace }}/{{ $labels.horizontalpodautoscaler  }} has not matched the desired number of replicas for longer than 15 minutes.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubehpareplicasmismatch",
							"summary":     "HPA has not matched desired number of replicas.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(kube_horizontalpodautoscaler_status_desired_replicas{job="kube-state-metrics", namespace=~".*"}
  !=
kube_horizontalpodautoscaler_status_current_replicas{job="kube-state-metrics", namespace=~".*"})
  and
(kube_horizontalpodautoscaler_status_current_replicas{job="kube-state-metrics", namespace=~".*"}
  >
kube_horizontalpodautoscaler_spec_min_replicas{job="kube-state-metrics", namespace=~".*"})
  and
(kube_horizontalpodautoscaler_status_current_replicas{job="kube-state-metrics", namespace=~".*"}
  <
kube_horizontalpodautoscaler_spec_max_replicas{job="kube-state-metrics", namespace=~".*"})
  and
changes(kube_horizontalpodautoscaler_status_current_replicas{job="kube-state-metrics", namespace=~".*"}[15m]) == 0
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeHpaMaxedOut",
						Annotations: map[string]string{
							"description": "HPA {{ $labels.namespace }}/{{ $labels.horizontalpodautoscaler  }} has been running at max replicas for longer than 15 minutes.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubehpamaxedout",
							"summary":     "HPA is running at max replicas",
						},
						Expr: intstr.IntOrString{
							StrVal: `
kube_horizontalpodautoscaler_status_current_replicas{job="kube-state-metrics", namespace=~".*"}
  ==
kube_horizontalpodautoscaler_spec_max_replicas{job="kube-state-metrics", namespace=~".*"}
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeKubernetesResourcesPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-kubernetes-resources",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "kubernetes-resources",
				Rules: []v1.Rule{
					{
						Alert: "KubeCPUOvercommit",
						Annotations: map[string]string{
							"description": "Cluster {{ $labels.cluster }} has overcommitted CPU resource requests for Pods by {{ $value }} CPU shares and cannot tolerate node failure.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubecpuovercommit",
							"summary":     "Cluster has overcommitted CPU resource requests.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
sum(namespace_cpu:kube_pod_container_resource_requests:sum{job="kube-state-metrics",}) by (cluster) - (sum(kube_node_status_allocatable{job="kube-state-metrics",resource="cpu"}) by (cluster) - max(kube_node_status_allocatable{job="kube-state-metrics",resource="cpu"}) by (cluster)) > 0
and
(sum(kube_node_status_allocatable{job="kube-state-metrics",resource="cpu"}) by (cluster) - max(kube_node_status_allocatable{job="kube-state-metrics",resource="cpu"}) by (cluster)) > 0
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeMemoryOvercommit",
						Annotations: map[string]string{
							"description": "Cluster {{ $labels.cluster }} has overcommitted memory resource requests for Pods by {{ $value | humanize }} bytes and cannot tolerate node failure.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubememoryovercommit",
							"summary":     "Cluster has overcommitted memory resource requests.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
sum(namespace_memory:kube_pod_container_resource_requests:sum{}) by (cluster) - (sum(kube_node_status_allocatable{resource="memory", job="kube-state-metrics"}) by (cluster) - max(kube_node_status_allocatable{resource="memory", job="kube-state-metrics"}) by (cluster)) > 0
and
(sum(kube_node_status_allocatable{resource="memory", job="kube-state-metrics"}) by (cluster) - max(kube_node_status_allocatable{resource="memory", job="kube-state-metrics"}) by (cluster)) > 0
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeCPUQuotaOvercommit",
						Annotations: map[string]string{
							"description": "Cluster {{ $labels.cluster }}  has overcommitted CPU resource requests for Namespaces.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubecpuquotaovercommit",
							"summary":     "Cluster has overcommitted CPU resource requests.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
sum(min without(resource) (kube_resourcequota{job="kube-state-metrics", type="hard", resource=~"(cpu|requests.cpu)"})) by (cluster)
  /
sum(kube_node_status_allocatable{resource="cpu", job="kube-state-metrics"}) by (cluster)
  > 1.5
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("5m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeMemoryQuotaOvercommit",
						Annotations: map[string]string{
							"description": "Cluster {{ $labels.cluster }}  has overcommitted memory resource requests for Namespaces.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubememoryquotaovercommit",
							"summary":     "Cluster has overcommitted memory resource requests.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
sum(min without(resource) (kube_resourcequota{job="kube-state-metrics", type="hard", resource=~"(memory|requests.memory)"})) by (cluster)
  /
sum(kube_node_status_allocatable{resource="memory", job="kube-state-metrics"}) by (cluster)
  > 1.5
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("5m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeQuotaAlmostFull",
						Annotations: map[string]string{
							"description": "Namespace {{ $labels.namespace }} is using {{ $value | humanizePercentage }} of its {{ $labels.resource }} quota.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubequotaalmostfull",
							"summary":     "Namespace quota is going to be full.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
kube_resourcequota{job="kube-state-metrics", type="used"}
  / ignoring(instance, job, type)
(kube_resourcequota{job="kube-state-metrics", type="hard"} > 0)
  > 0.9 < 1
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "info"},
					}, {
						Alert: "KubeQuotaFullyUsed",
						Annotations: map[string]string{
							"description": "Namespace {{ $labels.namespace }} is using {{ $value | humanizePercentage }} of its {{ $labels.resource }} quota.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubequotafullyused",
							"summary":     "Namespace quota is fully used.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
kube_resourcequota{job="kube-state-metrics", type="used"}
  / ignoring(instance, job, type)
(kube_resourcequota{job="kube-state-metrics", type="hard"} > 0)
  == 1
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "info"},
					}, {
						Alert: "KubeQuotaExceeded",
						Annotations: map[string]string{
							"description": "Namespace {{ $labels.namespace }} is using {{ $value | humanizePercentage }} of its {{ $labels.resource }} quota.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubequotaexceeded",
							"summary":     "Namespace quota has exceeded the limits.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
kube_resourcequota{job="kube-state-metrics", type="used"}
  / ignoring(instance, job, type)
(kube_resourcequota{job="kube-state-metrics", type="hard"} > 0)
  > 1
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "CPUThrottlingHigh",
						Annotations: map[string]string{
							"description": "{{ $value | humanizePercentage }} throttling of CPU in namespace {{ $labels.namespace }} for container {{ $labels.container }} in pod {{ $labels.pod }}.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/cputhrottlinghigh",
							"summary":     "Processes experience elevated CPU throttling.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
sum(increase(container_cpu_cfs_throttled_periods_total{container!="", }[5m])) by (container, pod, namespace)
  /
sum(increase(container_cpu_cfs_periods_total{}[5m])) by (container, pod, namespace)
  > ( 25 / 100 )
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "info"},
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeKubernetesStoragePrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-kubernetes-storage",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "kubernetes-storage",
				Rules: []v1.Rule{
					{
						Alert: "KubePersistentVolumeFillingUp",
						Annotations: map[string]string{
							"description": "The PersistentVolume claimed by {{ $labels.persistentvolumeclaim }} in Namespace {{ $labels.namespace }} is only {{ $value | humanizePercentage }} free.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubepersistentvolumefillingup",
							"summary":     "PersistentVolume is filling up.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  kubelet_volume_stats_available_bytes{job="kubelet", namespace=~".*", metrics_path="/metrics"}
    /
  kubelet_volume_stats_capacity_bytes{job="kubelet", namespace=~".*", metrics_path="/metrics"}
) < 0.03
and
kubelet_volume_stats_used_bytes{job="kubelet", namespace=~".*", metrics_path="/metrics"} > 0
unless on(namespace, persistentvolumeclaim)
kube_persistentvolumeclaim_access_mode{ access_mode="ReadOnlyMany"} == 1
unless on(namespace, persistentvolumeclaim)
kube_persistentvolumeclaim_labels{label_excluded_from_alerts="true"} == 1
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("1m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "KubePersistentVolumeFillingUp",
						Annotations: map[string]string{
							"description": "Based on recent sampling, the PersistentVolume claimed by {{ $labels.persistentvolumeclaim }} in Namespace {{ $labels.namespace }} is expected to fill up within four days. Currently {{ $value | humanizePercentage }} is available.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubepersistentvolumefillingup",
							"summary":     "PersistentVolume is filling up.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  kubelet_volume_stats_available_bytes{job="kubelet", namespace=~".*", metrics_path="/metrics"}
    /
  kubelet_volume_stats_capacity_bytes{job="kubelet", namespace=~".*", metrics_path="/metrics"}
) < 0.15
and
kubelet_volume_stats_used_bytes{job="kubelet", namespace=~".*", metrics_path="/metrics"} > 0
and
predict_linear(kubelet_volume_stats_available_bytes{job="kubelet", namespace=~".*", metrics_path="/metrics"}[6h], 4 * 24 * 3600) < 0
unless on(namespace, persistentvolumeclaim)
kube_persistentvolumeclaim_access_mode{ access_mode="ReadOnlyMany"} == 1
unless on(namespace, persistentvolumeclaim)
kube_persistentvolumeclaim_labels{label_excluded_from_alerts="true"} == 1
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("1h")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubePersistentVolumeInodesFillingUp",
						Annotations: map[string]string{
							"description": "The PersistentVolume claimed by {{ $labels.persistentvolumeclaim }} in Namespace {{ $labels.namespace }} only has {{ $value | humanizePercentage }} free inodes.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubepersistentvolumeinodesfillingup",
							"summary":     "PersistentVolumeInodes are filling up.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  kubelet_volume_stats_inodes_free{job="kubelet", namespace=~".*", metrics_path="/metrics"}
    /
  kubelet_volume_stats_inodes{job="kubelet", namespace=~".*", metrics_path="/metrics"}
) < 0.03
and
kubelet_volume_stats_inodes_used{job="kubelet", namespace=~".*", metrics_path="/metrics"} > 0
unless on(namespace, persistentvolumeclaim)
kube_persistentvolumeclaim_access_mode{ access_mode="ReadOnlyMany"} == 1
unless on(namespace, persistentvolumeclaim)
kube_persistentvolumeclaim_labels{label_excluded_from_alerts="true"} == 1
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("1m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "KubePersistentVolumeInodesFillingUp",
						Annotations: map[string]string{
							"description": "Based on recent sampling, the PersistentVolume claimed by {{ $labels.persistentvolumeclaim }} in Namespace {{ $labels.namespace }} is expected to run out of inodes within four days. Currently {{ $value | humanizePercentage }} of its inodes are free.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubepersistentvolumeinodesfillingup",
							"summary":     "PersistentVolumeInodes are filling up.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  kubelet_volume_stats_inodes_free{job="kubelet", namespace=~".*", metrics_path="/metrics"}
    /
  kubelet_volume_stats_inodes{job="kubelet", namespace=~".*", metrics_path="/metrics"}
) < 0.15
and
kubelet_volume_stats_inodes_used{job="kubelet", namespace=~".*", metrics_path="/metrics"} > 0
and
predict_linear(kubelet_volume_stats_inodes_free{job="kubelet", namespace=~".*", metrics_path="/metrics"}[6h], 4 * 24 * 3600) < 0
unless on(namespace, persistentvolumeclaim)
kube_persistentvolumeclaim_access_mode{ access_mode="ReadOnlyMany"} == 1
unless on(namespace, persistentvolumeclaim)
kube_persistentvolumeclaim_labels{label_excluded_from_alerts="true"} == 1
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("1h")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubePersistentVolumeErrors",
						Annotations: map[string]string{
							"description": "The persistent volume {{ $labels.persistentvolume }} has status {{ $labels.phase }}.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubepersistentvolumeerrors",
							"summary":     "PersistentVolume is having issues with provisioning.",
						},
						Expr: intstr.IntOrString{
							StrVal: `kube_persistentvolume_status_phase{phase=~"Failed|Pending",job="kube-state-metrics"} > 0`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("5m")),
						Labels: map[string]string{"severity": "critical"},
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeKubernetesSystemApiserverPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-kubernetes-system-apiserver",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "kubernetes-system-apiserver",
				Rules: []v1.Rule{
					{
						Alert: "KubeClientCertificateExpiration",
						Annotations: map[string]string{
							"description": "A client certificate used to authenticate to kubernetes apiserver is expiring in less than 7.0 days.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubeclientcertificateexpiration",
							"summary":     "Client certificate is about to expire.",
						},
						Expr: intstr.IntOrString{
							StrVal: `apiserver_client_certificate_expiration_seconds_count{job="apiserver"} > 0 and on(job) histogram_quantile(0.01, sum by (job, le) (rate(apiserver_client_certificate_expiration_seconds_bucket{job="apiserver"}[5m]))) < 604800`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("5m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeClientCertificateExpiration",
						Annotations: map[string]string{
							"description": "A client certificate used to authenticate to kubernetes apiserver is expiring in less than 24.0 hours.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubeclientcertificateexpiration",
							"summary":     "Client certificate is about to expire.",
						},
						Expr: intstr.IntOrString{
							StrVal: `apiserver_client_certificate_expiration_seconds_count{job="apiserver"} > 0 and on(job) histogram_quantile(0.01, sum by (job, le) (rate(apiserver_client_certificate_expiration_seconds_bucket{job="apiserver"}[5m]))) < 86400`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("5m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "KubeAggregatedAPIErrors",
						Annotations: map[string]string{
							"description": "Kubernetes aggregated API {{ $labels.name }}/{{ $labels.namespace }} has reported errors. It has appeared unavailable {{ $value | humanize }} times averaged over the past 10m.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubeaggregatedapierrors",
							"summary":     "Kubernetes aggregated API has reported errors.",
						},
						Expr: intstr.IntOrString{
							StrVal: "sum by(name, namespace, cluster)(increase(aggregator_unavailable_apiservice_total[10m])) > 4",
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeAggregatedAPIDown",
						Annotations: map[string]string{
							"description": "Kubernetes aggregated API {{ $labels.name }}/{{ $labels.namespace }} has been only {{ $value | humanize }}% available over the last 10m.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubeaggregatedapidown",
							"summary":     "Kubernetes aggregated API is down.",
						},
						Expr: intstr.IntOrString{
							StrVal: "(1 - max by(name, namespace, cluster)(avg_over_time(aggregator_unavailable_apiservice[10m]))) * 100 < 85",
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("5m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeAPIDown",
						Annotations: map[string]string{
							"description": "KubeAPI has disappeared from Prometheus target discovery.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubeapidown",
							"summary":     "Target disappeared from Prometheus target discovery.",
						},
						Expr: intstr.IntOrString{
							StrVal: `absent(up{job="apiserver"} == 1)`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "KubeAPITerminatedRequests",
						Annotations: map[string]string{
							"description": "The kubernetes apiserver has terminated {{ $value | humanizePercentage }} of its incoming requests.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubeapiterminatedrequests",
							"summary":     "The kubernetes apiserver has terminated {{ $value | humanizePercentage }} of its incoming requests.",
						},
						Expr: intstr.IntOrString{
							StrVal: `sum(rate(apiserver_request_terminations_total{job="apiserver"}[10m]))  / (  sum(rate(apiserver_request_total{job="apiserver"}[10m])) + sum(rate(apiserver_request_terminations_total{job="apiserver"}[10m])) ) > 0.20`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("5m")),
						Labels: map[string]string{"severity": "warning"},
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeKubernetesSystemControllerManagerPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-kubernetes-system-controller-manager",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "kubernetes-system-controller-manager",
				Rules: []v1.Rule{
					{
						Alert: "KubeControllerManagerDown",
						Annotations: map[string]string{
							"description": "KubeControllerManager has disappeared from Prometheus target discovery.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubecontrollermanagerdown",
							"summary":     "Target disappeared from Prometheus target discovery.",
						},
						Expr: intstr.IntOrString{
							StrVal: `absent(up{job="kube-controller-manager"} == 1)`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "critical"},
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeKubernetesSystemKubeProxyPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-kubernetes-system-kube-proxy",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "kubernetes-system-kube-proxy",
				Rules: []v1.Rule{
					{
						Alert: "KubeProxyDown",
						Annotations: map[string]string{
							"description": "KubeProxy has disappeared from Prometheus target discovery.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubeproxydown",
							"summary":     "Target disappeared from Prometheus target discovery.",
						},
						Expr: intstr.IntOrString{
							StrVal: `absent(up{job="kube-proxy"} == 1)`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "critical"},
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeKubernetesSystemKubeletPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-kubernetes-system-kubelet",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "kubernetes-system-kubelet",
				Rules: []v1.Rule{
					{
						Alert: "KubeNodeNotReady",
						Annotations: map[string]string{
							"description": "{{ $labels.node }} has been unready for more than 15 minutes.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubenodenotready",
							"summary":     "Node is not ready.",
						},
						Expr: intstr.IntOrString{
							StrVal: `kube_node_status_condition{job="kube-state-metrics",condition="Ready",status="true"} == 0`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeNodeUnreachable",
						Annotations: map[string]string{
							"description": "{{ $labels.node }} is unreachable and some workloads may be rescheduled.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubenodeunreachable",
							"summary":     "Node is unreachable.",
						},
						Expr: intstr.IntOrString{
							StrVal: `(kube_node_spec_taint{job="kube-state-metrics",key="node.kubernetes.io/unreachable",effect="NoSchedule"} unless ignoring(key,value) kube_node_spec_taint{job="kube-state-metrics",key=~"ToBeDeletedByClusterAutoscaler|cloud.google.com/impending-node-termination|aws-node-termination-handler/spot-itn"}) == 1`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeletTooManyPods",
						Annotations: map[string]string{
							"description": "Kubelet '{{ $labels.node }}' is running at {{ $value | humanizePercentage }} of its Pod capacity.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubelettoomanypods",
							"summary":     "Kubelet is running at capacity.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
count by(cluster, node) (
  (kube_pod_status_phase{job="kube-state-metrics",phase="Running"} == 1) * on(instance,pod,namespace,cluster) group_left(node) topk by(instance,pod,namespace,cluster) (1, kube_pod_info{job="kube-state-metrics"})
)
/
max by(cluster, node) (
  kube_node_status_capacity{job="kube-state-metrics",resource="pods"} != 1
) > 0.95
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "info"},
					}, {
						Alert: "KubeNodeReadinessFlapping",
						Annotations: map[string]string{
							"description": "The readiness status of node {{ $labels.node }} has changed {{ $value }} times in the last 15 minutes.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubenodereadinessflapping",
							"summary":     "Node readiness status is flapping.",
						},
						Expr: intstr.IntOrString{
							StrVal: `sum(changes(kube_node_status_condition{job="kube-state-metrics",status="true",condition="Ready"}[15m])) by (cluster, node) > 2`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeletPlegDurationHigh",
						Annotations: map[string]string{
							"description": "The Kubelet Pod Lifecycle Event Generator has a 99th percentile duration of {{ $value }} seconds on node {{ $labels.node }}.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubeletplegdurationhigh",
							"summary":     "Kubelet Pod Lifecycle Event Generator is taking too long to relist.",
						},
						Expr: intstr.IntOrString{
							StrVal: `node_quantile:kubelet_pleg_relist_duration_seconds:histogram_quantile{quantile="0.99"} >= 10`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("5m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeletPodStartUpLatencyHigh",
						Annotations: map[string]string{
							"description": "Kubelet Pod startup 99th percentile latency is {{ $value }} seconds on node {{ $labels.node }}.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubeletpodstartuplatencyhigh",
							"summary":     "Kubelet Pod startup latency is too high.",
						},
						Expr: intstr.IntOrString{
							StrVal: `histogram_quantile(0.99, sum(rate(kubelet_pod_worker_duration_seconds_bucket{job="kubelet", metrics_path="/metrics"}[5m])) by (cluster, instance, le)) * on(cluster, instance) group_left(node) kubelet_node_name{job="kubelet", metrics_path="/metrics"} > 60`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeletClientCertificateExpiration",
						Annotations: map[string]string{
							"description": "Client certificate for Kubelet on node {{ $labels.node }} expires in {{ $value | humanizeDuration }}.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubeletclientcertificateexpiration",
							"summary":     "Kubelet client certificate is about to expire.",
						},
						Expr: intstr.IntOrString{
							StrVal: "kubelet_certificate_manager_client_ttl_seconds < 604800",
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeletClientCertificateExpiration",
						Annotations: map[string]string{
							"description": "Client certificate for Kubelet on node {{ $labels.node }} expires in {{ $value | humanizeDuration }}.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubeletclientcertificateexpiration",
							"summary":     "Kubelet client certificate is about to expire.",
						},
						Expr: intstr.IntOrString{
							StrVal: "kubelet_certificate_manager_client_ttl_seconds < 86400",
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "KubeletServerCertificateExpiration",
						Annotations: map[string]string{
							"description": "Server certificate for Kubelet on node {{ $labels.node }} expires in {{ $value | humanizeDuration }}.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubeletservercertificateexpiration",
							"summary":     "Kubelet server certificate is about to expire.",
						},
						Expr: intstr.IntOrString{
							StrVal: "kubelet_certificate_manager_server_ttl_seconds < 604800",
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeletServerCertificateExpiration",
						Annotations: map[string]string{
							"description": "Server certificate for Kubelet on node {{ $labels.node }} expires in {{ $value | humanizeDuration }}.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubeletservercertificateexpiration",
							"summary":     "Kubelet server certificate is about to expire.",
						},
						Expr: intstr.IntOrString{
							StrVal: "kubelet_certificate_manager_server_ttl_seconds < 86400",
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "KubeletClientCertificateRenewalErrors",
						Annotations: map[string]string{
							"description": "Kubelet on node {{ $labels.node }} has failed to renew its client certificate ({{ $value | humanize }} errors in the last 5 minutes).",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubeletclientcertificaterenewalerrors",
							"summary":     "Kubelet has failed to renew its client certificate.",
						},
						Expr: intstr.IntOrString{
							StrVal: "increase(kubelet_certificate_manager_client_expiration_renew_errors[5m]) > 0",
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeletServerCertificateRenewalErrors",
						Annotations: map[string]string{
							"description": "Kubelet on node {{ $labels.node }} has failed to renew its server certificate ({{ $value | humanize }} errors in the last 5 minutes).",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubeletservercertificaterenewalerrors",
							"summary":     "Kubelet has failed to renew its server certificate.",
						},
						Expr: intstr.IntOrString{
							StrVal: "increase(kubelet_server_expiration_renew_errors[5m]) > 0",
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeletDown",
						Annotations: map[string]string{
							"description": "Kubelet has disappeared from Prometheus target discovery.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubeletdown",
							"summary":     "Target disappeared from Prometheus target discovery.",
						},
						Expr: intstr.IntOrString{
							StrVal: `absent(up{job="kubelet", metrics_path="/metrics"} == 1)`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "critical"},
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeKubernetesSystemPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-kubernetes-system",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "kubernetes-system",
				Rules: []v1.Rule{
					{
						Alert: "KubeVersionMismatch",
						Annotations: map[string]string{
							"description": "There are {{ $value }} different semantic versions of Kubernetes components running.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubeversionmismatch",
							"summary":     "Different semantic versions of Kubernetes components running.",
						},
						Expr: intstr.IntOrString{
							StrVal: `count by (cluster) (count by (git_version, cluster) (label_replace(kubernetes_build_info{job!~"kube-dns|coredns"},"git_version","$1","git_version","(v[0-9]*.[0-9]*).*"))) > 1`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "KubeClientErrors",
						Annotations: map[string]string{
							"description": "Kubernetes API server client '{{ $labels.job }}/{{ $labels.instance }}' is experiencing {{ $value | humanizePercentage }} errors.'",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubeclienterrors",
							"summary":     "Kubernetes API server client is experiencing errors.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(sum(rate(rest_client_requests_total{job="apiserver",code=~"5.."}[5m])) by (cluster, instance, job, namespace)
  /
sum(rate(rest_client_requests_total{job="apiserver"}[5m])) by (cluster, instance, job, namespace))
> 0.01
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeKubernetesSystemSchedulerPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-kubernetes-system-scheduler",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "kubernetes-system-scheduler",
				Rules: []v1.Rule{
					{
						Alert: "KubeSchedulerDown",
						Annotations: map[string]string{
							"description": "KubeScheduler has disappeared from Prometheus target discovery.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/kubernetes/kubeschedulerdown",
							"summary":     "Target disappeared from Prometheus target discovery.",
						},
						Expr: intstr.IntOrString{
							StrVal: `absent(up{job="kube-scheduler"} == 1)`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "critical"},
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeNodeExporterPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-node-exporter",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "node-exporter",
				Rules: []v1.Rule{
					{
						Alert: "NodeFilesystemSpaceFillingUp",
						Annotations: map[string]string{
							"description": `Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available space left and is filling up.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/node/nodefilesystemspacefillingup",
							"summary":     "Filesystem is predicted to run out of space within the next 24 hours.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  node_filesystem_avail_bytes{job="node-exporter",fstype!="",mountpoint!=""} / node_filesystem_size_bytes{job="node-exporter",fstype!="",mountpoint!=""} * 100 < 15
and
  predict_linear(node_filesystem_avail_bytes{job="node-exporter",fstype!="",mountpoint!=""}[6h], 24*60*60) < 0
and
  node_filesystem_readonly{job="node-exporter",fstype!="",mountpoint!=""} == 0
)
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("1h")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "NodeFilesystemSpaceFillingUp",
						Annotations: map[string]string{
							"description": `Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available space left and is filling up fast.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/node/nodefilesystemspacefillingup",
							"summary":     "Filesystem is predicted to run out of space within the next 4 hours.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  node_filesystem_avail_bytes{job="node-exporter",fstype!="",mountpoint!=""} / node_filesystem_size_bytes{job="node-exporter",fstype!="",mountpoint!=""} * 100 < 10
and
  predict_linear(node_filesystem_avail_bytes{job="node-exporter",fstype!="",mountpoint!=""}[6h], 4*60*60) < 0
and
  node_filesystem_readonly{job="node-exporter",fstype!="",mountpoint!=""} == 0
)
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("1h")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "NodeFilesystemAlmostOutOfSpace",
						Annotations: map[string]string{
							"description": `Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available space left.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/node/nodefilesystemalmostoutofspace",
							"summary":     "Filesystem has less than 5% space left.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  node_filesystem_avail_bytes{job="node-exporter",fstype!="",mountpoint!=""} / node_filesystem_size_bytes{job="node-exporter",fstype!="",mountpoint!=""} * 100 < 5
and
  node_filesystem_readonly{job="node-exporter",fstype!="",mountpoint!=""} == 0
)
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("30m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "NodeFilesystemAlmostOutOfSpace",
						Annotations: map[string]string{
							"description": `Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available space left.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/node/nodefilesystemalmostoutofspace",
							"summary":     "Filesystem has less than 3% space left.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  node_filesystem_avail_bytes{job="node-exporter",fstype!="",mountpoint!=""} / node_filesystem_size_bytes{job="node-exporter",fstype!="",mountpoint!=""} * 100 < 3
and
  node_filesystem_readonly{job="node-exporter",fstype!="",mountpoint!=""} == 0
)
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("30m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "NodeFilesystemFilesFillingUp",
						Annotations: map[string]string{
							"description": `Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available inodes left and is filling up.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/node/nodefilesystemfilesfillingup",
							"summary":     "Filesystem is predicted to run out of inodes within the next 24 hours.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  node_filesystem_files_free{job="node-exporter",fstype!="",mountpoint!=""} / node_filesystem_files{job="node-exporter",fstype!="",mountpoint!=""} * 100 < 40
and
  predict_linear(node_filesystem_files_free{job="node-exporter",fstype!="",mountpoint!=""}[6h], 24*60*60) < 0
and
  node_filesystem_readonly{job="node-exporter",fstype!="",mountpoint!=""} == 0
)
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("1h")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "NodeFilesystemFilesFillingUp",
						Annotations: map[string]string{
							"description": `Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available inodes left and is filling up fast.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/node/nodefilesystemfilesfillingup",
							"summary":     "Filesystem is predicted to run out of inodes within the next 4 hours.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  node_filesystem_files_free{job="node-exporter",fstype!="",mountpoint!=""} / node_filesystem_files{job="node-exporter",fstype!="",mountpoint!=""} * 100 < 20
and
  predict_linear(node_filesystem_files_free{job="node-exporter",fstype!="",mountpoint!=""}[6h], 4*60*60) < 0
and
  node_filesystem_readonly{job="node-exporter",fstype!="",mountpoint!=""} == 0
)
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("1h")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "NodeFilesystemAlmostOutOfFiles",
						Annotations: map[string]string{
							"description": `Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available inodes left.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/node/nodefilesystemalmostoutoffiles",
							"summary":     "Filesystem has less than 5% inodes left.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  node_filesystem_files_free{job="node-exporter",fstype!="",mountpoint!=""} / node_filesystem_files{job="node-exporter",fstype!="",mountpoint!=""} * 100 < 5
and
  node_filesystem_readonly{job="node-exporter",fstype!="",mountpoint!=""} == 0
)
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("1h")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "NodeFilesystemAlmostOutOfFiles",
						Annotations: map[string]string{
							"description": `Filesystem on {{ $labels.device }} at {{ $labels.instance }} has only {{ printf "%.2f" $value }}% available inodes left.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/node/nodefilesystemalmostoutoffiles",
							"summary":     "Filesystem has less than 3% inodes left.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  node_filesystem_files_free{job="node-exporter",fstype!="",mountpoint!=""} / node_filesystem_files{job="node-exporter",fstype!="",mountpoint!=""} * 100 < 3
and
  node_filesystem_readonly{job="node-exporter",fstype!="",mountpoint!=""} == 0
)
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("1h")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "NodeNetworkReceiveErrs",
						Annotations: map[string]string{
							"description": `{{ $labels.instance }} interface {{ $labels.device }} has encountered {{ printf "%.0f" $value }} receive errors in the last two minutes.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/node/nodenetworkreceiveerrs",
							"summary":     "Network interface is reporting many receive errors.",
						},
						Expr: intstr.IntOrString{
							StrVal: "rate(node_network_receive_errs_total[2m]) / rate(node_network_receive_packets_total[2m]) > 0.01",
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("1h")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "NodeNetworkTransmitErrs",
						Annotations: map[string]string{
							"description": `{{ $labels.instance }} interface {{ $labels.device }} has encountered {{ printf "%.0f" $value }} transmit errors in the last two minutes.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/node/nodenetworktransmiterrs",
							"summary":     "Network interface is reporting many transmit errors.",
						},
						Expr: intstr.IntOrString{
							StrVal: "rate(node_network_transmit_errs_total[2m]) / rate(node_network_transmit_packets_total[2m]) > 0.01",
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("1h")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "NodeHighNumberConntrackEntriesUsed",
						Annotations: map[string]string{
							"description": "{{ $value | humanizePercentage }} of conntrack entries are used.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/node/nodehighnumberconntrackentriesused",
							"summary":     "Number of conntrack are getting close to the limit.",
						},
						Expr: intstr.IntOrString{
							StrVal: "(node_nf_conntrack_entries / node_nf_conntrack_entries_limit) > 0.75",
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "NodeTextFileCollectorScrapeError",
						Annotations: map[string]string{
							"description": "Node Exporter text file collector failed to scrape.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/node/nodetextfilecollectorscrapeerror",
							"summary":     "Node Exporter text file collector failed to scrape.",
						},
						Expr: intstr.IntOrString{
							StrVal: `node_textfile_scrape_error{job="node-exporter"} == 1`,
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "NodeClockSkewDetected",
						Annotations: map[string]string{
							"description": "Clock on {{ $labels.instance }} is out of sync by more than 0.05s. Ensure NTP is configured correctly on this host.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/node/nodeclockskewdetected",
							"summary":     "Clock skew detected.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  node_timex_offset_seconds{job="node-exporter"} > 0.05
and
  deriv(node_timex_offset_seconds{job="node-exporter"}[5m]) >= 0
)
or
(
  node_timex_offset_seconds{job="node-exporter"} < -0.05
and
  deriv(node_timex_offset_seconds{job="node-exporter"}[5m]) <= 0
)
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "NodeClockNotSynchronising",
						Annotations: map[string]string{
							"description": "Clock on {{ $labels.instance }} is not synchronising. Ensure NTP is configured on this host.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/node/nodeclocknotsynchronising",
							"summary":     "Clock not synchronising.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
min_over_time(node_timex_sync_status{job="node-exporter"}[5m]) == 0
and
node_timex_maxerror_seconds{job="node-exporter"} >= 16
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "NodeRAIDDegraded",
						Annotations: map[string]string{
							"description": "RAID array '{{ $labels.device }}' on {{ $labels.instance }} is in degraded state due to one or more disks failures. Number of spare drives is insufficient to fix issue automatically.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/node/noderaiddegraded",
							"summary":     "RAID Array is degraded",
						},
						Expr: intstr.IntOrString{
							StrVal: `node_md_disks_required{job="node-exporter",device=~"(/dev/)?(mmcblk.p.+|nvme.+|rbd.+|sd.+|vd.+|xvd.+|dm-.+|md.+|dasd.+)"} - ignoring (state) (node_md_disks{state="active",job="node-exporter",device=~"(/dev/)?(mmcblk.p.+|nvme.+|rbd.+|sd.+|vd.+|xvd.+|dm-.+|md.+|dasd.+)"}) > 0`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "NodeRAIDDiskFailure",
						Annotations: map[string]string{
							"description": "At least one device in RAID array on {{ $labels.instance }} failed. Array '{{ $labels.device }}' needs attention and possibly a disk swap.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/node/noderaiddiskfailure",
							"summary":     "Failed device in RAID array",
						},
						Expr: intstr.IntOrString{
							StrVal: `node_md_disks{state="failed",job="node-exporter",device=~"(/dev/)?(mmcblk.p.+|nvme.+|rbd.+|sd.+|vd.+|xvd.+|dm-.+|md.+|dasd.+)"} > 0`,
							Type:   intstr.Type(int64(1)),
						},
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "NodeFileDescriptorLimit",
						Annotations: map[string]string{
							"description": `File descriptors limit at {{ $labels.instance }} is currently at {{ printf "%.2f" $value }}%.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/node/nodefiledescriptorlimit",
							"summary":     "Kernel is predicted to exhaust file descriptors limit soon.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  node_filefd_allocated{job="node-exporter"} * 100 / node_filefd_maximum{job="node-exporter"} > 70
)
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "NodeFileDescriptorLimit",
						Annotations: map[string]string{
							"description": `File descriptors limit at {{ $labels.instance }} is currently at {{ printf "%.2f" $value }}%.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/node/nodefiledescriptorlimit",
							"summary":     "Kernel is predicted to exhaust file descriptors limit soon.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  node_filefd_allocated{job="node-exporter"} * 100 / node_filefd_maximum{job="node-exporter"} > 90
)
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "critical"},
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeNodeExporterRulesPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-node-exporter.rules",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "node-exporter.rules",
				Rules: []v1.Rule{
					{
						Expr: intstr.IntOrString{
							StrVal: `
count without (cpu, mode) (
  node_cpu_seconds_total{job="node-exporter",mode="idle"}
)
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "instance:node_num_cpu:sum",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
1 - avg without (cpu) (
  sum without (mode) (rate(node_cpu_seconds_total{job="node-exporter", mode=~"idle|iowait|steal"}[5m]))
)
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "instance:node_cpu_utilisation:rate5m",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
(
  node_load1{job="node-exporter"}
/
  instance:node_num_cpu:sum{job="node-exporter"}
)
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "instance:node_load1_per_cpu:ratio",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
1 - (
  (
    node_memory_MemAvailable_bytes{job="node-exporter"}
    or
    (
      node_memory_Buffers_bytes{job="node-exporter"}
      +
      node_memory_Cached_bytes{job="node-exporter"}
      +
      node_memory_MemFree_bytes{job="node-exporter"}
      +
      node_memory_Slab_bytes{job="node-exporter"}
    )
  )
/
  node_memory_MemTotal_bytes{job="node-exporter"}
)
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "instance:node_memory_utilisation:ratio",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `rate(node_vmstat_pgmajfault{job="node-exporter"}[5m])`,
							Type:   intstr.Type(int64(1)),
						},
						Record: "instance:node_vmstat_pgmajfault:rate5m",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `rate(node_disk_io_time_seconds_total{job="node-exporter", device=~"(/dev/)?(mmcblk.p.+|nvme.+|rbd.+|sd.+|vd.+|xvd.+|dm-.+|md.+|dasd.+)"}[5m])`,
							Type:   intstr.Type(int64(1)),
						},
						Record: "instance_device:node_disk_io_time_seconds:rate5m",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `rate(node_disk_io_time_weighted_seconds_total{job="node-exporter", device=~"(/dev/)?(mmcblk.p.+|nvme.+|rbd.+|sd.+|vd.+|xvd.+|dm-.+|md.+|dasd.+)"}[5m])`,
							Type:   intstr.Type(int64(1)),
						},
						Record: "instance_device:node_disk_io_time_weighted_seconds:rate5m",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
sum without (device) (
  rate(node_network_receive_bytes_total{job="node-exporter", device!="lo"}[5m])
)
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "instance:node_network_receive_bytes_excluding_lo:rate5m",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
sum without (device) (
  rate(node_network_transmit_bytes_total{job="node-exporter", device!="lo"}[5m])
)
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "instance:node_network_transmit_bytes_excluding_lo:rate5m",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
sum without (device) (
  rate(node_network_receive_drop_total{job="node-exporter", device!="lo"}[5m])
)
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "instance:node_network_receive_drop_excluding_lo:rate5m",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
sum without (device) (
  rate(node_network_transmit_drop_total{job="node-exporter", device!="lo"}[5m])
)
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "instance:node_network_transmit_drop_excluding_lo:rate5m",
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeNodeNetworkPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-node-network",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "node-network",
				Rules: []v1.Rule{
					{
						Alert: "NodeNetworkInterfaceFlapping",
						Annotations: map[string]string{
							"description": `Network interface "{{ $labels.device }}" changing its up status often on node-exporter {{ $labels.namespace }}/{{ $labels.pod }}`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/general/nodenetworkinterfaceflapping",
							"summary":     "Network interface is often changing its status",
						},
						Expr: intstr.IntOrString{
							StrVal: `changes(node_network_up{job="node-exporter",device!~"veth.+"}[2m]) > 2`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("2m")),
						Labels: map[string]string{"severity": "warning"},
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubeNodeRulesPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-node.rules",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "node.rules",
				Rules: []v1.Rule{
					{
						Expr: intstr.IntOrString{
							StrVal: `
topk by(cluster, namespace, pod) (1,
  max by (cluster, node, namespace, pod) (
    label_replace(kube_pod_info{job="kube-state-metrics",node!=""}, "pod", "$1", "pod", "(.*)")
))
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "node_namespace_pod:kube_pod_info:",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
count by (cluster, node) (
  node_cpu_seconds_total{mode="idle",job="node-exporter"}
  * on (namespace, pod) group_left(node)
  topk by(namespace, pod) (1, node_namespace_pod:kube_pod_info:)
)
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "node:node_num_cpu:sum",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
sum(
  node_memory_MemAvailable_bytes{job="node-exporter"} or
  (
    node_memory_Buffers_bytes{job="node-exporter"} +
    node_memory_Cached_bytes{job="node-exporter"} +
    node_memory_MemFree_bytes{job="node-exporter"} +
    node_memory_Slab_bytes{job="node-exporter"}
  )
) by (cluster)
`,
							Type: intstr.Type(int64(1)),
						},
						Record: ":node_memory_MemAvailable_bytes:sum",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
avg by (cluster, node) (
  sum without (mode) (
    rate(node_cpu_seconds_total{mode!="idle",mode!="iowait",mode!="steal",job="node-exporter"}[5m])
  )
)
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "node:node_cpu_utilization:ratio_rate5m",
					}, {
						Expr: intstr.IntOrString{
							StrVal: `
avg by (cluster) (
  node:node_cpu_utilization:ratio_rate5m
)
`,
							Type: intstr.Type(int64(1)),
						},
						Record: "cluster:node_cpu:ratio_rate5m",
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubePrometheusOperatorPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-prometheus-operator",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "prometheus-operator",
				Rules: []v1.Rule{
					{
						Alert: "PrometheusOperatorListErrors",
						Annotations: map[string]string{
							"description": "Errors while performing List operations in controller {{$labels.controller}} in {{$labels.namespace}} namespace.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus-operator/prometheusoperatorlisterrors",
							"summary":     "Errors while performing list operations in controller.",
						},
						Expr: intstr.IntOrString{
							StrVal: `(sum by (cluster,controller,namespace) (rate(prometheus_operator_list_operations_failed_total{job="kube-promtheus-stack-kube-operator",namespace="monitoring"}[10m])) / sum by (cluster,controller,namespace) (rate(prometheus_operator_list_operations_total{job="kube-promtheus-stack-kube-operator",namespace="monitoring"}[10m]))) > 0.4`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "PrometheusOperatorWatchErrors",
						Annotations: map[string]string{
							"description": "Errors while performing watch operations in controller {{$labels.controller}} in {{$labels.namespace}} namespace.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus-operator/prometheusoperatorwatcherrors",
							"summary":     "Errors while performing watch operations in controller.",
						},
						Expr: intstr.IntOrString{
							StrVal: `(sum by (cluster,controller,namespace) (rate(prometheus_operator_watch_operations_failed_total{job="kube-promtheus-stack-kube-operator",namespace="monitoring"}[5m])) / sum by (cluster,controller,namespace) (rate(prometheus_operator_watch_operations_total{job="kube-promtheus-stack-kube-operator",namespace="monitoring"}[5m]))) > 0.4`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "PrometheusOperatorSyncFailed",
						Annotations: map[string]string{
							"description": "Controller {{ $labels.controller }} in {{ $labels.namespace }} namespace fails to reconcile {{ $value }} objects.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus-operator/prometheusoperatorsyncfailed",
							"summary":     "Last controller reconciliation failed",
						},
						Expr: intstr.IntOrString{
							StrVal: `min_over_time(prometheus_operator_syncs{status="failed",job="kube-promtheus-stack-kube-operator",namespace="monitoring"}[5m]) > 0`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "PrometheusOperatorReconcileErrors",
						Annotations: map[string]string{
							"description": "{{ $value | humanizePercentage }} of reconciling operations failed for {{ $labels.controller }} controller in {{ $labels.namespace }} namespace.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus-operator/prometheusoperatorreconcileerrors",
							"summary":     "Errors while reconciling controller.",
						},
						Expr: intstr.IntOrString{
							StrVal: `(sum by (cluster,controller,namespace) (rate(prometheus_operator_reconcile_errors_total{job="kube-promtheus-stack-kube-operator",namespace="monitoring"}[5m]))) / (sum by (cluster,controller,namespace) (rate(prometheus_operator_reconcile_operations_total{job="kube-promtheus-stack-kube-operator",namespace="monitoring"}[5m]))) > 0.1`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "PrometheusOperatorNodeLookupErrors",
						Annotations: map[string]string{
							"description": "Errors while reconciling Prometheus in {{ $labels.namespace }} Namespace.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus-operator/prometheusoperatornodelookuperrors",
							"summary":     "Errors while reconciling Prometheus.",
						},
						Expr: intstr.IntOrString{
							StrVal: `rate(prometheus_operator_node_address_lookup_errors_total{job="kube-promtheus-stack-kube-operator",namespace="monitoring"}[5m]) > 0.1`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "PrometheusOperatorNotReady",
						Annotations: map[string]string{
							"description": "Prometheus operator in {{ $labels.namespace }} namespace isn't ready to reconcile {{ $labels.controller }} resources.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus-operator/prometheusoperatornotready",
							"summary":     "Prometheus operator not ready",
						},
						Expr: intstr.IntOrString{
							StrVal: `min by (cluster,controller,namespace) (max_over_time(prometheus_operator_ready{job="kube-promtheus-stack-kube-operator",namespace="monitoring"}[5m]) == 0)`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("5m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "PrometheusOperatorRejectedResources",
						Annotations: map[string]string{
							"description": `Prometheus operator in {{ $labels.namespace }} namespace rejected {{ printf "%0.0f" $value }} {{ $labels.controller }}/{{ $labels.resource }} resources.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus-operator/prometheusoperatorrejectedresources",
							"summary":     "Resources rejected by Prometheus operator",
						},
						Expr: intstr.IntOrString{
							StrVal: `min_over_time(prometheus_operator_managed_resources{state="rejected",job="kube-promtheus-stack-kube-operator",namespace="monitoring"}[5m]) > 0`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("5m")),
						Labels: map[string]string{"severity": "warning"},
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}

var KubePromtheusStackKubePrometheusPrometheusRule = &v1.PrometheusRule{
	ObjectMeta: metav1.ObjectMeta{
		Labels: map[string]string{
			"app":                          "kube-prometheus-stack",
			"app.kubernetes.io/instance":   "kube-promtheus-stack",
			"app.kubernetes.io/managed-by": "Helm",
			"app.kubernetes.io/part-of":    "kube-prometheus-stack",
			"app.kubernetes.io/version":    "47.0.0",
			"chart":                        "kube-prometheus-stack-47.0.0",
			"heritage":                     "Helm",
			"release":                      "kube-promtheus-stack",
		},
		Name:      "kube-promtheus-stack-kube-prometheus",
		Namespace: "monitoring",
	},
	Spec: v1.PrometheusRuleSpec{
		Groups: []v1.RuleGroup{
			{
				Name: "prometheus",
				Rules: []v1.Rule{
					{
						Alert: "PrometheusBadConfig",
						Annotations: map[string]string{
							"description": "Prometheus {{$labels.namespace}}/{{$labels.pod}} has failed to reload its configuration.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus/prometheusbadconfig",
							"summary":     "Failed Prometheus configuration reload.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
# Without max_over_time, failed scrapes could create false negatives, see
# https://www.robustperception.io/alerting-on-gauges-in-prometheus-2-0 for details.
max_over_time(prometheus_config_last_reload_successful{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m]) == 0
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "PrometheusNotificationQueueRunningFull",
						Annotations: map[string]string{
							"description": "Alert notification queue of Prometheus {{$labels.namespace}}/{{$labels.pod}} is running full.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus/prometheusnotificationqueuerunningfull",
							"summary":     "Prometheus alert notification queue predicted to run full in less than 30m.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
# Without min_over_time, failed scrapes could create false negatives, see
# https://www.robustperception.io/alerting-on-gauges-in-prometheus-2-0 for details.
(
  predict_linear(prometheus_notifications_queue_length{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m], 60 * 30)
>
  min_over_time(prometheus_notifications_queue_capacity{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m])
)
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "PrometheusErrorSendingAlertsToSomeAlertmanagers",
						Annotations: map[string]string{
							"description": `{{ printf "%.1f" $value }}% errors while sending alerts from Prometheus {{$labels.namespace}}/{{$labels.pod}} to Alertmanager {{$labels.alertmanager}}.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus/prometheuserrorsendingalertstosomealertmanagers",
							"summary":     "Prometheus has encountered more than 1% errors sending alerts to a specific Alertmanager.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  rate(prometheus_notifications_errors_total{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m])
/
  rate(prometheus_notifications_sent_total{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m])
)
* 100
> 1
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "PrometheusNotConnectedToAlertmanagers",
						Annotations: map[string]string{
							"description": "Prometheus {{$labels.namespace}}/{{$labels.pod}} is not connected to any Alertmanagers.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus/prometheusnotconnectedtoalertmanagers",
							"summary":     "Prometheus is not connected to any Alertmanagers.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
# Without max_over_time, failed scrapes could create false negatives, see
# https://www.robustperception.io/alerting-on-gauges-in-prometheus-2-0 for details.
max_over_time(prometheus_notifications_alertmanagers_discovered{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m]) < 1
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "PrometheusTSDBReloadsFailing",
						Annotations: map[string]string{
							"description": "Prometheus {{$labels.namespace}}/{{$labels.pod}} has detected {{$value | humanize}} reload failures over the last 3h.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus/prometheustsdbreloadsfailing",
							"summary":     "Prometheus has issues reloading blocks from disk.",
						},
						Expr: intstr.IntOrString{
							StrVal: `increase(prometheus_tsdb_reloads_failures_total{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[3h]) > 0`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("4h")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "PrometheusTSDBCompactionsFailing",
						Annotations: map[string]string{
							"description": "Prometheus {{$labels.namespace}}/{{$labels.pod}} has detected {{$value | humanize}} compaction failures over the last 3h.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus/prometheustsdbcompactionsfailing",
							"summary":     "Prometheus has issues compacting blocks.",
						},
						Expr: intstr.IntOrString{
							StrVal: `increase(prometheus_tsdb_compactions_failed_total{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[3h]) > 0`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("4h")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "PrometheusNotIngestingSamples",
						Annotations: map[string]string{
							"description": "Prometheus {{$labels.namespace}}/{{$labels.pod}} is not ingesting samples.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus/prometheusnotingestingsamples",
							"summary":     "Prometheus is not ingesting samples.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  rate(prometheus_tsdb_head_samples_appended_total{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m]) <= 0
and
  (
    sum without(scrape_job) (prometheus_target_metadata_cache_entries{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}) > 0
  or
    sum without(rule_group) (prometheus_rule_group_rules{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}) > 0
  )
)
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "PrometheusDuplicateTimestamps",
						Annotations: map[string]string{
							"description": `Prometheus {{$labels.namespace}}/{{$labels.pod}} is dropping {{ printf "%.4g" $value  }} samples/s with different values but duplicated timestamp.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus/prometheusduplicatetimestamps",
							"summary":     "Prometheus is dropping samples with duplicate timestamps.",
						},
						Expr: intstr.IntOrString{
							StrVal: `rate(prometheus_target_scrapes_sample_duplicate_timestamp_total{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m]) > 0`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "PrometheusOutOfOrderTimestamps",
						Annotations: map[string]string{
							"description": `Prometheus {{$labels.namespace}}/{{$labels.pod}} is dropping {{ printf "%.4g" $value  }} samples/s with timestamps arriving out of order.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus/prometheusoutofordertimestamps",
							"summary":     "Prometheus drops samples with out-of-order timestamps.",
						},
						Expr: intstr.IntOrString{
							StrVal: `rate(prometheus_target_scrapes_sample_out_of_order_total{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m]) > 0`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("10m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "PrometheusRemoteStorageFailures",
						Annotations: map[string]string{
							"description": `Prometheus {{$labels.namespace}}/{{$labels.pod}} failed to send {{ printf "%.1f" $value }}% of the samples to {{ $labels.remote_name}}:{{ $labels.url }}`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus/prometheusremotestoragefailures",
							"summary":     "Prometheus fails to send samples to remote storage.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
(
  (rate(prometheus_remote_storage_failed_samples_total{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m]) or rate(prometheus_remote_storage_samples_failed_total{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m]))
/
  (
    (rate(prometheus_remote_storage_failed_samples_total{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m]) or rate(prometheus_remote_storage_samples_failed_total{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m]))
  +
    (rate(prometheus_remote_storage_succeeded_samples_total{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m]) or rate(prometheus_remote_storage_samples_total{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m]))
  )
)
* 100
> 1
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "PrometheusRemoteWriteBehind",
						Annotations: map[string]string{
							"description": `Prometheus {{$labels.namespace}}/{{$labels.pod}} remote write is {{ printf "%.1f" $value }}s behind for {{ $labels.remote_name}}:{{ $labels.url }}.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus/prometheusremotewritebehind",
							"summary":     "Prometheus remote write is behind.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
# Without max_over_time, failed scrapes could create false negatives, see
# https://www.robustperception.io/alerting-on-gauges-in-prometheus-2-0 for details.
(
  max_over_time(prometheus_remote_storage_highest_timestamp_in_seconds{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m])
- ignoring(remote_name, url) group_right
  max_over_time(prometheus_remote_storage_queue_highest_sent_timestamp_seconds{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m])
)
> 120
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "PrometheusRemoteWriteDesiredShards",
						Annotations: map[string]string{
							"description": "Prometheus {{$labels.namespace}}/{{$labels.pod}} remote write desired shards calculation wants to run {{ $value }} shards for queue {{ $labels.remote_name}}:{{ $labels.url }}, which is more than the max of {{ printf `prometheus_remote_storage_shards_max{instance=\"%s\",job=\"kube-promtheus-stack-kube-prometheus\",namespace=\"monitoring\"}` $labels.instance | query | first | value }}.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus/prometheusremotewritedesiredshards",
							"summary":     "Prometheus remote write desired shards calculation wants to run more than configured max shards.",
						},
						Expr: intstr.IntOrString{
							StrVal: `
# Without max_over_time, failed scrapes could create false negatives, see
# https://www.robustperception.io/alerting-on-gauges-in-prometheus-2-0 for details.
(
  max_over_time(prometheus_remote_storage_shards_desired{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m])
>
  max_over_time(prometheus_remote_storage_shards_max{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m])
)
`,
							Type: intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "PrometheusRuleFailures",
						Annotations: map[string]string{
							"description": `Prometheus {{$labels.namespace}}/{{$labels.pod}} has failed to evaluate {{ printf "%.0f" $value }} rules in the last 5m.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus/prometheusrulefailures",
							"summary":     "Prometheus is failing rule evaluations.",
						},
						Expr: intstr.IntOrString{
							StrVal: `increase(prometheus_rule_evaluation_failures_total{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m]) > 0`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "PrometheusMissingRuleEvaluations",
						Annotations: map[string]string{
							"description": `Prometheus {{$labels.namespace}}/{{$labels.pod}} has missed {{ printf "%.0f" $value }} rule group evaluations in the last 5m.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus/prometheusmissingruleevaluations",
							"summary":     "Prometheus is missing rule evaluations due to slow rule group evaluation.",
						},
						Expr: intstr.IntOrString{
							StrVal: `increase(prometheus_rule_group_iterations_missed_total{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m]) > 0`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "PrometheusTargetLimitHit",
						Annotations: map[string]string{
							"description": `Prometheus {{$labels.namespace}}/{{$labels.pod}} has dropped {{ printf "%.0f" $value }} targets because the number of targets exceeded the configured target_limit.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus/prometheustargetlimithit",
							"summary":     "Prometheus has dropped targets because some scrape configs have exceeded the targets limit.",
						},
						Expr: intstr.IntOrString{
							StrVal: `increase(prometheus_target_scrape_pool_exceeded_target_limit_total{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m]) > 0`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "PrometheusLabelLimitHit",
						Annotations: map[string]string{
							"description": `Prometheus {{$labels.namespace}}/{{$labels.pod}} has dropped {{ printf "%.0f" $value }} targets because some samples exceeded the configured label_limit, label_name_length_limit or label_value_length_limit.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus/prometheuslabellimithit",
							"summary":     "Prometheus has dropped targets because some scrape configs have exceeded the labels limit.",
						},
						Expr: intstr.IntOrString{
							StrVal: `increase(prometheus_target_scrape_pool_exceeded_label_limits_total{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m]) > 0`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "PrometheusScrapeBodySizeLimitHit",
						Annotations: map[string]string{
							"description": `Prometheus {{$labels.namespace}}/{{$labels.pod}} has failed {{ printf "%.0f" $value }} scrapes in the last 5m because some targets exceeded the configured body_size_limit.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus/prometheusscrapebodysizelimithit",
							"summary":     "Prometheus has dropped some targets that exceeded body size limit.",
						},
						Expr: intstr.IntOrString{
							StrVal: `increase(prometheus_target_scrapes_exceeded_body_size_limit_total{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m]) > 0`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "PrometheusScrapeSampleLimitHit",
						Annotations: map[string]string{
							"description": `Prometheus {{$labels.namespace}}/{{$labels.pod}} has failed {{ printf "%.0f" $value }} scrapes in the last 5m because some targets exceeded the configured sample_limit.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus/prometheusscrapesamplelimithit",
							"summary":     "Prometheus has failed scrapes that have exceeded the configured sample limit.",
						},
						Expr: intstr.IntOrString{
							StrVal: `increase(prometheus_target_scrapes_exceeded_sample_limit_total{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m]) > 0`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "PrometheusTargetSyncFailure",
						Annotations: map[string]string{
							"description": `{{ printf "%.0f" $value }} targets in Prometheus {{$labels.namespace}}/{{$labels.pod}} have failed to sync because invalid configuration was supplied.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus/prometheustargetsyncfailure",
							"summary":     "Prometheus has failed to sync targets.",
						},
						Expr: intstr.IntOrString{
							StrVal: `increase(prometheus_target_sync_failed_total{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[30m]) > 0`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("5m")),
						Labels: map[string]string{"severity": "critical"},
					}, {
						Alert: "PrometheusHighQueryLoad",
						Annotations: map[string]string{
							"description": "Prometheus {{$labels.namespace}}/{{$labels.pod}} query API has less than 20% available capacity in its query engine for the last 15 minutes.",
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus/prometheushighqueryload",
							"summary":     "Prometheus is reaching its maximum capacity serving concurrent requests.",
						},
						Expr: intstr.IntOrString{
							StrVal: `avg_over_time(prometheus_engine_queries{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m]) / max_over_time(prometheus_engine_queries_concurrent_max{job="kube-promtheus-stack-kube-prometheus",namespace="monitoring"}[5m]) > 0.8`,
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "warning"},
					}, {
						Alert: "PrometheusErrorSendingAlertsToAnyAlertmanager",
						Annotations: map[string]string{
							"description": `{{ printf "%.1f" $value }}% minimum errors while sending alerts from Prometheus {{$labels.namespace}}/{{$labels.pod}} to any Alertmanager.`,
							"runbook_url": "https://runbooks.prometheus-operator.dev/runbooks/prometheus/prometheuserrorsendingalertstoanyalertmanager",
							"summary":     "Prometheus encounters more than 3% errors sending alerts to any Alertmanager.",
						},
						Expr: intstr.IntOrString{
							StrVal: "min without (alertmanager) (\n  rate(prometheus_notifications_errors_total{job=\"kube-promtheus-stack-kube-prometheus\",namespace=\"monitoring\",alertmanager!~``}[5m])\n/\n  rate(prometheus_notifications_sent_total{job=\"kube-promtheus-stack-kube-prometheus\",namespace=\"monitoring\",alertmanager!~``}[5m])\n)\n* 100\n> 3",
							Type:   intstr.Type(int64(1)),
						},
						For:    P(v1.Duration("15m")),
						Labels: map[string]string{"severity": "critical"},
					},
				},
			},
		},
	},
	TypeMeta: metav1.TypeMeta{
		APIVersion: "monitoring.coreos.com/v1",
		Kind:       "PrometheusRule",
	},
}
