diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 97fdfb940..2226788ff 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1483,6 +1483,11 @@ deploy: [grafana-dashboards-infra]="cluster-overview.json gpu-overview.json foxhunt-gpu-training.json foxhunt-infrastructure.json" [grafana-dashboards-cicd]="foxhunt-ci-pipelines.json gitlab-services.json" ) + declare -A FOLDERS=( + [grafana-dashboards-foxhunt]="Foxhunt" + [grafana-dashboards-infra]="Infrastructure" + [grafana-dashboards-cicd]="CI/CD" + ) for cm_name in "${!GROUPS[@]}"; do args="" for df in ${GROUPS[$cm_name]}; do @@ -1492,8 +1497,9 @@ deploy: kubectl create configmap "$cm_name" -n foxhunt $args \ --dry-run=client -o yaml | \ kubectl label -f - --dry-run=client -o yaml --local grafana_dashboard=1 | \ + kubectl annotate -f - --dry-run=client -o yaml --local grafana_folder="${FOLDERS[$cm_name]}" | \ kubectl apply -f - - echo " Applied ConfigMap: $cm_name" + echo " Applied ConfigMap: $cm_name (folder: ${FOLDERS[$cm_name]})" fi done rm -rf "$TMP_DIR" diff --git a/infra/k8s/monitoring/dashboards/import.sh b/infra/k8s/monitoring/dashboards/import.sh index d67e8d3b1..31f693ef5 100755 --- a/infra/k8s/monitoring/dashboards/import.sh +++ b/infra/k8s/monitoring/dashboards/import.sh @@ -128,6 +128,13 @@ declare -A CONFIGMAP_GROUPS=( [grafana-dashboards-cicd]="foxhunt-ci-pipelines.json gitlab-services.json" ) +# Folder mapping: ConfigMap name -> Grafana folder name (used by sidecar annotation) +declare -A CONFIGMAP_FOLDERS=( + [grafana-dashboards-foxhunt]="Foxhunt" + [grafana-dashboards-infra]="Infrastructure" + [grafana-dashboards-cicd]="CI/CD" +) + deploy_configmaps() { echo "" echo "Deploying dashboard ConfigMaps..." @@ -148,13 +155,14 @@ import json, os tmp = '${tmp_dir}' ns = '${KUBE_NAMESPACE}' groups = ${CONFIGMAP_GROUPS_JSON} +folders = ${CONFIGMAP_FOLDERS_JSON} items = [] for name, files in groups.items(): cm = { 'apiVersion': 'v1', 'kind': 'ConfigMap', - 'metadata': {'name': name, 'namespace': ns, 'labels': {'grafana_dashboard': '1'}}, + 'metadata': {'name': name, 'namespace': ns, 'labels': {'grafana_dashboard': '1'}, 'annotations': {'grafana_folder': folders.get(name, '')}}, 'data': {} } for f in files: @@ -187,6 +195,17 @@ done CONFIGMAP_GROUPS_JSON+='}' export CONFIGMAP_GROUPS_JSON +# Export folders as JSON for python +CONFIGMAP_FOLDERS_JSON='{' +first=true +for name in "${!CONFIGMAP_FOLDERS[@]}"; do + $first || CONFIGMAP_FOLDERS_JSON+=',' + CONFIGMAP_FOLDERS_JSON+="\"${name}\":\"${CONFIGMAP_FOLDERS[${name}]}\"" + first=false +done +CONFIGMAP_FOLDERS_JSON+='}' +export CONFIGMAP_FOLDERS_JSON + # --- Deploy --- failed=0