From 471f27eba4a189dc3922ab05f0bd0441d6d88605 Mon Sep 17 00:00:00 2001
From: "Antoine R. Dumont (@ardumont)" <ardumont@softwareheritage.org>
Date: Tue, 16 May 2023 15:11:39 +0200
Subject: [PATCH] opentelemetry: Unify index names in environments

- {staging,production}-swh-logs
- {staging,production}-system-logs

This will fix the misnaming in production [1]. The data stream 'logs-*-*' pattern exists
which prevented the index name to be correctly built (and historically, the staging ones
were named differently too so the issue was not detected earlier).

[1]
```
curl -s ${ES_SERVER}/_cat/indices | grep "staging\|production"
...
green open  .ds-logs-swh-production-2023.05.16-000001    OMdrZ9DXRZ2t2SP4PEhwVA 1 1  5398438      0   2.1gb     1gb
green open  .ds-logs-system-production-2023.05.16-000001 WcV164JHSgOIOWjVUddeHg 1 1
6097451      0   3.4gb     2gb
...
```

Refs. swh/infra/sysadm-environment#4524
---
 .../templates/otlp-collector/_collector.tpl                  | 4 ++--
 cluster-configuration/values/archive-production-rke2.yaml    | 3 ---
 cluster-configuration/values/archive-staging-rke2.yaml       | 5 -----
 3 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/cluster-configuration/templates/otlp-collector/_collector.tpl b/cluster-configuration/templates/otlp-collector/_collector.tpl
index 30ceb95dd..8909adbdf 100644
--- a/cluster-configuration/templates/otlp-collector/_collector.tpl
+++ b/cluster-configuration/templates/otlp-collector/_collector.tpl
@@ -3,8 +3,8 @@
 # in the argocd application defined in application.yaml
 {{ if .Values.otlpCollector.enabled -}}
 {{- $environment := get .Values "environment" }}
-{{- $logs_swh := .Values.otlpCollector.indexes.swh | default ( print "logs-swh-" $environment ) -}}
-{{- $logs_system := .Values.otlpCollector.indexes.system | default ( print "logs-system-" $environment ) -}}
+{{- $logs_swh := .Values.otlpCollector.indexes.swh | default ( print $environment "-swh-logs" ) -}}
+{{- $logs_system := .Values.otlpCollector.indexes.system | default ( print $environment "-system-logs" ) -}}
 {{- $activate_debug := .Values.otlpCollector.debug -}}
 ---
 mode: daemonset
diff --git a/cluster-configuration/values/archive-production-rke2.yaml b/cluster-configuration/values/archive-production-rke2.yaml
index 475bfc7a2..e423e136e 100644
--- a/cluster-configuration/values/archive-production-rke2.yaml
+++ b/cluster-configuration/values/archive-production-rke2.yaml
@@ -23,9 +23,6 @@ certManager:
 otlpCollector:
   enabled: true
   debug: false
-  indexes:
-    swh: logs-swh-production
-    system: logs-system-production
   resources:
     cpu: 1024m
     memory: 16Gi
diff --git a/cluster-configuration/values/archive-staging-rke2.yaml b/cluster-configuration/values/archive-staging-rke2.yaml
index 4551dc090..d69238b65 100644
--- a/cluster-configuration/values/archive-staging-rke2.yaml
+++ b/cluster-configuration/values/archive-staging-rke2.yaml
@@ -23,11 +23,6 @@ certManager:
 otlpCollector:
   enabled: true
   debug: false
-  indexes:
-    # misnamed: should be logs-{swh,system}-staging, kept for retro compatibility with
-    # development tryouts
-    swh: staging-logs
-    system: staging-system-logs
   resources:
     cpu: 256m
     memory: 2Gi
-- 
GitLab