alloy icon indicating copy to clipboard operation
alloy copied to clipboard

Formatting of local.file in format function does not return the string contents

Open ResuBaka opened this issue 1 year ago • 0 comments

What's wrong?

When you try to use the format function to crate a new string and one of the arguments is the contents of the local.file you get something like this back {%!s(bool=false) contents_of_the_file}:15692 when you use format("%s:%s", local.file.file.content, "15692"). This does not happen when you use for example join to combine both strings.

Steps to reproduce

Crate a alloy config which locks something like this as added below.

System information

No response

Software version

Grafana Alloy 1.3.0

Configuration

local.file "instance_id" {
  filename  = "/etc/alloy/instance_id.txt"
}

prometheus.scrape "default" {
  targets    = [
    {"__address__" = "127.0.0.1:15692", "instance" = format("%s:%s", local.file.instance_id.content, "15692")},
  ]
  forward_to = [prometheus.remote_write.default.receiver]
  scrape_interval = "15s"
}

Logs

No response

ResuBaka avatar Aug 14 '24 06:08 ResuBaka