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

普罗米修斯(Prometheus)

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档

文章目录

  • 一、普罗米修斯(Prometheus)是什么?
    • 1.下载Prometheus工具(切记和操作系统版本对应)
    • 2.解压命令
    • 3.修改prometheus.yml配置
    • 4.免密版(默认端口9090)
    • 4.加密版(默认端口9090)
  • 二、告警(Alertmanager)是什么?
    • 1.下载地址
    • 2.解压命令
    • 3.修改配置文件
    • 4.配置Alertmanager启动文件(默认端口9093)
  • 三、钉钉(dingtalk)是什么?
    • 1.下载地址:
    • 2.解压命令
    • 3.修改配置文件
    • 4.启动钉钉服务(默认端口8060)
  • 总结


一、普罗米修斯(Prometheus)是什么?

prometheus是由谷歌研发的一款开源的监控软件,它通过安装在远程机器上的exporter,通过HTTP协议从远程的机器收集数据并存储在本地的时序数据库上。目前已经被云计算本地基金会托管,是继k8s托管的第二个项目,号称是下一代监控。
在这里插入图片描述

1.下载Prometheus工具(切记和操作系统版本对应)

下载地址:https://prometheus.io/download/

操作系统版本
x86prometheus-2.45.0.linux-amd64.tar.gz
linuxprometheus-2.45.0.linux-amd64.tar.gz
windowprometheus-2.45.0.windows-amd64.zip

2.解压命令

tar -zxvf prometheus-2.45.0.linux-amd64.tar.gz

在这里插入图片描述

3.修改prometheus.yml配置

# my global config
global:scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.# scrape_timeout is set to the global default (10s).# Alertmanager configuration 告警信息服务配置,用来发送告警信息,敲黑板:很重要
alerting:alertmanagers:- static_configs:- targets:- 192.168.10.111:9093# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
# 自定义规则,会获取指定目录下的所有规则配置文件
rule_files:- "rules/*.yml"# - "second_rules.yml"# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.- job_name: "prometheus"# metrics_path defaults to '/metrics'# scheme defaults to 'http'.static_configs:- targets: ["localhost:9090"]- job_name: 'gateway'static_configs:- targets: ['192.168.10.111:11200']- job_name: 'eureka'static_configs:- targets: ['192.168.10.111:11300']- job_name: 'object'scrape_interval: 15sscrape_timeout: 10smetrics_path: '/object-library-api-service/actuator/prometheus'static_configs:- targets: ['192.168.10.111:11198']- job_name: 'sync'static_configs:- targets: ['192.168.10.111:11025']
# 监听服务信息,定义服务名称,暴露接口给普罗米修斯进行验证,配置指定的gargets信息- job_name: 'user'metrics_path: '/actuator/prometheus'static_configs:- targets: ['192.168.11.2:7777']
#  - job_name: 'alertmanager'
#    static_configs:
#      - targets: ['192.168.10.111:9093']

4.免密版(默认端口9090)

[Unit]
Description=prometheus[Service]
Restart=on-failure
ExecStart=/longjin/prometheus/prometheus --config.file=/longjin/prometheus/prometheus.yml

4.加密版(默认端口9090)

[Unit]
Description=prometheus[Service]
Restart=on-failure
ExecStart=/longjin/prometheus/prometheus --config.file=/longjin/prometheus/prometheus.yml --web.config.file=/longjin/prometheus/web.yml 

web.yml配置文件

basic_auth_users:# 密码生成地址:https://www.bejson.com/encrypt/bcrpyt_encode/,格式为 [ admin: 123456 ]admin: $2a$10$6TUBoDndlIkyTVimXSv7COac2fC9HpT4CCA7gnwNrvTRmkA0YURWO

check验证
在这里插入图片描述

二、告警(Alertmanager)是什么?

Alertmanager 主要用于接收 Prometheus 发送的告警信息,它支持丰富的告警通知渠道,而且很容易做到告警信息进行去重,降噪,分组等,是一款前卫的告警通知系统。

1.下载地址

下载地址:https://prometheus.io/download/

2.解压命令

tar -zxvf alertmanager-0.26.0.linux-amd64.tar.gz

在这里插入图片描述

3.修改配置文件

route:group_by: ['alertname']group_wait: 30sgroup_interval: 5mrepeat_interval: 1hreceiver: 'dingding.alertname'
receivers:
# 配置调用钉钉服务接口,用来推送消息- name: 'dingding.alertname'webhook_configs:- url: 'http://192.168.10.111:8060/dingtalk/alertname/send'send_resolved: true
inhibit_rules:- source_match:severity: 'critical'target_match:severity: 'warning'equal: ['alertname', 'dev', 'instance']

4.配置Alertmanager启动文件(默认端口9093)

[Unit]
Description=alertmanager[Service]
Restart=on-failure
ExecStart=/longjin/prometheus/alert/alertmanager --config.file=/longjin/prometheus/alert/alertmanager.yml --storage.path=/longjin/prometheus/alert/data/

三、钉钉(dingtalk)是什么?

钉钉(DingTalk)是阿里巴巴集团专为中国企业打造的免费沟通和协同的多端平台,提供PC版,Web版,Mac版和手机版,支持手机和电脑间文件互传。

1.下载地址:

下载地址:https://github.com/timonwong/prometheus-webhook-dingtalk/releases

2.解压命令

tar -zxvf prometheus-webhook-dingtalk-2.1.0.linux-amd64.tar.gz

在这里插入图片描述

3.修改配置文件

cp一份配置文件出来,切记改成你们自己钉钉机器人的配置。查看钉钉机器人基本信息就可以了

## Request timeout
timeout: 5s## Uncomment following line in order to write template from scratch (be careful!)
#no_builtin_template: true## Customizable templates path
templates:- contrib/templates/legacy/template.tmpl## You can also override default template using `default_message`
## The following example to use the 'legacy' template from v0.3.0
#default_message:
#  title: '{{ template "legacy.title" . }}'
#  text: '{{ template "legacy.content" . }}'## Targets, previously was known as "profiles"
targets:alertname:url: https://oapi.dingtalk.com/robot/send?access_token=0145833c0ef253ac16cf0c65284b312548a6f2b35d630400a85584b00e860e# secret for signaturesecret: SECbb5316787dc845ec6d93f36ba4b186ed642d3e9267cfd702fce8961cbe26amention:mobiles: ['178****3721']webhook1:url: https://oapi.dingtalk.com/robot/send?access_token=0145833c0ef253ac16cf0c65284b312548a6f2b35d630400a85584b00e860e# secret for signaturesecret: SECbb5316787dc845ec6d93f36ba4b186ed642d3e9267cfd702fce8961cbe26awebhook2:url: https://oapi.dingtalk.com/robot/send?access_token=0145833c0ef253ac16cf0c65284b312548a6f2b35d630400a85584b00e860ewebhook_legacy:url: https://oapi.dingtalk.com/robot/send?access_token=0145833c0ef253ac16cf0c65284b312548a6f2b35d630400a85584b00e860e# Customize template contentmessage:# Use legacy templatetitle: '{{ template "legacy.title" . }}'text: '{{ template "legacy.content" . }}'webhook_mention_all:url: https://oapi.dingtalk.com/robot/send?access_token=0145833c0ef253ac16cf0c65284b312548a6f2b35d630400a85584b00e860esecret: SECbb5316787dc845ec6d93f36ba4b186ed642d3e9267cfd702fce8961cbe26amention:all: truewebhook_mention_users:url: https://oapi.dingtalk.com/robot/send?access_token=0145833c0ef253ac16cf0c65284b312548a6f2b35d630400a85584b00e860emention:mobiles: ['178****3721']

4.启动钉钉服务(默认端口8060)

[Unit]
Description=dingtalk[Service]
Restart=on-failure
WorkingDirectory=/longjin/prometheus/dingtalk
ExecStart=/longjin/prometheus/dingtalk/prometheus-webhook-dingtalk --config.file=/longjin/prometheus/dingtalk/config.yml
[Install]
WantedBy=multi-user.target

总结

人生物语:自己不努力上进,何来的得心应手?不是娇靥,就可以有馥郁的芳香;不是有刀戟就可以百战百胜。你不是急流,不能湍飞;你不是花儿,你没有自带的芳香;你不是海洋,不可海纳百川。

http://www.lryc.cn/news/158951.html

相关文章:

  • JAVA面试题2012年版本
  • IED设备模型
  • HTTP代理如何设置
  • 【设计模式】单例设计模式
  • SpingBoot整合Sa-Token框架(1)
  • 软件测试技术题目大全【含答案】
  • C#__线程的优先级和状态控制
  • 103.36.167.X在服务器删除、复制文件的时候会出现卡的情况,是什么原因?
  • Vim 插件应用篇 vim-plug:简洁高效的Vim插件管理工具
  • springboot 请求https的私有证书验证
  • YOLO的基本原理详解
  • 【UE 材质】制作飘动的旗帜
  • windows苹果商店上架ipa(基于appuploader)
  • 什么是SpringCloud Eureka服务注册与发现
  • A Mathematical Framework for Transformer Circuits—Part (1)
  • 关于Maven中使用idea发布java项目的步骤:
  • 如何使用ArcGIS Earth制作地图动画视频
  • 【Linux成长史】Linux基本指令大全
  • ChatGPT:深度学习和机器学习的知识桥梁
  • python-基本数据类型-笔记
  • 如何使用API数据接口给自己创造收益
  • 第三方软件信息安全测评服务范围
  • 测试开发 | Java 接口自动化测试首选方案:REST Assured 实践
  • vue3:13、Vue3.3新特性-defineModel
  • 如何理解C++中的void*
  • MVC,MVP,MVVM的理解和区别
  • 【TypeScript】一直提示 :无法重新声明块范围变量
  • 【python自动化】七月PytestAutoApi开源框架学习笔记(一)
  • Python学习 -- logging模块
  • 【socket】getaddrinfo、getsockname、getpeername对比