普罗米修斯(Prometheus)

news/2024/5/19 0:03:36 标签: 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

在这里插入图片描述

prometheusyml_22">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: 15s
    scrape_timeout: 10s
    metrics_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: 30s
  group_interval: 5m
  repeat_interval: 1h
  receiver: '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 signature
    secret: SECbb5316787dc845ec6d93f36ba4b186ed642d3e9267cfd702fce8961cbe26a
    mention:
      mobiles: ['178****3721']
  webhook1:
    url: https://oapi.dingtalk.com/robot/send?access_token=0145833c0ef253ac16cf0c65284b312548a6f2b35d630400a85584b00e860e
    # secret for signature
    secret: SECbb5316787dc845ec6d93f36ba4b186ed642d3e9267cfd702fce8961cbe26a
  webhook2:
    url: https://oapi.dingtalk.com/robot/send?access_token=0145833c0ef253ac16cf0c65284b312548a6f2b35d630400a85584b00e860e
  webhook_legacy:
    url: https://oapi.dingtalk.com/robot/send?access_token=0145833c0ef253ac16cf0c65284b312548a6f2b35d630400a85584b00e860e
    # Customize template content
    message:
      # Use legacy template
      title: '{{ template "legacy.title" . }}'
      text: '{{ template "legacy.content" . }}'
  webhook_mention_all:
    url: https://oapi.dingtalk.com/robot/send?access_token=0145833c0ef253ac16cf0c65284b312548a6f2b35d630400a85584b00e860e
    secret: SECbb5316787dc845ec6d93f36ba4b186ed642d3e9267cfd702fce8961cbe26a
    mention:
      all: true
  webhook_mention_users:
    url: https://oapi.dingtalk.com/robot/send?access_token=0145833c0ef253ac16cf0c65284b312548a6f2b35d630400a85584b00e860e
    mention:
      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.niftyadmin.cn/n/5016909.html

相关文章

YOLOv5算法改进(15)— 更换Neck之AFPN

前言&#xff1a;Hello大家好&#xff0c;我是小哥谈。在YOLOv5中添加AFPN&#xff08;Adaptive Feature Pyramid Network&#xff09;可以提高目标检测的准确性。AFPN是一种用于目标检测任务的功能增强模块&#xff0c;它能够自适应地融合来自不同层级的特征图&#xff0c;以提…

数据结构与算法——复习总结

线性表 线性表括顺序表和链式表。 栈&#xff08;Stack&#xff09;是只允许在一端进行插入或删除操作的线性表。应用&#xff1a;表达式求值&#xff0c;函数递归调用 队列&#xff08;Queue&#xff09;是只允许在一端进行插入&#xff0c;在另一端删除的线性表。应用&…

c语言练习49:有多少⼩于当前数字的数字

有多少⼩于当前数字的数字 给你⼀个数组 nums &#xff0c;对于其中每个元素 nums[i] &#xff0c;请你统计数组中⽐它⼩的所有数字的数⽬。 换⽽⾔之&#xff0c;对于每个 nums[i] 你必须计算出有效的 j 的数量&#xff0c;其中 j 满⾜ j ! i。 且nums[j] < nums[i] …

page、request、session和application有什么区别?以及cookie的含义

众所周知&#xff0c;为了在页面、请求、和用户之间传递和共享数据&#xff0c;JSP提供了四个不同的作用域&#xff1a;page&#xff08;页面作用域&#xff09;、request&#xff08;请求作用域&#xff09;、session&#xff08;会话作用域&#xff09;、application&#xf…

在MAC电脑上将NTFS格式移动硬盘转换为ExFAT格式

注意&#xff1a;转化之前先将移动硬盘中的内容进行备份 1、点击桌面上的【前往】&#xff0c;选择【实用工具】 2、在列表中选择【磁盘工具】 3、在左侧选中你的磁盘&#xff0c;点击右侧上方的【抹掉】,注意&#xff1a;将永久抹掉储存在上面的所有数据&#xff0c;因此需要…

angualr:CSS一个div内两个子元素的高度自适应

问题&#xff1a; 如题 参考&#xff1a; CSS一个div内两个子元素的高度自适应-腾讯云开发者社区-腾讯云

ros_launch配置

创建launch文件批运行节点和包 将以下四条指令写入launch文件中 获取软件包的完整指令 rospackpkg&#xff1a;软件包名字 type&#xff1a;节点名字 四条指令转化成launch文件

【计算机网络】TCP传输控制协议——三次握手

文章目录 握手的流程常考考点 握手的流程 一开始&#xff0c;客户端和服务端都处于CLOSE状态&#xff0c;先是服务端监听某个端口&#xff0c;处于LISTEN状态。然后客户端主动发起连接SYN&#xff0c;之后处于SYN-SEND状态。服务端收到发起的连接&#xff0c;返回SYN&#xff0…