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

syntax: Add json_encode to stdlib #152

Open
braunsonm opened this issue Jul 25, 2023 · 9 comments · May be fixed by #2860
Open

syntax: Add json_encode to stdlib #152

braunsonm opened this issue Jul 25, 2023 · 9 comments · May be fixed by #2860
Assignees
Labels
enhancement New feature or request needs-attention proposal A proposal for new functionality. type/syntax Alloy configuration syntax issues

Comments

@braunsonm
Copy link

braunsonm commented Jul 25, 2023

Request

Add a function to the standard library similar to json_decode but in the reverse direction. Taking a map type and encoding to a string.

Use case

In order to configure the embedded blackbox, it would be nice to be able to use the powerful features of Alloy syntax while providing the inline configuration.

prometheus.exporter.blackbox "example" {
  config = json_encode({
    modules = {
      http_2xx = {
        prober = "http"
        http = {
          headers = {
            "Authorization" = sys.env("HTTP_AUTH_HEADER")
          }
        }
      }
    }
  })

  target "example" {
    address = "http://example.com"
    module  = "http_2xx"
  }

  target "grafana" {
    address = "http://grafana.com"
    module  = "http_2xx"
  }
}
@braunsonm braunsonm added the enhancement New feature or request label Jul 25, 2023
@rfratto
Copy link
Member

rfratto commented Jul 27, 2023

Interesting idea, I wouldn't be against having a json_encode function :)

@rfratto rfratto transferred this issue from grafana/agent Aug 25, 2023
@rfratto rfratto transferred this issue from grafana/river Apr 9, 2024
@rfratto rfratto changed the title Add json_encode to stdlib of River syntax: Add json_encode to stdlib Apr 9, 2024
@rfratto rfratto added the type/syntax Alloy configuration syntax issues label Apr 9, 2024
Copy link
Contributor

This issue has not had any activity in the past 30 days, so the needs-attention label has been added to it.
If the opened issue is a bug, check to see if a newer release fixed your issue. If it is no longer relevant, please feel free to close this issue.
The needs-attention label signals to maintainers that something has fallen through the cracks. No action is needed by you; your issue will be kept open and you do not have to respond to this comment. The label will be removed the next time this job runs if there is new activity.
Thank you for your contributions!

@rfratto rfratto added the proposal A proposal for new functionality. label Jun 14, 2024
@wildum
Copy link
Contributor

wildum commented Jan 20, 2025

Hi, could you expand a little bit on the use case?
The implementation should be straight forward but we don't see enough value in it for now. Moving it to "likely declined" for now. If a need for it comes up, we will move it to active

@wildum wildum moved this from Incoming to Likely Decline in Alloy proposals Jan 20, 2025
@braunsonm
Copy link
Author

@wildum What further expansion of the use case were you expecting? Blackbox requires a JSON configuration file, which right now we have to provide as a string. So it would be nice if we could use River's syntax to generate the configuration instead. This would allow calling things like sys.env etc while building the configuration.

@wildum
Copy link
Contributor

wildum commented Jan 20, 2025

This would allow calling things like sys.env etc

That's the part I was curious about. I could not see which component export would make sense here but sys.env sounds useful. Adding concrete examples to proposals helps for review. If you could update your example by adding the sys.env + other refs to Alloy values that you would find useful there, that would be great.

I move the proposal to Active and will suggest it in next week's meeting for approval

@wildum wildum moved this from Likely Decline to Active in Alloy proposals Jan 20, 2025
@braunsonm
Copy link
Author

You got it, added an example.

@wildum
Copy link
Contributor

wildum commented Feb 3, 2025

Moving to likely accepted, the limitations will need to be documented for things that cannot be converted

@wildum wildum moved this from Active to Likely Accept in Alloy proposals Feb 3, 2025
@wildum wildum moved this from Likely Accept to Accepted in Alloy proposals Feb 10, 2025
@ravishankar15
Copy link
Contributor

I would like to check on this issue. If work has not been started can we assign this to me.

@wildum wildum assigned wildum and ravishankar15 and unassigned wildum Feb 26, 2025
@wildum
Copy link
Contributor

wildum commented Feb 26, 2025

done, thanks!

@ravishankar15 ravishankar15 linked a pull request Feb 27, 2025 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs-attention proposal A proposal for new functionality. type/syntax Alloy configuration syntax issues
Projects
Status: Accepted
Development

Successfully merging a pull request may close this issue.

4 participants