使用PromDash创建服务器的度量仪表板

首先

使用Prometheus和PromDash来展示用于服务器监控的这样的仪表盘。

スクリーンショット 2017-04-23 23.40.31.png
    • さくらのクラウド(プラン/1Core-1GB)

 

    Ubuntu 16.04

192.168.x.12: Prometheus和PromDash
192.168.x.31-33: 被监控的服务器

スクリーンショット 2017-04-24 0.10.14.png

Prometheus的安装和启动

$ wget https://github.com/prometheus/prometheus/releases/download/v1.5.2/prometheus-1.5.2.linux-amd64.tar.gz
$ tar xzvf prometheus-1.5.2.linux-amd64.tar.gz
$ mv prometheus-1.5.2.linux-amd64 prometheus
$ vi prometheus.yml
$ nohup ./prometheus > prometheus.log 2>&1 &

请给出以下内容的本地化中文释义,只需要一个选项:
prometheus.yml文件的内容

# global config
global:
  scrape_interval:     30s #node_exporterなどに問い合わせる頻度
  evaluation_interval: 30s

  external_labels:
      monitor: 'codelab-monitor'

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first.rules"
  # - "second.rules"

# 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: 'server'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ['192.168.x.31:9100','192.168.x.32:9100','192.168.x.33:9100']

安装 node_exporter

在被监视的服务器上安装node_exporter。

$ wget https://github.com/prometheus/node_exporter/releases/download/v0.14.0/node_exporter-0.14.0.linux-amd64.tar.gz
$ tar -xzvf node_exporter-0.14.0.linux-amd64.tar.gz 
$ sudo ln -s ~/node_exporter/node_exporter-0.14.0.linux-amd64/node_exporter /usr/bin/

为了启动service node_exporter start,需要在/etc/systemd/system/node_exporter.service中写入以下内容。
我参考了这个Gist。

[Unit]
Description=Prometheus node exporter
After=local-fs.target network-online.target network.target
Wants=local-fs.target network-online.target network.target

[Service]
ExecStart=/usr/bin/node_exporter
Type=simple

[Install]
WantedBy=multi-user.target
$sudo systemctl list-unit-files
$sudo systemctl enable node_exporter.service
$sudo service node_exporter start

安装PromDash

在 Prometheus 的仪表盘上安装 Prometheus 仪表盘(PromDash)。

$sudo apt-get install sqlite3 libsqlite3-dev
$sudo apt-get install apt-transport-https ca-certificates
$sudo docker run -p 3000:3000 -v /tmp/prom:/tmp/prom -e DATABASE_URL=sqlite3:/tmp/prom/file.sqlite3 -d prom/promdash

对Basic认证进行设置

我会对全体人员进行基本认证。

安装nginx。

$sudo apt-get install nginx

创建.htpasswd文件。

$htpasswd -c .htpasswd user

将以下的nginx配置写在/etc/nginx/site-available/prometheus中。将example.com替换为自己服务器的DNS。将Prometheus定位到/api/路径,并将PromDash定位到根路径。

server {
    server_name example.com
    listen 0.0.0.0:80;
    location / {
      proxy_pass http://localhost:3000/;

      auth_basic "Prometheus";
      auth_basic_user_file ".htpasswd";
      proxy_set_header    X-Host       $host;
    }
    location /api/ { 
      proxy_pass http://localhost:9090/api/;

      auth_basic "Prometheus";
      auth_basic_user_file ".htpasswd";
      proxy_set_header    X-Host       $host;
    }

}
$sudo ln -s /etc/nginx/sites-available/prometheus /etc/nginx/sites-enabled/prometheus
$sudo service nginx restart

当您通过VPC等访问192.168.x.12时,将会显示仪表盘。

在PromDash上的配置

添加服务器

スクリーンショット 2017-04-24 8.28.19.png

图表增加

スクリーンショット 2017-04-24 9.18.47.png

普罗米修斯查询

    • ロードアベレージ: node_load1{job=~”server”}

ネットワーク受信rate(node_network_receive_bytes{job=~”server”}[5m])
ネットワーク送信rate(node_network_transmit_bytes{job=~”server”}[5m])

ファイルディスクリプタnode_filefd_allocated{job=~”server”}

メモリ関連node_memory_MemFree{job=~”server”}

ディスクReadrate(node_disk_reads_completed{job=~”server”}[5m])

ディスクWriterate(node_disk_write_completed{job=~”server”}[5m])

最后
最终
最后的时候
最后一步
终究
到最后
最晚
落幕时
最后的结局
最终结果

通过这个你可以方便地监控服务器。除了node_exporter之外,还有其他的选项,比如jmx_exporter,可以显示Java中运行的中间件(如cassandra)的度量信息。

请提供更多上下文以便我理解您需要重新表达的内容。

node_exporter:https://github.com/prometheus/node_exporter
node_exporter:https://github.com/prometheus/node_exporter

serviceの設定:https://gist.github.com/deviantony/2a2141ea32c1f601467e39d3a093d6ec
service的设置:https://gist.github.com/deviantony/2a2141ea32c1f601467e39d3a093d6ec

PromDash: https://github.com/prometheus-junkyard/promdash
PromDash:https://github.com/prometheus-junkyard/promdash

Prometheusのクエリ:https://prometheus.io/docs/querying/basics/
Prometheus的查询:https://prometheus.io/docs/querying/basics/

ベーシック認証をPrometheusとPromDashにかける:https://github.com/prometheus-junkyard/promdash/issues/341
为Prometheus和PromDash启用基本认证:https://github.com/prometheus-junkyard/promdash/issues/341

广告
将在 10 秒后关闭
bannerAds