Prometheus Blackbox_exporter笔记

news/2024/5/18 23:41:33 标签: prometheus, 笔记, linux

一、安装Promtheus

在 Prometheus 官网 Download | Prometheus 获取适用于 Linux 的 Prometheus 安
装包,这里我选择最新的 2.46.0  版本,我是 Linux 系统,选择下载 prometheus-2.46.0.linux-amd64.tar.gz
 

下载安装包:
wget https://github.com/prometheus/prometheus/releases/download/v2.46.0/prometheus-
2.46.0.linux-amd64.tar.gz
 
解压安装包
tar zxvf prometheus-2.46.0.linux-amd64.tar.gz
 
进到解压目录
cd prometheus-2.46.0.linux-amd64/
 
查看版本信息
./prometheus --version

生成prometheus启动脚本,自行修改目录,我的解压目录是/opt/prometheus-2.46.0.linux-amd64/prometheus
vim /etc/systemd/system/prometheus.service

[Unit]
Description=Prometheus
Documentation=https://prometheus.io/docs/introduction/overview/
Wants=network-online.target
After=network-online.target

[Service]
ExecStart=/opt/prometheus-2.46.0.linux-amd64/prometheus \
  --config.file=/opt/prometheus-2.46.0.linux-amd64/prometheus.yml \
  --storage.tsdb.path=/opt/prometheus-2.46.0.linux-amd64/data
ExecReload=/bin/kill -HUP $MAINPID
TimeoutStopSec=20s
Restart=always

[Install]
WantedBy=default.target

 systemctl daemon-reload
 systemctl enable prometheus
 systemctl start prometheus

 systemctl status prometheus

访问http://IP:9090/targets进行确认

二、安装Blackbox_expoter 

下载地址:Releases · prometheus/blackbox_exporter · GitHub

tar zxvf blackbox_exporter-0.24.0.linux-amd64.tar.gz -C /usr/local/

vim /etc/systemd/system/blackbox_exporter.service

[Unit]
Description=Blackbox Exporter
Wants=network-online.target
After=network-online.target

[Service]
ExecStart=/usr/local/blackbox_exporter-0.24.0.linux-amd64/blackbox_exporter \
  --config.file=/usr/local/blackbox_exporter-0.24.0.linux-amd64/blackbox.yml
ExecReload=/bin/kill -HUP $MAINPID
TimeoutStopSec=20s
Restart=always

[Install]
WantedBy=default.target

systemctl daemon-reload
systemctl enable blackbox_exporter
systemctl start blackbox_exporter

systemctl status blackbox_exporter

访问IP:9115进行确认

三、安装Grafana 

 下载地址:

 Download Grafana | Grafana Labs

wget https://dl.grafana.com/oss/release/grafana-10.1.0-1.x86_64.rpm

yum install -y urw-fonts
rpm -ivh grafana-10.1.0-1.x86_64.rpm

数据配置路径,比如数据目录、日志目录、插件目录:/etc/sysconfig/grafana-server
默认的用户名和密码为 admin ,也可以在配置文件 /etc/grafana/grafana.ini中配置 admin_user 和 admin_password 两个参数来进行覆盖。
配置中文界面:
vim /etc/grafana/grafana.ini

default_language = zh-Hans

systemctl daemon-reload
systemctl enable grafana-server.service
systemctl start grafana-server

访问 http:IP:3000 进行确认

 四、配置Prometheus

 配置prmetheus.yml使用blackbox_exporter

vim /opt/prometheus-2.46.0.linux-amd64/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:
          # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_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: 网站状态
    metrics_path: /probe
    params:
      module: [http_2xx]
    static_configs:
    - targets:
      - http://www.baidu.com
      - http://www.jd.com
      labels:
        group: web
    relabel_configs:
    - source_labels: [__address__]
      target_label: __param_target
    - source_labels: [__param_target]
      target_label: instance
    - target_label: __address__
      replacement: 192.168.31.80:9115
   

  - job_name: 网络联通性
    metrics_path: /probe
    params:
      module: [icmp]
    static_configs:
    - targets:
      - 10.4.117.66
      - 10.4.117.69
      labels:
        group: icmp
    relabel_configs:
    - source_labels: [__address__]
      target_label: __param_target
    - source_labels: [__param_target]
      target_label: instance
    - target_label: __address__
      replacement: 192.168.31.80:9115

  - job_name: TCP端口状态
    metrics_path: /probe
    params:
      module: [tcp_connect]
    static_configs:
    - targets:
      - 10.4.117.205:443
      - 10.4.117.205:38080
      labels:
        group: tcp-port-status
    relabel_configs:
    - source_labels: [__address__]
      target_label: __param_target
    - source_labels: [__param_target]
      target_label: instance
    - target_label: __address__
      replacement: 192.168.31.80:9115

五、Grafana插件安装

 默认仪表盘部分插件没有,示例安装:grafana-piechart-panel

grafana-cli plugins install grafana-piechart-panel

指定插件路径

vim /etc/grafana/grafana.ini

[plugin.piechart]
path = /var/lib/grafana/plugins/grafana-piechart-panel

六、Grafana 模板选择

Dashboards | Grafana Labs 模板地址

示例:

模板ID:13659

模板ID:9965


http://www.niftyadmin.cn/n/5311138.html

相关文章

sql如何获取字段是数组中的数字【搬代码】

我们可以看到表中字段是一个数组怎么获取其中的数据呢&#xff1f; SELECT sim->>$[0] FROM fin_xxx如果使用左外链接&#xff0c;如下&#xff0c;其他连接时一样的 SELECT a.* FROM fin_aaaa a LEFT JOIN fin_xxx b ON b.sim_r->>$[0]a.corr WHERE b.tid20210 …

C# xml序列化和反序列化

问题 有的项目使用webservice返回结果是xml&#xff0c;需要进行xml序列化和反序列化 xml序列化相关特性 C#中&#xff0c;XML序列化相关的特性主要包括&#xff1a; XmlIgnore&#xff1a;这个特性可以用来指示序列化过程忽略一个属性或一个字段。当使用XmlIgnore特性时&a…

Spring Boot和Redis Geo实现附近的人【redis实战 三】

欢迎来到我的博客&#xff0c;代码的世界里&#xff0c;每一行都是一个故事 靠近你&#xff1a;使用Spring Boot和Redis Geo探索坐标点的秘密 引言(redis实战)前言Redis Geo回顾redis中GEO的优势1. 性能2. 存储效率3. 简化的操作和集成4. 灵活性和可扩展性5. 成本效益注意事项…

信息系统安全——基于 KALI 和 Metasploit 的渗透测试

实验 2 基于 KALI 和 Metasploit 的渗透测试 2.1 实验名称 《基于 KALI 和 Metasploit 的渗透测试》 2.2 实验目的 1 、熟悉渗透测试方法 2 、熟悉渗透测试工具 Kali 及 Metasploit 的使用 2.3 实验步骤及内容 1 、安装 Kali 系统 2 、选择 Kali 中 1-2 种攻击工具&#xff0c…

15.认识Android中Activity的生命周期

(1).一个Activity页面&#xff0c;从开始到结束会经历哪些生命周期 (2).各生命周期阶段会调用的函数&#xff08;生命周期函数&#xff09;

DD代驾.高级数分 已二面

dd高级数据分析面试感觉更偏数科一点&#xff0c;问了很多AB实验和反事实因果推断的问题&#xff0c;同时也比较关注怎么对模型进行的评价 一面&#xff1a;小组长|组员 40min 自我介绍项目深究1、你在实际工作做AB的流程2、AB实验你们咋算的样本量3、AB实验你们啥情况会做A…

MLP(多层感知机) 虚战1

使用Keras实现MLP 前两节地址&#xff1a; CSDNmatplotlib 虚战1-CSDN博客 &#xff08;数据的获取在这有说明&#xff09; 数据预处理 虚战1-CSDN博客CSDN 数据预处理的最后一步&#xff1a;将数据集分为 训练数据集、测试数据集和校验数据集。 训练数据集&#xff1a…

视频号小店做不起来?万法一门!分享两个做视频号小店的建议!

我是王路飞。 作为当前电商行业的重头戏&#xff0c;做视频号小店的越来越多了。 就像当初的抖店一样&#xff0c;越早入局的&#xff0c;机会越大。 但是很多商家私信我说视频号小店好像比抖店难多了&#xff0c;自己根本做不起来。 我给你们两个建议&#xff1a;【不要拿…