監視するサーバーに node_exporter をDLしてインストールするまでは今までと同じ EC2_instance のサーバーを監視する場合にはちょっといままでと注意が必要かもしれないです。
node_exporter インストール手順(監視サーバー)
wget https://github.com/prometheus/node_exporter/releases/download/v0.15.1/node_exporter-0.15.1.linux-amd64.tar.gz tar zxvf node_exporter-0.15.1.linux-amd64.tar.gz cd node_exporter-0.15.1.linux-amd64 ./node_exporter で最後らへんに INFO[0000] Listening on :9100 source="node_exporter.go:76" とか出るので http://IP:9100 にブラウザから接続して確認
prometheus サーバー側の config ファイル
vim prometheus.yml
# 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: Æ'localhost:9090'Å
- job_name: 'client'
ec2_sd_configs:
# The information to access the EC2 API.
# The AWS Region.
- region: ap-northeast-1
# The AWS API keys. If blank, the environment variables `AWS_ACCESS_KEY_ID`
# and `AWS_SECRET_ACCESS_KEY` are used.
access_key: HOGEEEEEEEEEEE
secret_key: HOGEEEEEEEEEEE
port: 9100
プロメテウス側でターゲットを確認すると監視側のサーバー状況が確認できると思います。
ただ今回 ec2 の プライベート IP からの接続なので EC2 を建てるときにそのような設定をしてない場合はできないので注意です。


