From 22ea077a168a1d276b28bf1448bb81c0ee8c31e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rcio=20Fernandes?= Date: Tue, 9 Dec 2025 01:15:43 +0000 Subject: [PATCH] vector: added extra labels --- roles/vector/defaults/main.yml | 3 ++- roles/vector/templates/vector.yaml.j2 | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) 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