Course outline

Grafana / Intermediate: transformations, configuration, and alerts / Lesson 14

Ratios, populations and alert meaning

Compare numerator and denominator populations before displaying or alerting on a combined ratio.

About 3 min readContent reviewed
On this page

Lesson goals

  • Calculate a weighted combined error ratio from matching populations.
  • Handle zero traffic and missing series explicitly in dashboard and alert reviews.

Define numerator and denominator

An error ratio answers a question only when its numerator and denominator cover the same service population, time window and request definition. Decide whether retries and excluded routes count before choosing a visualization. A percentage displayed with a polished unit can still compare unrelated populations. Document the query, labels and window so a reviewer can reconstruct the calculation and its operational meaning.

Inspect two synthetic services

The fixture contains one error in ten requests for service A and nine in ninety for service B over the same declared interval. Both individual ratios are ten percent. These numbers are illustrative counts, not live Prometheus samples or a query result. A real counter-based query must also account for its source semantics, reset handling and the selected time window.

json Synthetic request and error counts
{"service_a":{"errors":1,"requests":10},"service_b":{"errors":9,"requests":90}}

Both services describe the same interval and compatible definitions in this teaching fixture.

Aggregate counts before dividing

Add the errors and requests separately: ten divided by one hundred is 0.1, or ten percent. This method weights each request equally; averaging per-service percentages gives each service equal weight instead and can differ when their traffic differs. The JSON result records the calculation, not an executed Grafana expression. Retain the numerator and denominator alongside the ratio during investigation.

json Combined ratio for the fixture
{"total_errors":10,"total_requests":100,"combined_error_ratio":0.1}

Ten errors divided by one hundred requests yields 0.1 under the stated population contract.

Decide what missing or zero means

No requests, a missing time series and a query error are different conditions. A zero denominator should not be silently described as zero errors, and an absent service may indicate missing telemetry rather than healthy traffic. Specify the expected display and alert behavior for each case and check the rules supported by the deployed source and Grafana version. Review label alignment before combining series.

Test a meaningful alert

In a disposable dashboard and alert rule, use a known synthetic dataset with uneven traffic, a zero-traffic interval and a missing series. Compare the displayed ratio and alert evaluation with independently calculated expectations for the same window. Verify that notification routing reaches a test contact point. A matching panel alone does not prove the alert uses the same query, reduction, timing or missing-data policy.

Common errors and fixes

An average of service percentages misstates the request-weighted ratio.

Why it happens
Each service was given equal weight despite different traffic.
How to fix it
Aggregate compatible error and request counts separately before dividing.
Prevent it next time
Test an uneven-traffic fixture.

Zero traffic is presented as a healthy zero error rate.

Why it happens
A zero denominator was silently mapped to zero.
How to fix it
Use the documented no-traffic behavior.
Prevent it next time
Test zero and missing inputs separately.

A panel and alert disagree about the same ratio.

Why it happens
Their windows, labels or reductions differ.
How to fix it
Compare the actual query and evaluation contexts.
Prevent it next time
Review both together with a known fixture.

2 practice exercises

1. What is the combined ratio in the fixture?

Show worked solution

There are ten errors and one hundred requests, so 10 / 100 = 0.1, or 10%. This answer assumes both services use the same definitions and interval.

2. Service A has 1 error in 2 requests and B has 0 errors in 98. What is the request-weighted ratio?

Show worked solution

The combined population has 1 error in 100 requests, or 1%. Averaging the service ratios, 50% and 0%, would give 25%, a different question that weights both services equally.

Key takeaways

  • Aggregate compatible numerators and denominators before dividing.
  • Treat zero traffic, missing data and query errors as distinct cases.

Official references