How do I get the hostname added as a label when using “static_config”? I have tried starting promtail with --client.external-labels=hostname=$(hostname) but I couldn’t get that to work. Can anyone post their config?
Maybe I’m missing something but that doesn’t mention how to add the hostname without explicitly adding it.
host: yourhost # A `host` label will help identify logs from this machine vs others
‘yourhost’ I would need to replace this with the actual hostname manually. Is there not a way to use $HOSTNAME or something else? I know for the journal you can use __journal__hostname but I can’t figure out how to to use that when using static_configs.
I could generate the configs but what I’m trying to do is documented with both --client.external-labels and --config.expand-env=true. I can’t get either one to work and I can only imagine someone else out there is doing this.
At this point I’m planning on generating each devices config which now adds a bit more complexity. I have over 3k devices that this will be running on and having to generate the configs just because I can’t get the hostname added in seems silly.
If you’re using the helm chart like me. Use the suggested way in the chart to do it. It’s a bit hidden in the values file here it’s quite similar to the solution but capitalizied. I think it takes the env variable HOSTNAME from the pod nodeName field.