Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add grafana including example dashboard for 'podinfoes' #653

Merged
merged 2 commits into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,30 @@ uninstall-prometheus:
$(call uninstall-prometheus,$(CLUSTER_GSLB1))
$(call uninstall-prometheus,$(CLUSTER_GSLB2))

.PHONY: deploy-grafana
deploy-grafana:
@echo "\n$(YELLOW)Local cluster $(CYAN)$(CLUSTER_GSLB1)$(NC)"
@echo "\n$(YELLOW)install grafana $(NC)"
@$(eval PREVIOUS_CONTEXT := $(shell kubectl config current-context))
kubectl config use-context k3d-$(CLUSTER_GSLB1)
kubectl apply -f deploy/grafana/dashboard-cm.yaml
@kubectl config use-context $(PREVIOUS_CONTEXT)
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update
helm -n k8gb upgrade -i grafana grafana/grafana -f deploy/grafana/values.yaml \
--wait --timeout=2m0s \
--kube-context=k3d-$(CLUSTER_GSLB1)

.PHONY: uninstall-grafana
uninstall-grafana:
@echo "\n$(YELLOW)Local cluster $(CYAN)$(CLUSTER_GSLB1)$(NC)"
@echo "\n$(YELLOW)uninstall grafana $(NC)"
@$(eval PREVIOUS_CONTEXT := $(shell kubectl config current-context))
kubectl config use-context k3d-$(CLUSTER_GSLB1)
-kubectl delete -f deploy/grafana/dashboard-cm.yaml
@kubectl config use-context $(PREVIOUS_CONTEXT)
helm uninstall grafana -n k8gb --kube-context=k3d-$(CLUSTER_GSLB1)

.PHONY: dns-tools
dns-tools: ## Run temporary dnstools pod for debugging DNS issues
@kubectl -n k8gb get svc k8gb-coredns
Expand Down
224 changes: 224 additions & 0 deletions deploy/grafana/dashboard-cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: podinfo-dashboard
labels:
grafana_dashboard: "true"
data:
podinfo.json: |-
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"target": {
"limit": 100,
"matchAny": false,
"tags": [],
"type": "dashboard"
},
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"gnetId": null,
"graphTooltip": 0,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": "Prometheus-cluster1",
"description": "# of successful http GET requests per minute on the podinfo app",
"fieldConfig": {
"defaults": {
"color": {
"mode": "continuous-BlYlRd"
},
"custom": {
"axisLabel": "req/min",
"axisPlacement": "auto",
"axisSoftMin": 0,
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "normal"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 12,
"x": 0,
"y": 0
},
"id": 2,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single"
}
},
"targets": [
{
"exemplar": true,
"expr": "rate(http_request_duration_seconds_count{path=\"root\", status=\"200\"}[180s])*180",
"instant": false,
"interval": "",
"legendFormat": "{{kubernetes_pod_name}}",
"refId": "A"
}
],
"title": "podinfo on cluster 1 (EU)",
"type": "timeseries"
},
{
"datasource": "Prometheus-cluster2",
"description": "# of successful http GET requests per minute on the podinfo app",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "req/min",
"axisPlacement": "auto",
"axisSoftMin": 0,
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineStyle": {
"fill": "solid"
},
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 12,
"x": 12,
"y": 0
},
"id": 3,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single"
}
},
"targets": [
{
"exemplar": true,
"expr": "rate(http_request_duration_seconds_count{path=\"root\", status=\"200\"}[180s])*180",
"instant": false,
"interval": "",
"legendFormat": "{{kubernetes_pod_name}}",
"refId": "A"
}
],
"title": "podinfo on cluster 2 (US)",
"type": "timeseries"
}
],
"refresh": "5s",
"schemaVersion": 31,
"style": "dark",
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-30m",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "failover",
"uid": "RngAHeDnz",
"version": 1
}
40 changes: 40 additions & 0 deletions deploy/grafana/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
sidecar:
dashboards:
enabled: true
datasources:
datasources.yaml:
apiVersion: 1
datasources:
# use this proxied datasource for single cluster deployment
# - name: Prometheus
# type: prometheus
# url: http://prometheus-server.k8gb.svc.cluster.local:9090
# access: proxy
# isDefault: true
- name: Prometheus-cluster1
type: prometheus
url: http://localhost:8080
access: direct
isDefault: false
- name: Prometheus-cluster2
type: prometheus
url: http://localhost:8081
access: direct
isDefault: false
dashboardProviders:
dashboardproviders.yaml:
apiVersion: 1
providers:
- name: 'default'
orgId: 1
folder: ''
type: file
disableDeletion: false
editable: true
options:
path: /var/lib/grafana/dashboards
dashboards:
default:
k8s-node-exporter-full:
# Node Exporter Full https://grafana.com/grafana/dashboards/1860
url: https://grafana.com/api/dashboards/1860/revisions/23/download