Skip to content

syntax: Add json_encode to stdlib #152

Open
@braunsonm

Description

@braunsonm

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"
  }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

  • Status

    Accepted

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions