Skip to content

Commit

Permalink
Add grafana including example dashboard for 'podinfoes'
Browse files Browse the repository at this point in the history
Signed-off-by: Jirka Kremser <jiri.kremser@gmail.com>
  • Loading branch information
jkremser committed Oct 13, 2021
1 parent 52d0c10 commit 7a2c345
Show file tree
Hide file tree
Showing 3 changed files with 313 additions and 0 deletions.
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
249 changes: 249 additions & 0 deletions deploy/grafana/dashboard-cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
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": [
{
"__systemRef": "hideSeriesFrom",
"matcher": {
"id": "byNames",
"options": {
"mode": "exclude",
"names": [
"frontend-podinfo-665f549f99-7t6zz"
],
"prefix": "All except:",
"readOnly": true
}
},
"properties": [
{
"id": "custom.hideFrom",
"value": {
"legend": false,
"tooltip": false,
"viz": true
}
}
]
}
]
},
"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

0 comments on commit 7a2c345

Please sign in to comment.