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

2,prometheus node_export及服务端配置文件

1. Node Exporter 服务配置

1.1 Node Exporter systemd 服务文件

cat > /usr/lib/systemd/system/nodeexporter.service <<EOF
[Unit]
Description=prometheus node_exporter
After=network.target[Service]
Type=simple
ExecStart=/bin/node_exporter
KillMode=process[Install]
WantedBy=multi-user.target
EOF

1.2 启动Node Exporter服务

# 重新加载systemd配置
systemctl daemon-reload# 设置开机自启并立即启动
systemctl enable --now node-exporter

2. Prometheus 主配置文件

2.1 基础配置文件

cat > /app/tools/prometheus/prometheus.yml <<EOF
global:scrape_interval: 15sevaluation_interval: 15salerting:alertmanagers:- static_configs:- targets:rule_files:scrape_configs:- job_name: "oldboy_prometheus_server"static_configs:- targets: ["localhost:9090"]- job_name: "oldboy_basic_info_node_exporter"static_configs:- targets:- "prom.oldboylinux.cn:9100"- "gra.oldboylinux.cn:9100"
EOF

2.2 动态配置文件版本

cat > /app/tools/prometheus/prometheus.yml <<EOF
global:scrape_interval: 15sevaluation_interval: 15salerting:alertmanagers:- static_configs:- targets:rule_files:scrape_configs:- job_name: "oldboy_prometheus_server"static_configs:- targets: ["localhost:9090"]# - job_name: "oldboy_basic_info_node_exporter"#   static_configs:#     - targets:#       - "prom.oldboylinux.cn:9100"#       - "gra.oldboylinux.cn:9100"- job_name: "oldboy_basic_info_node_exporter_discovery"file_sd_configs:- files:- /app/tools/prometheus/discovery_node_exporter.jsonrefresh_interval: 5s
EOF

配置说明:

  • file_sd_configs: 动态读取与加载配置文件
  • files: 指定要加载的配置文件路径
  • refresh_interval: 配置文件读取间隔,设置为5秒

3. 动态配置文件

3.1 创建动态配置文件

cat > /app/tools/prometheus/discovery_node_exporter.json <<EOF
[{"targets": ["prom.oldboylinux.cn:9100","gra.oldboylinux.cn:9100"]}
]
EOF

4. 操作步骤总结

  1. 配置Node Exporter服务

    • 创建systemd服务文件
    • 启动并启用服务
  2. 配置Prometheus

    • 可选择静态配置或动态配置方式
    • 动态配置通过file_sd_configs实现,便于批量管理主机
  3. 配置文件格式说明

    • 动态配置文件使用JSON格式
    • 支持多个targets数组
    • Prometheus会自动重新加载配置变更

5. 验证配置

# 检查配置文件语法
/app/tools/prometheus/promtool check config prometheus.yml# 重启Prometheus服务应用配置
systemctl restart prometheus# 查看服务状态
systemctl status prometheus
systemctl status node-exporter

这种配置方式特别适合大规模监控环境,可以轻松扩展和管理监控目标。

http://www.rkmt.cn/news/183116.html

相关文章:

  • 12 - 数据抽取 - parsel解析库
  • Lua 调试(Debug)
  • 家长们都应该了解这些知识,保护孩子视力太重要了
  • Math - 中心化,标准化和归一化
  • 西安交大突破:视觉语言模型功能词忽略提升鲁棒性
  • 利用RSS订阅扩大技术内容影响力范围
  • 写一个简单的Linux驱动程序
  • Elasticsearch 与 PostgreSQL 集成:关系型数据库的搜索增强
  • 2025最新云南节能评估报告服务品牌top5榜单公布,服务覆盖昆明/曲靖/文山/保山/昭通等地优质公司专业评测及选择指南,权威榜单助力企业项目高效合规 - 全局中转站
  • 设置系列专栏:如‘30天掌握AI开发环境搭建’
  • 华为OD机试 - 文件存储系统的排序 - 深度优先搜索dfs(Java 双机位C卷 200分)
  • Adams中机械系统动态质心实时显示与质心轨迹导出
  • Docker run命令启动Miniconda-Python3.10运行PyTorch示例
  • SSH远程访问Miniconda-Python3.10容器进行模型训练
  • 利用GitHub托管代码示例增强技术文章可信度
  • c++实现两个点一个宽度生成一个旋转矩形和计算旋转矩形的四个点坐标
  • Miniconda-Python3.10镜像在自动驾驶仿真中的潜在用途
  • 使用自动化工具辅助撰写Miniconda相关技术内容
  • 混沌测试:让系统在“混乱”中变得更强大
  • 通过微信公众号同步推送增加私域流量沉淀
  • Miniconda创建环境时指定Python版本的正确语法
  • 使用Miniconda环境运行LLaMA系列模型的初步尝试
  • 通过SSH执行非交互式Miniconda环境批量任务
  • 使用Miniconda环境实现Transformer模型蒸馏流程
  • Miniconda创建环境时指定channel优先级的技巧
  • 利用conda env export生成可复现的PyTorch环境文件
  • 在Jupyter中绘制PyTorch模型训练曲线的Matplotlib实践
  • Miniconda-Python3.10环境下安装TensorFlow和PyTorch双框架
  • CF 1603F October 18, 2017
  • 使用Miniconda安装PyTorch Profiler分析模型性能瓶颈