enhancement(remap transform): read metric values in VRL #27264
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 527 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.375
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #27264"
general
weight: 0.35
pront
Summary
VRL can't read a metric's value today:
.gauge.valuereads asnull.The value is already part of the event. Vector stores it as a
MetricValue, and the JSON encoding (used byvector tap, theconsolesink'sjsoncodec, and unit test output) writes it under the type's key, such as"gauge":{"value":123.0}. But VRL doesn't read theMetricdirectly. It reads a view built byVrlTarget, which only exposesname,namespace,kind,type,timestamp,interval_ms, andtags. Any other path is rejected as invalid, and VRL turns that error intonull. So the output shows the value while VRL readsnull, which is the mismatch reported in #14853.This PR makes the value of every metric type readable. The top-level field matches the metric type, as in the JSON encoding that
vector tapshows. For sketches, VRL exposes summary statistics directly under.sketch.| Type | Fields |
|---|---|
| counter / gauge |
.counter.value/.gauge.value|| set |
.set.values|| distribution |
.distribution.samples([{value, rate}]),.distribution.statistic|| aggregated_histogram |
.aggregated_histogram.buckets([{upper_limit, count}]),.count,.sum|| aggregated_summary |
.aggregated_summary.quantiles([{quantile, value}]),.count,.sum|| sketch |
.sketch.count,.min,.max,.sum,.avg(bins aren't exposed) |Special cases:
| Case | Reads as |
|---|---|
| Field for another type, such as
.counteron a gauge |null, soexists(.counter)isfalse|| NaN (VRL floats can't hold NaN) | the string
"NaN"|| Infinity | a float |
| Count above
i64::MAX| an exact decimal string || Missing histogram
sum| left out, so it reads asnullandexists()isfalse, unlike a sum of0|| After
.typeconverts a counter to a gauge or back | the value under the new type's field |This is the first step for #5521 and only covers reads. Assigning to these fields or calling
del()on them doesn't change the metric's value yet. A follow-up PR will add writes, including removing array elements such as a single sample. Removing the value itself, such asdel(.gauge.value), will stay unsupported because a metric always has a value.Reading
.on a metric now includes the value field, soencode_json(.)on metrics changes, andunnestcopies the value into each row. This is described in a breaking changelog fragment, so it appears in the upgrade guide with migration examples, including how to unnest only the tags.References
Related: #5521, #14853, #8105
Vector configuration
An example that reads gauge values from Vector's internal metrics. Each gauge in the output gets a
scaledtag with its value times 100, for example"scaled":"10000"for a gauge of100.0. On master,exists(.gauge)is false, so the example skips the assignment.How did you test this PR?
vrl_target.rsfor every metric type, special values (NaN, infinity, very large counts), type conversion, and that assigning or deleting leaves the value unchanged.remapand VRL condition tests that read values from real metric events, includingunnest!on.distribution.samples.vector testunit test based on #14853:log_to_metricproduces a gauge andassert_eq!(.gauge.value, 123.0)passes. It fails on master withnull == 123.scaledtags in the output.Does this PR include user facing changes?
For a new deprecation announcement, follow the deprecation policy and add a
deprecation.d/notice instead.no-changeloglabel to this PR.