Rewrite a label with label_replace

Create a new label from a regex capture, useful for joins and cleaner dashboards

label_replace(node_uname_info, "host", "$1", "nodename", "(.+)")

tool
prometheus30 commands
tags
prometheusobservabilitymonitoring

More prometheus commands

  • max_over_time(rate(node_network_receive_bytes_total[5m])[1h:1m])

    Subquery: the highest 5m rate, checked every minute over the last hour, shows traffic bursts

  • sum without(instance) (rate(http_requests_total{code=~"5.."}[5m]))

    without() keeps every label except instance, cleaner than a long by() list

  • groups: - name: slo rules: - record: job:request_errors:ratio5m expr: sum by(job)(rate(http_requests_total{code=~"5.."}[5m])) / sum by(job)(rate(http_requests_total[5m]))

    Precompute the SLO error ratio so dashboards and alerts stay fast

  • promtool check rules rules.yml && promtool check config prometheus.yml

    Run before a reload or in CI to catch broken expressions or YAML before deploy

  • promtool query instant http://localhost:9090 'topk(5, sum by(pod)(rate(container_cpu_usage_seconds_total[5m])))'

    Run PromQL without a browser, handy for top-N checks in scripts

all 30 prometheus commands