# Grafana datasource provisioning for Loki, Tempo, and QuestDB
# Apply via: kubectl apply -f grafana-datasources.yaml && kubectl rollout restart deploy/grafana -n foxhunt
apiVersion: v1
kind: ConfigMap
metadata:
  name: grafana-datasources-extra
  namespace: foxhunt
  labels:
    app.kubernetes.io/name: grafana
    grafana_datasource: "1"
data:
  loki-tempo.yaml: |
    apiVersion: 1
    datasources:
      - name: Loki
        type: loki
        access: proxy
        url: http://loki.foxhunt.svc.cluster.local:3100
        isDefault: false
        jsonData:
          derivedFields:
            - datasourceUid: tempo
              matcherRegex: '"trace_id":"(\w+)"'
              name: TraceID
              url: "$${__value.raw}"
      - name: Tempo
        type: tempo
        uid: tempo
        access: proxy
        url: http://tempo.foxhunt.svc.cluster.local:3200
        isDefault: false
        jsonData:
          tracesToLogsV2:
            datasourceUid: loki
            filterByTraceID: true
          nodeGraph:
            enabled: true
          serviceMap:
            datasourceUid: prometheus
  questdb.yaml: |
    apiVersion: 1
    datasources:
      - name: QuestDB
        type: postgres
        uid: questdb
        access: proxy
        url: questdb.foxhunt.svc.cluster.local:8812
        user: admin
        database: qdb
        isDefault: false
        jsonData:
          sslmode: disable
          maxOpenConns: 5
          postgresVersion: 1200
          timescaledb: false
        secureJsonData:
          password: quest
