Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add yaml_decode function to stdlib #42

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

djcode
Copy link

@djcode djcode commented Feb 5, 2024

River/Grafana Agent has the ability to parse json via the json_decode function.
This PR adds the same functionality for yaml files.

@wildum
Copy link
Contributor

wildum commented Feb 8, 2024

Thanks for adding this, it looks good to me :) Could you just add some tests under vm/vm_stdlb_test.go please?

@wildum
Copy link
Contributor

wildum commented Feb 8, 2024

Note: I tried locally to extract targets from a local yaml file and it worked well:

targets:
  - __address__: "localhost:9001"
  - __address__: "localhost:12345"
local.file "default" {
  filename = "../Downloads/example_yaml_file.yaml"
}

prometheus.scrape "scrape_prom_metrics" {
  targets = yaml_decode(local.file.default.content).targets
  forward_to = [prometheus.remote_write.scrape_prom_metrics.receiver]
}

@djcode
Copy link
Author

djcode commented Apr 12, 2024

With the move of River under the Alloy repo, do I need to resubmit this PR? Will this also be moved over and merged?

@wildum
Copy link
Contributor

wildum commented Apr 22, 2024

Sorry I thought this PR was already merged. If you don't mind then yes you can move it to Alloy else I can also do it for you

@mattdurham
Copy link
Collaborator

Do you want to move this to the Alloy repo? If not we can do it for you since its a pretty good feature to have in Alloy.

@djcode
Copy link
Author

djcode commented May 23, 2024

@mattdurham More than happy for you to move it to alloy for me.
I've been inundated with personal distractions recently and haven't had a chance to play with alloy yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants