Prometheus搭建

安装prometheus

下载并安装      服务器地址为:192.168.10.1

cd /usr/local
wget https://github.com/prometheus/prometheus/releases/download/v2.26.0/prometheus-2.26.0.linux-amd64.tar.gz
tar -zxvf prometheus-2.26.0.linux-amd64.tar.gz
mv prometheus-2.26.0.linux-amd64 promehtues

创建prometheus用户

groupadd prometheus
useradd -g prometheus -m -d /var/lib/prometheus -s /sbin/nologin prometheus
chown prometheus.prometheus /usr/local/prometheus -R

创建启动脚本:

复制代码
vim /usr/lib/systemd/system/prometheus.service 

[Unit]
Description=prometheus
After=network.target

[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus --storage.tsdb.retention.time=15d --log.level=info
Restart=on-failure

[Install]
WantedBy=multi-user.target
复制代码

配置 Prometheus 添加监控目标

复制代码
cd /usr/local/prometheus
vim prometheus.yml 
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: '192.168.10.1'
 
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.
 
    static_configs:
    - targets: ['localhost:9090','localhost:9100'] # 对本机node_exporter 监控
 
# 新添加的对其它node节点抓取数据
  - job_name: '192.168.75.10'
    #重写了全局抓取间隔时间,由15秒重写成5秒。
    scrape_interval: 5s
    static_configs:
    - targets: ['192.168.10.2:9100']
复制代码

启动prometheus

systemctl enable prometheus.service
systemctl start prometheus.service
systemctl status prometheus.service 

 访问

 访问 Prometheus WEB 查看我们定义的目标主机:http://192.168.10.1:9090/targets

 

posted @   fat_girl_spring  阅读(86)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
点击右上角即可分享
微信分享提示