Skip to content

Conversation

@esensar
Copy link
Contributor

@esensar esensar commented Jul 25, 2025

Summary

Adds 3 new functions: get_vector_metric, find_vector_metrics and aggregate_vector_metrics, enabling access to current Vector metrics (with some delay, to reduce locking).

Vector configuration

api:
  enabled: true
  address: "0.0.0.0:8686"

metrics_storage_refresh_period: 1

sources:
  demo_logs:
    type: demo_logs
    format: "json"

transforms:
  remap_vrl_metrics:
    type: remap
    inputs: ["demo_logs"]
    source: |
      .utilization = find_vector_metrics("utilization", tags: { "component_id": "console" })
      .utilization_sum = aggregate_vector_metrics("sum", "utilization")
      .utilization_avg = aggregate_vector_metrics("avg", "utilization")
      .utilization_min = aggregate_vector_metrics("min", "utilization")
      .utilization_max = aggregate_vector_metrics("max", "utilization")

sinks:
  console:
    inputs: ["remap_vrl_metrics"]
    type: console
    encoding:
      codec: json

How did you test this PR?

Ran Vector with the above configuration.

Change Type

  • Bug fix
  • New feature
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the no-changelog label to this PR.

References

Notes

  • Please read our Vector contributor resources.
  • Do not hesitate to use @vectordotdev/vector to reach out to us regarding this PR.
  • Some CI checks run only after we manually approve them.
    • We recommend adding a pre-push hook, please see this template.
    • Alternatively, we recommend running the following locally before pushing to the remote branch:
      • cargo fmt --all
      • cargo clippy --workspace --all-targets -- -D warnings
      • cargo nextest run --workspace (alternatively, you can run cargo test --all)
  • After a review is requested, please avoid force pushes to help us review incrementally.
    • Feel free to push as many commits as you want. They will be squashed into one before merging.
    • For example, you can run git merge origin master and git push.
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please
    run cargo vdev build licenses to regenerate the license inventory and commit the changes (if any). More details here.

Sponsored by Quad9

Adds 2 new functions: `get_vector_metric` and `find_vector_metrics`, enabling access to current
Vector metrics (with some delay, to reduce locking).

Closes: vectordotdev#23284
@github-actions github-actions bot added domain: topology Anything related to Vector's topology code domain: sources Anything related to the Vector's sources domain: transforms Anything related to Vector's transform components domain: sinks Anything related to the Vector's sinks domain: core Anything related to core crates i.e. vector-core, core-common, etc labels Jul 25, 2025
@esensar
Copy link
Contributor Author

esensar commented Jul 25, 2025

@pront this is still not done (I need to implement filtering by tags and maybe aggregation too), but I wanted to check if the way this global metrics cache is plugged into the topology looks alright to you.

@esensar
Copy link
Contributor Author

esensar commented Aug 6, 2025

@pront
Just checking if you had time to look at this one.

@pront
Copy link
Member

pront commented Aug 6, 2025

@pront Just checking if you had time to look at this one.

Hi @esensar, no we tend to not review draft PRs. In the future if you want us to take look please mark it as "ready for review" and ping @vectordotdev/vector

@esensar
Copy link
Contributor Author

esensar commented Aug 6, 2025

@pront Just checking if you had time to look at this one.

Hi @esensar, no we tend to not review draft PRs. In the future if you want us to take look please mark it as "ready for review" and ping @vectordotdev/vector

Oh, sorry about that. I left it as a draft because it is not really complete. It is missing the additional function arguments, for filtering by tags and similar, but I was wondering if the way I hooked up the metrics storage with the topology was alright. I can add these missing arguments and finalize the functions if you would prefer that to be done first.

@pront
Copy link
Member

pront commented Aug 6, 2025

@pront Just checking if you had time to look at this one.

Hi @esensar, no we tend to not review draft PRs. In the future if you want us to take look please mark it as "ready for review" and ping @vectordotdev/vector

Oh, sorry about that. I left it as a draft because it is not really complete. It is missing the additional function arguments, for filtering by tags and similar, but I was wondering if the way I hooked up the metrics storage with the topology was alright. I can add these missing arguments and finalize the functions if you would prefer that to be done first.

No problem. Just to manage expectations, I don't think we have enough time to put in this release. But will prioritize it for the next one.

@esensar
Copy link
Contributor Author

esensar commented Aug 6, 2025

Oh, sorry about that. I left it as a draft because it is not really complete. It is missing the additional function arguments, for filtering by tags and similar, but I was wondering if the way I hooked up the metrics storage with the topology was alright. I can add these missing arguments and finalize the functions if you would prefer that to be done first.

No problem. Just to manage expectations, I don't think we have enough time to put in this release. But will prioritize it for the next one.

Yeah, understood, that is fine. I am pretty sure I won't have it ready for the release anyways.

@esensar esensar marked this pull request as ready for review October 29, 2025 10:46
@esensar esensar requested a review from a team as a code owner October 29, 2025 10:46
@esensar esensar requested a review from a team as a code owner October 29, 2025 11:29
@github-actions github-actions bot added the domain: external docs Anything related to Vector's external, public documentation label Oct 29, 2025
Copy link
Contributor

@thomasqueirozb thomasqueirozb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I merged master and resolved the conflicts but it seems like tests are failing (and have been even before my changes). I'll circle back to this PR once I see new commits pushed

@thomasqueirozb thomasqueirozb added the meta: awaiting author Pull requests that are awaiting their author. label Dec 23, 2025
@github-actions github-actions bot removed the meta: awaiting author Pull requests that are awaiting their author. label Dec 23, 2025
@esensar
Copy link
Contributor Author

esensar commented Dec 23, 2025

I have fixed the one about using all() from vrl stdlib. Other tests passed for me.

@thomasqueirozb
Copy link
Contributor

thomasqueirozb commented Dec 23, 2025

Other tests passed for me.

cd lib/vector-vrl-metrics && cargo nextest run is failing for me. Letting CI run to see if it's replicable.

@thomasqueirozb
Copy link
Contributor

Looks like tests are failing in the CI also, not sure if something is different with your local environment that is making these tests pass.

@thomasqueirozb thomasqueirozb added the meta: awaiting author Pull requests that are awaiting their author. label Dec 23, 2025
@github-actions github-actions bot removed the meta: awaiting author Pull requests that are awaiting their author. label Dec 23, 2025
Copy link
Contributor

@thomasqueirozb thomasqueirozb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go! I'll enable auto merge and you can resolve all comments if you think no changes are necessary

@thomasqueirozb
Copy link
Contributor

It actually looks like playground is failing. I think that maybe we need to omit this new crate from vector_vrl_functions::all on wasm

@esensar
Copy link
Contributor Author

esensar commented Dec 24, 2025

It actually looks like playground is failing. I think that maybe we need to omit this new crate from vector_vrl_functions::all on wasm

Yeah, I did that. It should be working now (it worked locally 😄 -- wasm-pack build --target web --out-dir public/pkg in lib/vector-vrl/web-playground).

@esensar esensar requested a review from thomasqueirozb January 5, 2026 09:40
@thomasqueirozb
Copy link
Contributor

thomasqueirozb commented Jan 5, 2026

Hey @esensar, apologies for the delay - I was off for the last two weeks. Everything looks fine. Deny is failing due to an unrelated reason which I'll fix in another PR. This is good to go and I'll enable auto merge once deny is fixed, the only thing you'll need to do is to resolve all comments

@thomasqueirozb thomasqueirozb added this pull request to the merge queue Jan 7, 2026
Merged via the queue into vectordotdev:master with commit acd4a73 Jan 7, 2026
50 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 7, 2026
@esensar esensar deleted the feature/vrl-metrics-access branch January 7, 2026 09:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

domain: core Anything related to core crates i.e. vector-core, core-common, etc domain: external docs Anything related to Vector's external, public documentation domain: sinks Anything related to the Vector's sinks domain: sources Anything related to the Vector's sources domain: topology Anything related to Vector's topology code domain: transforms Anything related to Vector's transform components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make prometheus values available in VRL

4 participants