Course outline

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

Field overrides, mappings, and thresholds

Target presentation rules to the intended fields and distinguish display mappings and thresholds from source conversion, authorization, and alert evaluation.

About 4 min readContent reviewed
On this page

Lesson goals

  • Explain defaults and field matchers.
  • Review value, range, regex, and special mappings.
  • Interpret absolute and relative display thresholds.

An override is a conditional display rule

Field defaults provide common settings, while overrides select fields through supported matchers such as names, patterns, types, or query-related context. The exact matcher options depend on version and visualization. Review all matching rules and their combined effect instead of assuming one visible setting is the whole configuration. A source rename can make an exact matcher stop applying, while a broad regex can affect an unintended count field. Keep the field’s stable meaning and unit in the contract. An override changes presentation behavior; it is not a backend permission or a replacement for correctly typed data.

Target a duration field rather than every number

The classic field-config fragment applies a seconds unit only to delay_seconds while sharing a decimal default. It is incomplete as a panel and is not imported or rendered. A data source can return another field with the same display name but different identity, so check the actual frames and selected matcher behavior. Decimal display does not increase source precision. A count and a duration should not receive one common unit merely because both are numeric. Review expected and unexpected field names in a fixture before relying on a reused panel across sources.

json Illustrative named-field unit override
{"fieldConfig":{"defaults":{"decimals":1},"overrides":[{"matcher":{"id":"byName","options":"delay_seconds"},"properties":[{"id":"unit","value":"s"}]}]}}

The JSON demonstrates a classic byName matcher and unit property only. It is not a complete dashboard or a tested Grafana override.

A friendly label must preserve the underlying state

Value mappings can present selected values, ranges, regex matches, or special states using readable text and colors under supported options. Map a genuine zero delay to an on-time label only when the measurement contract supports that meaning. Null, stale data, and query error are different states and should not all become healthy. A regex over a textual field does not establish data correctness or sanitize a private payload. Retain a way to inspect the original value and type during diagnosis. Mappings can improve comprehension while still hiding distinctions if designed carelessly.

Display thresholds are not alert rules

Absolute thresholds compare against values in the field’s measurement scale. Percentage-based display modes depend on configured or computed range semantics, not automatically on percentiles or a service error percentage. The offline classifier demonstrates synthetic absolute boundaries and an explicit unknown state. It is not Grafana’s threshold implementation and prescribes no transit policy. A color change does not send a notification by itself. If an alert must use the same conceptual boundary, define and test its supported query and evaluation separately rather than assuming panel configuration controls the server-side rule.

python Offline display-boundary fixture
def display_band(delay):
    if delay is None:
        return "unknown"
    if delay < 10:
        return "normal"
    return "warning" if delay < 30 else "critical"
for value in (9, 10, 30, None):
    print(value, display_band(value))
Expected output
9 normal
10 warning
30 critical
None unknown

The synthetic cutoffs test lower-bound transitions only. No Grafana mapping, threshold renderer, or alert rule is executed.

Verify interaction and accessibility

Test normal, boundary, extreme, zero, null, renamed, and unexpectedly typed fields. Review defaults, overrides, mapping, unit, reducer, and visualization together because their interaction determines the result. Provide text or another accessible cue where color carries important status. Keep raw evidence available through the authorized source path without exposing private values in links. This lesson runs only a local classifier and checks no Grafana version, matcher precedence, schema, or rendering. The fragment and references describe the selected baseline, leaving actual UI and plugin behavior for a separate authorized integration.

Common errors and fixes

A regex override changes a count into seconds

Why it happens
The matcher selects more fields than intended.
How to fix it
Inspect actual field identity and narrow the rule.
Prevent it next time
Test renamed and similarly named fields.

Null is mapped to normal

Why it happens
Unknown evidence was merged with a healthy measurement.
How to fix it
Preserve a separate unavailable state.
Prevent it next time
Include missing and stale cases in review.

A red panel is assumed to send a page

Why it happens
Display thresholds were confused with alert evaluation.
How to fix it
Define the independent alert rule and delivery path.
Prevent it next time
Verify presentation and notifications separately.

Check your understanding

1. Why can an exact field-name override fail after a data-source migration?

Show worked solution

The field may be renamed, split into several frames, or expose a different name and label structure. The rule can stop matching or target another field. Compare the actual output contract and supported matcher semantics before changing display settings, and preserve a known-value fixture for the intended duration.

2. Can a percentage display threshold be treated as p95 or as an error-budget target?

Show worked solution

No. Its meaning depends on the field and range configuration. A percentile and an event ratio require their own valid source or query calculations. Document the quantity first, then choose the display rule, and keep any alert threshold independently defined and tested.

Key takeaways

  • Overrides select fields rather than redefine measurements.
  • Mappings and thresholds must preserve unknown states.
  • Display rules and alert rules are separate contracts.

Official references