grafana / alloy

OpenTelemetry Collector distribution with programmable pipelines
https://grafana.com/oss/alloy
Apache License 2.0
1k stars 101 forks source link

syntax: Add `json_encode` to stdlib #152

Open braunsonm opened 11 months ago

braunsonm commented 11 months ago

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 = {
    ...
    }
  })

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

  target "grafana" {
    address = "http://grafana.com"
    module  = "http_2xx"
  }
}
rfratto commented 11 months ago

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

github-actions[bot] commented 1 month ago

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!