Kube-Prometheus-Stack安装时初始化导入自定义Grafana dashboards

获取Grafana dashboards的JSON文件

这里是获取已经编辑好的Grafana dashboards的JSON文件;以便内置到Kube-Prometheus-Stack的helm charts的安装zip文件中。

编辑自定义dashboards JSON文件

获取dashboards JSON文件模板

其实Kube-Prometheus-Stack内部本身已经内置了大量kubenetes监控的dashboards。 进入目录,从这里目录复制任意一个作为模板。

复制代码
cd kube-prometheus-stack/templates/grafana/dashboards-1.14

cp alertmanager-overview.yaml my-dashboard.yaml

对 my-dashboard.yaml 文件进行修改

复制代码
  name: {{ printf "%s-%s" (include "kube-prometheus-stack.fullname" $) "my-dashboard" | trunc 63 | trimSuffix "-" }}
  • 修改data的键和值
复制代码
  my-dashboard.json: |-
    {"annotations":{"list":[{"builtIn":1,"datasource":{"type":"grafana","uid":"-- Grafana --"},"enable":true,"hide":true,"iconColor":"rgba(0, 211, 255, 1)","name":"Annotations & Alerts","type":"dashboard"}]},"editable":true,"fiscalYearStartMonth":0,"graphTooltip":0,"id":86,"links":[],"panels":[{"datasource":{"type":"prometheus","uid":"prometheus"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","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":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"maxHeight":600,"mode":"single","sort":"none"}},"targets":[{"datasource":{"type":"prometheus","uid":"prometheus"},"editorMode":"code","expr":"up","instant":false,"legendFormat":"__auto","range":true,"refId":"A"}],"title":"启动情况面板","type":"timeseries"}],"schemaVersion":39,"tags":[],"templating":{"list":[]},"time":{"from":"now-6h","to":"now"},"timeRangeUpdatedDuringEditOrView":false,"timepicker":{},"timezone":"browser","title":"自定义资源视图","uid":"ce0svip2ggmwwf","version":1,"weekStart":""}

这样就增加了一个自定义的Grafana dashboards;然后使用如下命令安装Kube-Prometheus-Stack;即可在安装时带入自定义的dashboard。

复制代码
helm install kube-promethues-stack . -n kube-prom --debug

参考:

复制代码
https://www.doit.com/how-to-add-custom-grafana-dashboards-in-code-using-the-kube-prometheus-stack-helm-chart/
相关推荐
s***35301 天前
SpringBoot集成Prometheus
spring boot·后端·prometheus
礼拜天没时间.1 天前
《Grafana 企业级可视化监控实战指南:从安装、配置到智能告警》:Grafana 简介
linux·运维·信息可视化·zabbix·grafana·监控
礼拜天没时间.1 天前
《Grafana 企业级可视化监控实战指南:从安装、配置到智能告警》:Grafana 环境搭建
linux·运维·信息可视化·zabbix·grafana·监控
v***88561 天前
【prometheus】Pushgateway安装和使用
prometheus
h***67372 天前
Prometheus(普罗米修斯)----- Nginx监控
运维·nginx·prometheus
cui_win3 天前
Docker Compose 部署一个完整的Prometheus监控告警系统
docker·容器·prometheus
Connie14513 天前
记一次K8s故障告警排查(Grafna告警排查)
云原生·容器·kubernetes·grafana
3***16104 天前
【监控】Spring Boot+Prometheus+Grafana实现可视化监控
spring boot·grafana·prometheus
努力发光的程序员6 天前
互联网大厂Java面试场景:微服务与Spring Cloud技术点解析
spring cloud·grafana·prometheus·微服务架构·jwt·api网关·jaeger
熊文豪6 天前
无需公网 IP,用 cpolar 让 Prometheus 监控随时随地可及
prometheus·cpolar