summaryrefslogtreecommitdiff
path: root/f3s/prometheus/patch-datasources.sh
blob: dc18ae3eb3755f21114fb2fab63bd3cab6207039 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# Patches the Grafana datasource ConfigMap to add Loki and Tempo with correct field order

cat > /tmp/datasource-complete.yaml << 'YAML'
apiVersion: 1
datasources:
- name: "Prometheus"
  type: prometheus
  uid: prometheus
  url: http://prometheus-kube-prometheus-prometheus.monitoring:9090/
  access: proxy
  isDefault: true
  jsonData:
    httpMethod: POST
    timeInterval: 30s
- name: "Alertmanager"
  type: alertmanager
  uid: alertmanager
  url: http://prometheus-kube-prometheus-alertmanager.monitoring:9093/
  access: proxy
  jsonData:
    handleGrafanaManagedAlerts: false
    implementation: prometheus
- name: Loki
  type: loki
  uid: loki
  url: http://loki.monitoring.svc.cluster.local:3100
  access: proxy
  isDefault: false
  editable: false
- name: Tempo
  type: tempo
  uid: tempo
  url: http://tempo.monitoring.svc.cluster.local:3200
  access: proxy
  isDefault: false
  editable: false
  jsonData:
    httpMethod: GET
    tracesToLogsV2:
      datasourceUid: loki
      spanStartTimeShift: -1h
      spanEndTimeShift: 1h
    tracesToMetrics:
      datasourceUid: prometheus
    serviceMap:
      datasourceUid: prometheus
    nodeGraph:
      enabled: true
    search:
      hide: false
    lokiSearch:
      datasourceUid: loki
YAML

kubectl create configmap prometheus-kube-prometheus-grafana-datasource \
  --from-file=datasource.yaml=/tmp/datasource-complete.yaml \
  -n monitoring \
  --dry-run=client -o yaml | kubectl apply -f -

rm /tmp/datasource-complete.yaml