云原生学习 – Prometheus 命令速查手册

一、安装与启动

# 二进制安装
wget https://github.com/prometheus/prometheus/releases/download/v2.45.0/prometheus-2.45.0.linux-amd64.tar.gz
tar xzf prometheus-2.45.0.linux-amd64.tar.gz
./prometheus --config.file=prometheus.yml

二、配置文件 (prometheus.yml)

global:
  scrape_interval: 15s

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']

  - job_name: 'node_exporter'
    static_configs:
      - targets: ['10.0.0.91:9100', '10.0.0.92:9100']

三、告警规则

groups:
  - name: node_rules
    rules:
      - alert: NodeDown
        expr: up{job="node_exporter"} == 0
        for: 1m
        labels:
          severity: critical
        annotations:
          summary: "Node {{ $labels.instance }} is down"

四、常用命令

# 查看Targets
curl https://localhost:9090/api/v1/targets

# 查询指标
curl https://localhost:9090/api/v1/query?query=up

# 验证规则
promtool check rules /opt/prometheus/rules/*.yml

# 热加载
curl -X POST https://localhost:9090/-/reload

五、Node Exporter

# 启动
./node_exporter --web.listen-address=:9100

# 常用指标
node_cpu_seconds_total
node_memory_MemAvailable_bytes
node_memory_MemTotal_bytes
node_filesystem_size_bytes

六、快捷命令速查

用途 命令
查看Targets curl :9090/api/v1/targets
查询指标 curl :9090/api/v1/query?query=up
验证规则 promtool check rules rules/*.yml
热加载 curl -X POST :9090/-/reload
告警状态 curl :9090/api/v1/alerts
记录~
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇