Prometheus(十)Granfana 通过文件配置实现自动化
使用配置文件方式配置 Datasource
配置文件目录:
/etc/grafana/provisioning/datasources/
文件 datasource.yml
内容如下
apiVersion: 1
datasources:- name: Prometheustype: prometheus# Access mode - proxy (server in the UI) or direct (browser in the UI).access: proxyurl: http://prometheus 的 IP:9090#url: http://prometheus:9091jsonData:httpMethod: POSTexemplarTraceIdDestinations:# Field with internal link pointing to data source in Grafana.# datasourceUid 的值可以是任意的值,但是需要是全局唯一。并且这个值是 dashboards 中使用到的.- datasourceUid: PBFA97CFB590B2093name: traceID# Field with external link.- name: traceIDurl: 'http://localhost:3000/explore?orgId=1&left=%5B%22now-1h%22,%22now%22,%22Jaeger%22,%7B%22query%22:%22$${__value.raw}%22%7D%5D'
使用配置文件方式配置 Dashboard
配置文件路径:
/etc/grafana/provisioning/dashboards/
将从官方下载好的 json 文件中的 annotations
任意文件名.json
"annotations": {"list": [{..."datasource": "-- Grafana --",
修改为
"annotations": {"list": [{..."datasource": {"type": "datasource","uid": "grafana"},
sed -ri 's/"-- Grafana --",/{\n "type": "datasource",\n "uid": "grafana"\n },doc /g' nodeExporter.json
再将所有的
${DS_TEST-PROMETHEUS}
修改 为
在 Datasource 中配置的 uid, 这里假设是 PBFA97CFB590B2093
或者将 “${DS_PROMETHEUS}”,
修改为
{"type": "prometheus","uid": "PBFA97CFB590B2093"},
sed -i 's#"\${DS_PROMETHEUS}",#{\n "type": "prometheus",\n "uid": "PBFA97CFB590B2093"\n },#gp' blackbox.json
使用文件配置创建和管理警报资源
官方文档 https://grafana.com/docs/grafana/latest/alerting/set-up/provision-alerting-resources/file-provisioning/
告警规则
/etc/grafana/provisioning/alerting/
在此目录下创建 yaml 文件,示例文件如下
# config file version
apiVersion: 1# 要导入或更新的规则组列表
groups:# <int> 组织 ID, default = 1- orgId: 1# <string, required> 规则组的名称name: my_rule_group# <string, required> 规则组将存储在其中的文件夹的名称folder: my_first_folder# <duration, required> 规则检查的时间间隔interval: 60s# <list, required> 属于规则组的规则列表rules:# <string, required> 规则的唯一标识符- uid: my_id_1# <string, required> 将在UI中显示的规则的标题title: my_first_rule# <string, required> 条件应使用哪个查询condition: A# <list, required>应在每次评估中执行的查询对象列表-应通过API获取data:- refId: A# datasourceUid 数据源 IDdatasourceUid: 'PBFA97CFB590B2093'model:# 条件conditions:- evaluator:params:- 3type: gtoperator:type: andquery:params:- Areducer:type: lasttype: querydatasource:type: __expr__uid: '-100'expression: 1==0intervalMs: 1000maxDataPoints: 43200refId: Atype: math# <string> 警报规则应链接到的仪表板的UIDdashboardUid: my_dashboard# <int> 警报规则应链接到的面板的IDpanelId: 123# <string> 未返回数据时警报规则的状态# 可以设置的值: "NoData", "Alerting", "OK", default = NoDatanoDataState: Alerting# <string> 查询执行失败时警报规则的状态# 可以设置的值: "Error", "Alerting", "OK", default = Alerting# <duration, required> 警报规则被触发后持续多久才发出告警信息for: 60s# <map<string, string>> 描述信息,任意数据的 key: valueannotations:some_key: some_value# <map<string, string> 可用于筛选和路由警报的字符串映射labels:team: sre_team_1
告警通道 钉钉
/etc/grafana/provisioning/alerting/
dingding.yml
# config file version
apiVersion: 1# List of contact points to import or update
contactPoints:# <int> organization ID, default = 1- orgId: 1# <string, required> name of the contact pointname: dingdingreceivers:# <string, required> unique identifier for the receiver- uid: dingdingtype: dingdingsettings:# <string, required>url: https://oapi.dingtalk.com/robot/send?access_token=xxx# <string> options: link, actionCard# msgType: linkmsgType: actionCard# <string>message: |{{ template "default.message" . }}
通知策略
/etc/grafana/provisioning/notifiers/
notifiers.yml
# config file version
apiVersion: 1# List of notification policies
policies:# <int> organization ID, default = 1- orgId: 1# <string> name of the contact point that should be used for this routereceiver: dingding# <list> The labels by which incoming alerts are grouped together. For example,# multiple alerts coming in for cluster=A and alertname=LatencyHigh would# be batched into a single group.## To aggregate by all possible labels use the special value '...' as# the sole label name, for example:# group_by: ['...']# This effectively disables aggregation entirely, passing through all# alerts as-is. This is unlikely to be what you want, unless you have# a very low alert volume or your upstream notification system performs# its own grouping.group_by: ['...']# <list> a list of matchers that an alert has to fulfill to match the nodematchers:- alertname = Watchdog- severity =~ "warning|critical"# <list> Times when the route should be muted. These must match the name of a# mute time interval.# Additionally, the root node cannot have any mute times.# When a route is muted it will not send any notifications, but# otherwise acts normally (including ending the route-matching process# if the `continue` option is not set)mute_time_intervals:- abc# <duration> How long to initially wait to send a notification for a group# of alerts. Allows to collect more initial alerts for the same group.# (Usually ~0s to few minutes), default = 30sgroup_wait: 30s# <duration> How long to wait before sending a notification about new alerts that# are added to a group of alerts for which an initial notification has# already been sent. (Usually ~5m or more), default = 5mgroup_interval: 5m# <duration> How long to wait before sending a notification again if it has already# been sent successfully for an alert. (Usually ~3h or more), default = 4hrepeat_interval: 4h# <list> Zero or more child routes# routes:# ...
配置模板
# config file version
apiVersion: 1# List of alert rule UIDs that should be deleted
deleteTemplates:# <int> organization ID, default = 1- orgId: 1# <string, required> name of the template, must be uniquename: my_first_template
配置静音
# config file version
apiVersion: 1# List of mute time intervals to import or update
muteTimes:# <int> organization ID, default = 1- orgId: 1# <string, required> name of the mute time interval, must be uniquename: mti_1# <list> time intervals that should trigger the muting# refer to https://prometheus.io/docs/alerting/latest/configuration/#time_interval-0time_intervals:- times:- start_time: '06:00'end_time: '23:59'weekdays: ['monday:wednesday', 'saturday', 'sunday']months: ['1:3', 'may:august', 'december']years: ['2020:2022', '2030']days_of_month: ['1:5', '-3:-1']
Prometheus(十)Granfana 通过文件配置实现自动化相关推荐
- 十招技巧将网络管理变成自动化
十招技巧将网络管理变成自动化 新一代网管工具所提供的解决方案能把过去人工.繁杂的网络管理工作变成自动化,并且具有主动性和增值功能.它有助于提高网络管理员的地位,使其成为策略管理员,同时又减少了 ...
- Exchange Server2013 系列十:证书的配置
Exchange Server2013 系列十:证书的配置 杜飞 经过前面的配置,基本上可以进行简单的邮件通讯了,但是当用户通过OWA连接邮箱时会报下面的提示: 其他一些服务,如 Outlook An ...
- Django学习之十: staticfile 静态文件
目录 Django学习之十: staticfile 静态文件 理解阐述 静态文件 Django对静态文件的处理 其它方面 总结 Django学习之十: staticfile 静态文件 理解阐述 静态文 ...
- redis的redis.config文件配置与内容+10.30日之前的总结
参考博客:redis.conf的一些配置+密码的设置(mac)+个人总结_雾喔的博客-CSDN博客_redis密码配置文件 这个是初始的redis.config的内容 # Redis configur ...
- 数据库的文件服务器配置,服务器数据库文件配置
服务器数据库文件配置 内容精选 换一换 SAP B1快速部署方案如图1所示.说明如下:VPC网络:为了保证网络的安全,SAP B1系统中所有节点在一个VPC网络内,且所有节点应属于同一个AZ(Avai ...
- 配置suse自动化安装
配置suse自动化安装 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 前言:不知道你习惯用那款虚拟器,我用的是VMware Workstation,别问我为什么,因 ...
- 十分钟教你配置frp实现内网穿透
十分钟教你配置frp实现内网穿透 一.frp的作用 利用处于内网或防火墙后的机器,对外网环境提供 http 或 https 服务. 对于 http, https 服务支持基于域名的虚拟主机,支持自定义 ...
- maven配置自动部署到服务器上,jenkins+svn+maven安装配置并自动化部署成功(超级详细)...
jenkins+svn+maven安装配置并自动化部署成功(超级详细) jenkins+svn+maven安装配置并自动化部署成功(超级详细) 简言 写这篇博客的原因是因为每次部署服务器的流程都是在做 ...
- 服务器前端文件配置,服务器前端文件配置
服务器前端文件配置 内容精选 换一换 使用mount命令挂载文件系统到云服务器,云服务器系统提示timed out.原因1:网络状态不稳定.原因2:网络连接异常.原因3:云服务器DNS配置错误,导致解 ...
最新文章
- 为什么数据库连接池不采用 IO 多路复用?
- mysql性能监控qps,tps,iops
- 第七届全国大学生智能汽车竞赛获奖名单
- 介绍一位高级数据分析师,告诉你数据分析原来这么好玩
- c++ primer 第14章 习题解答
- Win7删除不了打印机怎么办
- Android原生系统API自带dp、px、sp单位转换
- 八爪鱼,国内领先的爬虫云采集工具平台,为许多大型公司,政府,提供数据服务
- WPF:Documents文档--Annomation批注(1)
- python numpy数组动态写入csv文件_python - 将NumPy数组转储到csv fi中
- 毕设-基于SSM高校后勤管理系统
- excel概率密度函数公式_excel统计函数公式汇总
- 房地产里有多少“三季人”?
- css3 画太极图——用一个div实现
- mybatis-plus乐观锁配置
- Android Studio清单文件合并规则
- mysql面试题1313
- CT值及CT常用窗宽、窗位
- 我们只是虫子!我们真的是虫子吗?
- 手机相机里面的m_让手机具备M档 WP专业拍照软件ProShot
热门文章
- 快来抄吧:Project Plan Template 项目计划模板
- 参考文献怎么查找,去哪里查找?一篇文章讲明白这些问题
- 【信息隐藏】LSB隐写算法的实现与性能分析
- 微服务8--ELasticsearch搜索引擎
- ​英伟达 CEO 黄仁勋:摩尔定律结束了;苹果新专利:折叠式iPhone可自行修复折痕;Rust 1.64.0 发布|极客头条...
- IAR中map文件全解析
- 游戏服务器为什么选用Actor模型,《百万在线》给你答案
- sas和python哪个更容易发胖_碳水化合物和脂肪哪个更容易让身体发胖?
- python的转义字符,以及字符串输出转义字符
- 机器学习和深度学习的主要术语(中英)