forked from sassoftware/viya4-monitoring-kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatch-prometheus.sh
executable file
·52 lines (46 loc) · 1.57 KB
/
patch-prometheus.sh
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
#!/bin/sh
set -e
# Namespace of the Prometheus custom resource
MON_NS=${MON_NS:-monitoring}
# Name of the Prometheus custom resource
PROM_NAME=${PROM_NAME:-v4m-prometheus}
# Set PROM_PATH if using path-based ingress (e.g. PROM_PATH=/prometheus/)
PROM_PATH=${PROM_PATH:-/}
# Stackdriver Prometheus sidecar version
# https://console.cloud.google.com/gcr/images/stackdriver-prometheus/GLOBAL/stackdriver-prometheus-sidecar
GKE_SIDECAR_VERSION=${SIDECAR_VERSION:-0.10.0}
# Required user inputs
if [ "$GCP_PROJECT" == "" ]; then
echo "ERROR: GCP_PROJECT must be set"
exit 1
fi
if [ "$GCP_REGION" == "" ]; then
echo "ERROR: GCP_REGION must be set"
exit 1
fi
if [ "$GKE_CLUSTER" == "" ]; then
echo "ERROR: GKE_CLUSTER must be set"
exit 1
fi
kubectl -n "$MON_NS" patch prometheus "$PROM_NAME" --type merge --patch "
spec:
containers:
- name: sidecar
image: gcr.io/stackdriver-prometheus/stackdriver-prometheus-sidecar:$GKE_SIDECAR_VERSION
imagePullPolicy: Always
args:
- \"--stackdriver.project-id=$GCP_PROJECT\"
- \"--prometheus.wal-directory=/data/wal\"
- \"--stackdriver.kubernetes.location=$GCP_REGION\"
- \"--stackdriver.kubernetes.cluster-name=$GKE_CLUSTER\"
- \"--prometheus.api-address=http://127.0.0.1:9090$PROM_PATH\"
- \"--include={__name__!~'.*:.*',__name__!='',job!='kube-state-metrics'}\"
- \"--include={job='kube-state-metrics',__name__!~'.+_labels',__name__!~'.+_info'}\"
ports:
- name: sidecar
containerPort: 9091
volumeMounts:
- mountPath: /data
name: prometheus-$PROM_NAME-db
subPath: prometheus-db
"