prometheus安装

2024-09-05记录
安装下载
https://prometheus.io/download
https://www.cnblogs.com/ExMan/p/12567247.html

创建目录
mkdir /usr/local/prometheus

进入目录
cd /usr/local/prometheus

下载
wget https://github.com/prometheus/prometheus/releases/download/v2.53.1/prometheus-2.53.1.linux-amd64.tar.gz

解压
tar -zxf prometheus-2.53.1.linux-amd64.tar.gz

修改配置文件
prometheus.yml

检查配置文件
./promtool check config prometheus.yml

./promtool --help
./prometheus --help

chmod a+x "prometheus"

启动
./prometheus --config.file=./prometheus.yml --web.enable-lifecycle
静默启动
nohup ./prometheus --config.file=./prometheus.yml --web.enable-lifecycle --storage.tsdb.retention.time=20d --web.external-url=http://8.219.198.22:9090 > server_prometheus.log 2>&1 &

查看进程
ps -ef | grep prometheus
kill -9 xxx

查找端口盏用情况
lsof -i :9094
netstat -tulnp | grep :9093

rule
https://samber.github.io/awesome-prometheus-alerts/rules

groups:

  • name: exceptionRule
    rules:
    • alert: exceptionAlert
      expr: application_exception{application="userDemo"} < 10
      for: 10s
      labels:
      severity: warning
      team: frontend
      annotations:
      summary: "服务器频繁报错"
      description: "报错的频率达到(当前值:{{ $value }}%)"
  • name: ckExceptionRule
    rules:
    • alert: ckExceptionAlert
      expr: sum(increase(bbc_request_timer_ID_seconds_count{}[5m])) by (business_name) > 10
      for: 10s
      labels:
      severity: warning
      app: "gateway"
      annotations:
      summary: "test系统最近5分钟服务异常"
      description: "报错的频率达到(当前值:{{ $value }})"

检查模版
./promtool check rules first_rules.yml

关闭
ps -ef |grep prometheus |awk '{print $2}'|xargs kill -9
启动
nohup ./prometheus --config.file=./prometheus.yml --web.enable-lifecycle --storage.tsdb.retention.time=20d --web.external-url=http://8.219.198.22:9090 > server_prometheus.log 2>&1 &

重启
curl -X POST http://localhost:9090/-/reload

介绍:counter、timer、Gauge
https://blog.csdn.net/qq_20107237/article/details/125741018
https://blog.csdn.net/qq_34556414/article/details/138495421
https://zhuanlan.zhihu.com/p/675205581

posted @   kunchengs  阅读(29)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示