使用Prometheus和Grafana监控服务器
本文最后更新于 186 天前,其中的信息可能已经有所发展或是发生改变。

Pixiv ID: 112582990 <レミリア?>
Pixiv User ID: 74265011 <Rie>

前言

本文使用的系统为 Arch Linux 部分包可能在您的系统不存在/低版本

安装Prometheus和Grafana

sudo pacman -S prometheus grafana

配置Grafana

1) 由于Prometheus的默认配置足够监控本机,因此不进行配置,但仍放出配置文件

# my global config
global:
  scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  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
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: ["127.0.0.1:9090"]

2) 启动服务

sudo systemctl enable prometheus grafana --now

3) 登陆Grafana

地址为 :3000 ,默认帐号密码 admin/admin 登陆会有要求设置新密码

4) 添加图表

在登陆后点击 Add new connection 搜索到 Prometheus

进入后点击 Add new data source ,在HTTP栏填入 http://127.0.0.1:9090 即Prometheus监听地址,在Other中更改HTTP method从POST改为GET,最后点击Save & test

保存后点击最上方的Dashboards,从三个中随便选一个导入

回到Dashboards即可查看监控

暂无评论

发送评论 编辑评论


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