How to restore deleted recording rules for Kubernetes integration


I was trying to add same Alerting rules on Grafana Cloud alerting, but I think I have acidentally deleted the default recording rules for Kubernetes integration. because of that I don´t have CPU metrics in the Integration dashboards anymore.

Is there any way to restore the recording rules?

Or if someone can post the rules definitions, I could re-add then manually.

Also, I think there is a bug on the interface. I tried to create a new group, but it´s not created at the “root” level but instead inside the current selected group, like "integrations-kubernetes

Thank you.

Hello @brpaz

The most direct way to resolve this would be to uninstall, then reinstall the integration. Of course, if you customized the recording or alert rules in the “integrations-kubernetes” group, those changes would be lost.

If you’d like to simply replace the rule, here it is, fully rendered from my instance.

                "name": "k8s.rules",
                "file": "integrations-kubernetes",
                "rules": [
                        "name": "node_namespace_pod_container:container_cpu_usage_seconds_total:sum_rate",
                        "query": "sum by(cluster, namespace, pod, container) (rate(container_cpu_usage_seconds_total{image!=\"\",job=\"integrations/kubernetes/cadvisor\"}[5m])) * on(cluster, namespace, pod) group_left(node) topk by(cluster, namespace, pod) (1, max by(cluster, namespace, pod, node) (clamp_max(clamp_min(label_replace(container_start_time_seconds{instance!=\"\"}, \"node\", \"$1\", \"instance\", \"(.*)\"), 1), 1)))",
                        "labels": {},
                        "health": "ok",
                        "lastError": "",
                        "type": "recording",
                        "lastEvaluation": "2021-07-07T21:03:03.799414153Z",
                        "evaluationTime": 0.009059764
                "interval": 60,
                "lastEvaluation": "2021-07-07T21:03:03.79939174Z",
                "evaluationTime": 0.009086642

Also, I experienced the same issue with creating a new rule or rule group in the UI, I’ll look into that.