-
QuestionEarly on in my use of vector I wrote a toml configuration using "{{ host }}" in my sink definitions to specify per-host log destinations. Here is one of several sinks I have: Now despite quite a bit of searching I cannot find the documentation that describes "{{ host }}" as a mechanism. Neither https://vector.dev/docs/reference/configuration/ nor https://vector.dev/docs/reference/configuration/template-syntax/ mention it. I must have read it somewhere though, and it does work. Interestingly, I asked Claude to read the docs and it thinks that "the {{ }} syntax is exclusively for referencing event data fields at runtime, not arbitrary config variables." This is clearly not strictly true because the above config is working. I am curious what the dev team's take is. I would love to see some documentation describing the complete list of "global" variables (or whatever you call them; I mean the variables that aren't event fields) that are available in the template syntax. For example, I see I am also interested to know if using the template syntax in configs is recommended, given that the documentation is confusing in this department. I'd be happy to file an issues describing more specifically where I think the docs fall short. The team has been fantastically receptive to those issues in the past and I appreciate it. I didn't do so in this case because I don't want it to seem like I'm using docs issues just to ask for help. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
I found this: Is there a list of variables for template syntax? But the central question of using the template syntax (as opposed to env var syntax) in configuration files still stands. |
Beta Was this translation helpful? Give feedback.
There are two distinct interpolation mechanisms in Vector.
Static:
$VARor${VAR}- environment variable interpolation. This happens once when Vector loads the config file, before any events are processed. More on this here: https://vector.dev/docs/reference/environment_variables/Runtime: {{field}} - template syntax. This is evaluated per-event at runtime, pulling the value of field from each individual event. More on this here: https://vector.dev/docs/reference/configuration/template-syntax/
In your Axiom example, dataset = "{{host}}-webapp" works because your journald events have a host field added automatically by the source. It would equally work as dataset = "${HOSTNAME}-webap…