当前位置: 首页 > news >正文

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 文件进行修改

  • 删除头部的注释
{{- /*
Generated from 'alertmanager-overview' from https://raw.githubusercontent.com/prometheus-operator/kube-prometheus/2a14b95595fd6767bdeb03ca7460b15a3793d503/manifests/grafana-dashboardDefinitions.yaml
Do not change in-place! In order to change this file first read following link:
https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack/hack
*/ -}}
  • 修改ConfigMap的名称

在这里插入图片描述

  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/
http://www.lryc.cn/news/498307.html

相关文章:

  • 【SNIP】《An Analysis of Scale Invariance in Object Detection – SNIP》
  • JAVA基础学习笔记_异常
  • Modern Effective C++条款三十四:考虑lambda而非std::bind
  • lyapunov指数的绘制
  • Ansible 运维工具
  • 【AI系统】MobileNet 系列
  • MATLAB在生态环境数据处理与分析中的应用
  • tensorrt
  • 利用Grounding DINO进行自动标注——目标检测任务——YOLO格式
  • 网际协议(IP)与其三大配套协议(ARP、ICMP、IGMP)
  • uniapp 添加loading
  • cocotb pytest
  • docker run 设置启动命令
  • docker入门 自记录
  • css实现圆周运动效果
  • 【NoSQL数据库】MongoDB数据库——集合和文档的基本操作(创建、删除、更新、查询)
  • Dart 学习笔记(一)
  • 安防视频监控平台Liveweb视频汇聚管理系统管理方案
  • 十八(GIT)、GIT基本命令、axios别名方法、黑马就业数据平台(axios基地址、轻提示函数、注册及登录功能)
  • Linux查看系统基本信息
  • Word处理表格的一些宏
  • 将本地项目文件推送到Git仓库中
  • 2024-12-05OpenCV高级-滤波与增强
  • vue3中 axios 发送请求 刷新token 封装axios
  • aardio - 汉字笔顺处理 - json转sqlite转png
  • 数据结构学习笔记 双向链表
  • 深度学习作业十 BPTT
  • html+css+JavaScript实现轮播图
  • Python+onlyoffice 实现在线word编辑
  • PostgreSQLt二进制安装-contos7