diff --git a/roles/vector/defaults/main.yml b/roles/vector/defaults/main.yml index b8f39ca..a7c3b91 100644 --- a/roles/vector/defaults/main.yml +++ b/roles/vector/defaults/main.yml @@ -6,4 +6,5 @@ vector_config: journald: enbled: true loki: - address: "" \ No newline at end of file + address: "" + extra_labels: \ No newline at end of file diff --git a/roles/vector/templates/vector.yaml.j2 b/roles/vector/templates/vector.yaml.j2 index 37fc01a..6dfc1ba 100644 --- a/roles/vector/templates/vector.yaml.j2 +++ b/roles/vector/templates/vector.yaml.j2 @@ -13,7 +13,11 @@ transforms: .process = ._COMM .priority = .PRIORITY .host = "{{ vector_config.hostname }}" - +{% if vector_config.extra_labels is defined and vector_config.extra_labels|length > 0 %} +{% for src in vector_config.extra_labels %} + {{ src.name }} = "{{ src.value }}" +{% endfor %} +{% endif %} sinks: loki: type: loki @@ -31,4 +35,9 @@ sinks: unit: "{{ .unit }}" process: "{{ .process }}" priority: "{{ .priority }}" -{% endraw %} \ No newline at end of file +{% endraw %} +{% if vector_config.extra_labels is defined and vector_config.extra_labels|length > 0 %} +{% for src in vector_config.extra_labels %} + {{ src.label }}: "{% raw %}{{ {% endraw %}{{ src.name }}{% raw %} }}{% endraw %}" +{% endfor %} +{% endif %} \ No newline at end of file