grafana / alloy

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

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

Open ResuBaka opened 3 months ago

ResuBaka commented 3 months ago

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

github-actions[bot] commented 2 months 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!