Skip to content

Commit

Permalink
Use kube-prometheus-stack for monitoring with Prometheus
Browse files Browse the repository at this point in the history
  • Loading branch information
Process-ing committed Sep 19, 2024
1 parent 7fe1e44 commit 99362e1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
25 changes: 17 additions & 8 deletions services/grafana/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,24 @@
port=8080

helm repo add grafana https://grafana.github.io/helm-charts # Add Grafana Helm chart
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts # Add Prometheus Helm chart
helm repo update
kubectl create namespace loki
helm upgrade --install --namespace loki logging grafana/loki -f $(dirname $0)/loki-values.yaml --set loki.auth_enabled=false --set loki.useTestSchema=true # Install Loki

kubectl create namespace monitoring
helm upgrade --install --namespace monitoring loki grafana/loki -f $(dirname $0)/loki-values.yaml --set loki.auth_enabled=false --set loki.useTestSchema=true # Install Loki
# TODO: Stop using test schema
# TODO (maybe): Use auth
helm upgrade --install --namespace loki loki-grafana grafana/grafana -f $(dirname $0)/grafana-values.yaml # Install Grafana
sleep 10 # TODO: Wait for pods
export POD_NAME=$(kubectl get pods --namespace loki -l "app.kubernetes.io/name=grafana,app.kubernetes.io/instance=loki-grafana" -o jsonpath="{.items[0].metadata.name}")
kubectl --namespace loki wait --for=condition=ready pods/$POD_NAME --timeout=300s
kubectl --namespace loki port-forward $POD_NAME $port:3000 &
# helm upgrade --install --namespace monitoring loki-grafana grafana/grafana -f $(dirname $0)/grafana-values.yaml # Install Grafana
# sleep 10 # TODO: Wait for pods
# export POD_NAME=$(kubectl get pods --namespace loki -l "app.kubernetes.io/name=grafana,app.kubernetes.io/instance=loki-grafana" -o jsonpath="{.items[0].metadata.name}")
# kubectl --namespace loki wait --for=condition=ready pods/$POD_NAME --timeout=300s
# kubectl --namespace loki port-forward $POD_NAME $port:3000 &

# echo "Admin password:" $(kubectl get secret --namespace loki loki-grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo)

echo "Admin password:" $(kubectl get secret --namespace loki loki-grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo)
helm install kube-prometheus prometheus-community/kube-prometheus-stack --namespace monitoring -f $(dirname $0)/prometheus-config.yaml

sleep 10 # TODO: Wait for pods
POD_NAME=$(kubectl get pods --namespace monitoring -l "app.kubernetes.io/name=grafana" -o jsonpath="{.items[0].metadata.name}")
kubectl --namespace monitoring wait --for=condition=ready pods/$POD_NAME --timeout=300s
kubectl --namespace monitoring port-forward service/kube-prometheus-grafana $port:80 &
12 changes: 12 additions & 0 deletions services/grafana/prometheus-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
grafana:
enabled: true
adminPassword: tosta-mista-789 # TODO: Change password

aditionalDataSources:
- name: Loki
type: loki
# basicAuth: true
# basicAuthUser: ni
# basicAuthPassword: pass # TODO: Change password
url: http://logging-loki-gateway.loki.svc.cluster.local
isDefault: true

0 comments on commit 99362e1

Please sign in to comment.