TIL/Monitoring(k8s, grafana)

[모니터링, k8s, Grafana, Prometheus] Prometheus 쿼리에 '$__rate_interval' 이 포함될 때 return 값이 없는 현상

쓱쓱565 2024. 10. 31. 18:40

상황

  • Grafana 대시보드에서 Prometheus를 datasource로 사용하는 대시보드에서 metric들을 쿼리할 때, 그래프에 일부 값들이 표현되지 않았다.
  • 비교적 짧은 기간(5 ~ 10m) 을 쿼리할 때에만 해당 증상이 나타났다. 긴 기간을 쿼리할 때에는 정상 작동했다.

추측했던 원인

  • prometheus 의 버전 문제:
    • [$__rate_interval]을 지원하지 않는 버전이지 않을까 추측함 -> 아니었다.

원인

  • Prometheus 의 scrape_interval 값이 grafana의 rate_interval(조회 기간에 따라 자동 생성됨)값에 비해 크다.
  • Grafana 에서 rate_interval % 4가 Prometheus 의 scrape_interval 값 보다 작을 경우, 쿼리에 대한 결과값이 없다.

해결방법

  • Prometheus의 scrape_config 값을 작게 조정했다.
prometheus:
  enabled: true
  server:
    global:
      scrape_interval: 15s # default: 1m

외부 링크(Grafana 공식 블로그)

아래 글에서 위 증상을 확인할 수 있다.
https://grafana.com/blog/2020/09/28/new-in-grafana-7.2-__rate_interval-for-prometheus-rate-queries-that-just-work/

 

New in Grafana 7.2: $__rate_interval for Prometheus rate queries that just work | Grafana Labs

Ronald McCollam   ·   30 Oct 2024   ·   12 min read Grafana variables: what they are and how they create dynamic dashboards

grafana.com