← 返回
效率工具 中文

Grafana

Avoid common Grafana mistakes — query pitfalls, variable templating, alerting traps, and provisioning gotchas.
避免常见的Grafana错误——查询陷阱、变量模板、告警误区及配置易错点。
ivangdavila
效率工具 clawhub v1.0.0 1 版本 99771.3 Key: 无需
★ 4
Stars
📥 2,538
下载
💾 58
安装
1
版本
#latest

概述

Variables and Templating

  • Multi-value variable needs $__all in regex — or only first value used
  • ${var:csv} for comma-separated — ${var:pipe} for pipe-separated in regex
  • Variable in query: $var or ${var} — different escaping per data source
  • $__interval auto-adjusts to time range — use for aggregation window
  • Chained variables: child depends on parent — set "Refresh" to "On time range change"

Prometheus Queries

  • rate() needs range vector — rate(requests_total[5m]) not rate(requests_total)
  • rate() for counters, deriv() for gauges — rate handles counter resets
  • $__rate_interval over hardcoded — adapts to scrape interval and dashboard range
  • Labels in legend: {{label}} — multiple: {{instance}} - {{job}}
  • Regex filter: metric{label=~"val1|val2"}!~ for negative match

Panel Configuration

  • "No data" vs "null" are different — configure in display options
  • Thresholds work on last value — not all values in range
  • Min/max must match your data range — auto-scaling can hide anomalies
  • Time series for trends, stat for current value — choose visualization wisely

Alerting

  • Alert evaluates on server — not browser, query must work without variables
  • Variables not supported in alerts — hardcode values or use templates
  • Multiple conditions: AND is default — configure for OR if needed
  • Alert state "Pending" before "Firing" — for duration, prevents flapping
  • Notification channel must be configured — alert without channel = no notification

Dashboard Provisioning

  • JSON export includes data source UID — will fail if different on import
  • Use data source variables — ${DS_PROMETHEUS} substituted at runtime
  • Provisioned dashboards read-only by default — allowEditing: true in provisioning
  • Folder must exist before dashboard provisioning — or import fails silently

Data Sources

  • "Server" mode proxies through Grafana — hides credentials from browser
  • "Browser" mode direct from browser — faster but exposes URL/auth
  • Test connection catches most issues — but not query-specific problems
  • TLS skip verify for self-signed — but fix proper certs for production

Transformations

  • Order matters — transformations apply in sequence
  • Outer join for combining queries — match on time or label
  • Reduce for aggregating time series — last, mean, max, etc.
  • Add field from calculation — combine metrics client-side

Common Mistakes

  • Time range selector affects variable queries — unexpected results with "All time"
  • Dashboard saved but datasource not — works locally, breaks on import
  • Alert rule in dashboard vs Grafana alerting — different systems, don't mix
  • Panel queries run on every refresh — high-cardinality queries slow dashboard
  • Annotation queries add DB load — use sparingly on busy dashboards

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-28 20:04 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

productivity

Weather

steipete
获取当前天气和预报(无需API密钥)
★ 445 📥 226,223
productivity

Baidu web search

ide-rea
使用百度AI搜索引擎(BDSE)进行网络搜索。适用于获取实时信息、文档资料或研究课题。
★ 237 📥 105,446
ai-intelligence

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,355 📥 318,015