kubevirt: Prometheus has warning message of evaluating rule failed against KubeVirtComponentExceedsRequestedMemory

What happened: A clear and concise description of what the bug is.

When kubevirt and any others are deployed in same namespace, then prometheus will have such error message:

level=warn ts=2023-04-19T08:56:37.628Z caller=manager.go:603 component="rule manager" 
group=kubevirt.rules 
msg="Evaluating rule failed" 
rule="alert: KubeVirtComponentExceedsRequestedMemory\nexpr: 
((kube_pod_container_resource_requests{container=~"virt-controller|virt-api|virt-handler|virt-operator",namespace="harvester-system",resource="memory"})\n - on(pod) group_left(node) container_memory_working_set_bytes{container="",namespace="harvester-system"})
\n < 0\nfor: 5m\nlabels:\n kubernetes_operator_component: kubevirt\n kubernetes_operator_part_of: kubevirt\n severity: warning\nannotations:\n 
description: Container {{ $labels.container }} in pod {{ $labels.pod }} memory usage\n exceeds the memory requested\n 
runbook_url: https://kubevirt.io/monitoring/runbooks/KubeVirtComponentExceedsRequestedMemory\n 
summary: The container is using more memory than what is defined in the containers\n resource requests\n" 
err="found duplicate series for the match group {pod="kube-vip-cloud-provider-0"} on the right hand-side of the operation: 

What you expected to happen: A clear and concise description of what you expected to happen.

Fix the bug.

How to reproduce it (as minimally and precisely as possible): Steps to reproduce the behavior.

(1) deploy kubevirt in any namespace like harvester-system, (2) deploy any other deployments in this namesapce

Additional context: Add any other context about the problem here. Reported in https://github.com/kubevirt/kubevirt/issues/8439, which was closed and I can not reopen it. There was ever some PR to fix: https://github.com/kubevirt/kubevirt/pull/8306, but seemed still not correctly working in all cases.

Environment:

  • KubeVirt version (use virtctl version): v0.54.0
  • Kubernetes version (use kubectl version): v1.21
  • VM or VMI specifications: N/A
  • Cloud provider or hardware configuration: Harvester
  • OS (e.g. from /etc/os-release): N/A
  • Kernel (e.g. uname -a): N/A
  • Install tools: N/A
  • Others: N/A

Root cause

Per investigation https://github.com/harvester/harvester/issues/3792#issuecomment-1532559288

Run those rules in prometheus directly in a single-node k8s cluster (havester):

**Left hand:**
kube_pod_container_resource_requests{container=~"virt-controller|virt-api|virt-handler|virt-operator",namespace="harvester-system",resource="memory"}

Only 5 return results.

**Right hand:**
container_memory_working_set_bytes{container="",namespace="harvester-system"}

There are much more (30) return results
Load time: 34ms   Resolution: 14s   Result series: 30

Prometheus is complaining ...err="found duplicate series for the match group {pod="kube-vip-cloud-provider-0"} on the right hand-side of the operation...

A workaround to work correctly if following explanation is correct: https://github.com/harvester/harvester/issues/3792#issuecomment-1532699770

((kube_pod_container_resource_requests{container=~"virt-controller|virt-api|virt-handler|virt-operator",namespace="harvester-system",resource="memory"}) - on(pod) group_left(node) container_memory_working_set_bytes{container=~"virt-controller|virt-api|virt-handler|virt-operator",namespace="harvester-system"}) < 0

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 28 (14 by maintainers)

Most upvoted comments

Just chiming in to say #10022 is still needed as late as v1.1.1 - I’m able to reproduce this on k3s 1.28+ and kube-prometheus both in v0.13.0 and main.