← Back to Pull requests

enhancement(remap transform): read metric values in VRL #27264

Closed
unknown closed this pull request without merging on Nov 20, 2026 21:57 UTC
View on GitHub
unknown unknown commented on Nov 18, 2026 22:04 UTC
Author

Summary

VRL can't read a metric's value today: .gauge.value reads as null.

The value is already part of the event. Vector stores it as a MetricValue, and the JSON encoding (used by vector tap, the console sink's json codec, and unit test output) writes it under the type's key, such as "gauge":{"value":123.0}. But VRL doesn't read the Metric directly. It reads a view built by VrlTarget, which only exposes name, namespace, kind, type, timestamp, interval_ms, and tags. Any other path is rejected as invalid, and VRL turns that error into null. So the output shows the value while VRL reads null, 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 tap shows. 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 .counter on a gauge | null, so exists(.counter) is false |
| 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 as null and exists() is false, unlike a sum of 0 |
| After .type converts 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 as del(.gauge.value), will stay unsupported because a metric always has a value.

Reading . on a metric now includes the value field, so encode_json(.) on metrics changes, and unnest copies 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 scaled tag with its value times 100, for example "scaled":"10000" for a gauge of 100.0. On master, exists(.gauge) is false, so the example skips the assignment.

sources:
  metrics:
    type: internal_metrics

transforms:
  scale:
    type: remap
    inputs: [metrics]
    source: |
      if exists(.gauge) {
        .tags.scaled = to_string(float!(.gauge.value) * 100)
      }

sinks:
  out:
    type: console
    inputs: [scale]
    encoding:
      codec: json

How did you test this PR?

  • Unit tests in vrl_target.rs for every metric type, special values (NaN, infinity, very large counts), type conversion, and that assigning or deleting leaves the value unchanged.

  • remap and VRL condition tests that read values from real metric events, including unnest! on .distribution.samples.

  • A vector test unit test based on #14853: log_to_metric produces a gauge and assert_eq!(.gauge.value, 123.0) passes. It fails on master with null == 123.

  • Ran the configuration above locally and checked the scaled tags in the output.
  • Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.

  • For a new deprecation announcement, follow the deprecation policy and add a deprecation.d/ notice instead.
  • No. A maintainer will apply the no-changelog label to this PR.
  • Diff: 527 lines (+395 / -132) across 6 files Reviewer: pront Review duration: 2873m
    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
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.8% (MEDIUM) · Higher = larger blast radius
    47.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.9% · Safe to merge
    18.9%