From a451c320327f1e6a4da842a0e583179176d4691d Mon Sep 17 00:00:00 2001 From: Bodo Schulz Date: Sat, 13 Jul 2024 13:07:57 +0200 Subject: [PATCH] fix loki --- .../templates/loki/loki.d/storage_config.j2 | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/roles/loki/templates/loki/loki.d/storage_config.j2 b/roles/loki/templates/loki/loki.d/storage_config.j2 index 78915c6..7f09149 100644 --- a/roles/loki/templates/loki/loki.d/storage_config.j2 +++ b/roles/loki/templates/loki/loki.d/storage_config.j2 @@ -208,14 +208,22 @@ storage_config: {% endfor %} {% if loki_config_storage.boltdb_shipper.index_gateway_client is defined and loki_config_storage.boltdb_shipper.index_gateway_client | count > 0 %} - index_gateway_client: - {% if loki_config_storage.boltdb_shipper.index_gateway_client.server_address is defined and - loki_config_storage.boltdb_shipper.index_gateway_client.server_address | string | length > 0 %} - server_address: {{ loki_config_storage.boltdb_shipper.index_gateway_client.server_address }} - {% endif %} - {% if loki_config_storage.boltdb_shipper.index_gateway_client.log_gateway_requests is defined %} - log_gateway_requests: {{ loki_config_storage.boltdb_shipper.index_gateway_client.log_gateway_requests | bool | bodsch.core.config_bool(true_as='true', false_as='false') }} + {% set valid_keys = [ + "server_address", + "log_gateway_requests"] %} + {% if loki_main_version is version_compare("2.5", operator='>') %} + {% set indx = valid_keys.index('log_gateway_requests') %} + {% set _ = valid_keys.pop(indx) %} {% endif %} + index_gateway_client: + {% for key, v in loki_config_querier.items() %} + {% if key in valid_keys %} + {% set value = v | bodsch.grafana.loki_value %} + {% if value %} + {{ key }}: {{ value }} + {% endif %} + {% endif %} + {% endfor %} {% if loki_config_storage.boltdb_shipper.index_gateway_client.grpc_client_config is defined and loki_config_storage.boltdb_shipper.index_gateway_client.grpc_client_config | count > 0 %} grpc_client_config: