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

Prometheus的服务命令和配置文件

一、Prometheus的服务端命令和启动方式

1.服务端命令(具体详情可以--help查看)

--config.file=“prometheus.yml”指定配置文件,默认是当前目录下的prometheus.yml
--web.listen-address="0.0.0.0:9090"web页面的地址与端口,可以通过nginx添加访问认证
--web.max-connections=512最大并发连接数为512
--storage.tsdb.path="data/"指定时序数据库TSDB存放目录
--log.level=info日志级别,info为标准输出;(详细输出:debug....)
--log.format=logfmt日志格式,logfmt为默认格式;(收集日志可用json格式)

2.启动方式(启动命令可以按需修改)

  • 普通启动
/app/prometheus/prometheus --config.file="/app/prometheus/prometheus.yml" --web.listen-address="0.0.0.0:9090" --web.max-connections=512 &>/var/log/prometheus.log &
  • 开启自启
# 编辑rc.local文件
vim /etc/rc.local
# 在末尾添加下面启动命令
/app/prometheus/prometheus --config.file="/app/prometheus/prometheus.yml" --web.listen-address="0.0.0.0:9090" --web.max-connections=512 &>/var/log/prometheus.log &
  • 设置systemctl启动
# 编辑/usr/lib/systemd/system/prometheus.service配置下面内容[Unit]
Description=prometheus server
After=network.target
[Service]
Type=simple
ExecStart=/app/prometheus/prometheus --config.file=/app/prometheus/prometheus.yml --web.listen-address=0.0.0.0:9090 --web.max-connections=512 
KillMode=process
[Install]
WantedBy=multi-user.target# 保存退出后执行下面命令
systemctl daemon-reload
systemctl enable prometheus.service
systemctl start prometheus.service

二、Prometheus中的配置文件详解(prometheus.yml)

## 全局定义部分
# my global config
global:scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. prometheus采集数据的间隔时间;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 用于配置报警规则,alertmanager
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']# file_sd_configs: 动态配置文件,动态读取文件内容,然后进行监控,修改后不需要重启服务
  • 配置动态读取监控主机 
    # 动态配置file_sd_configs: 动态配置文件,动态读取文件内容,然后进行监控,修改后不需要重启服务- files:- /app/prometheus/dis_node_exporter.ymlrefresh_interval: 5s  # 读取文件间隔时间
#配置/app/prometheus/dis_node_exporter.yml文件
[{"targets": [ "localhost:9090","node-exporter:9100"]}
]

相关文章:

  • springboot03
  • Linux(Ubuntu)新建文件权限继承问题
  • 常见算法题目1 - 给定一个整数数组和一个目标值,找出数组中两个数之和等于目标值的数组下标组合
  • 【424. 替换后的最长重复字符】
  • linux字符模式关闭光标
  • 第34节:迁移学习中的特征提取方法
  • 九、日志分析和系统故障排查
  • 【Python3教程】Python3 文件(File)方法详解
  • 痉挛性斜颈护理指南:多维度守护颈部健康
  • 自动化测试报告工具
  • 课外知识:Python方法绑定机制与装饰器传参详解 与 实战
  • 各个网络协议的依赖关系
  • Labview使用报表工具
  • 谷歌开源医疗领域AI语言模型速递:medgemma-27b-text-it
  • 深入剖析 Doris 倒排索引(上):原理与应用全解析​
  • 【C/C++】深入解析Linux下C/C++内存管理全攻略(纲要)
  • 在政务中使用仙盟创梦工具维护曲靖市麒麟公安分局————仙盟创梦IDE
  • JVM常量池(class文件常量池,运行时常量池,字符串常量池)
  • 互联网大厂Java求职面试:AI大模型推理优化与实时数据处理架构
  • CRichEditCtrl 控件实现日志输出
  • 电脑网站开发手机上可以打开吗/百度软件商店
  • 南通网站建设有限公司/搜狗网站提交入口
  • 网络规划设计师和网络工程师/搜索引擎优化面对哪些困境
  • wordpress搭建多个购物网站/学生个人网页制作素材
  • 做视频网站需要什么软件/seo软件服务
  • windows不能用wordpress/长清区seo网络优化软件