メインコンテンツまでスキップ

ダッシュボードの設定

ヒント

Prometheus は、監視対象ターゲットのメトリック HTTP エンドポイントをスクレイピングして、監視対象からメトリックを収集する監視プラットフォームです。公式ドキュメントはこちらから入手できます。

Grafana は、収集されたデータを視覚化するために使用されるダッシュボードです。

警告

Grafanaはリレー1でなくても問題ありません。Grafanaサーバーを別で稼働させる場合はリレー1を読み替えてください。

PrometheusとGrafanaのインストール

Prometheus と Prometheus ノード エクスポーターをインストールします。

sudo apt install -y prometheus prometheus-node-exporter

Grafanaをインストールします。

sudo apt install -y apt-transport-https software-properties-common
sudo wget -q -O /usr/share/keyrings/grafana.key https://apt.grafana.com/gpg.key
echo "deb [signed-by=/usr/share/keyrings/grafana.key] https://apt.grafana.com stable main" > grafana.list
sudo mv grafana.list /etc/apt/sources.list.d/grafana.list
sudo apt update -y && sudo apt install -y grafana

サービスを有効にして自動的に開始されるようにします。

sudo systemctl enable grafana-server.service
sudo systemctl enable prometheus.service
sudo systemctl enable prometheus-node-exporter.service

Grafanaポートの開放

sudo ufw allow 3000/tcp
sudo ufw reload
  • prometheus-node-exporterのパスを取得します。
cd $HOME/git
node_exporter_path=`which prometheus-node-exporter`

/usr/bin/prometheus-node-exporter

  • 最新のnode_exporterをダウンロードします。

リリースページから最新のリリースを確認してください。

release_tag=$(curl -s https://api.github.com/repos/prometheus/node_exporter/releases/latest | jq -r .tag_name)
version=${release_tag#v}
echo "Release tag : ${release_tag}"
echo "Release version : ${version}"
wget https://github.com/prometheus/node_exporter/releases/download/${release_tag}/node_exporter-${version}.linux-amd64.tar.gz
  • ダウンロードファイルを解凍します。
tar xvf node_exporter-${version}.linux-amd64.tar.gz
  • サービスを停止します。
sudo systemctl stop prometheus-node-exporter.service
  • バイナリファイルをシステムフォルダへコピーします。
cd node_exporter-${version}.linux-amd64
sudo cp node_exporter ${node_exporter_path}
  • サービスをスタートします。
sudo systemctl start prometheus-node-exporter.service
  • ダウンロードファイルの削除
rm $HOME/git/node_exporter-${version}.linux-amd64.tar.gz
  • バージョンを確認します。
prometheus-node-exporter --version

node_exporter, version 1.8.2

  • /etc/prometheus/prometheus.ymlにあるprometheus.ymlを更新します。

以下の変数に各IPを代入します。

relay1_ipv4_or_dns=
relay2_ipv4_or_dns=
BP_ipv4=

Prometheusの設定ファイル作成

cat > $HOME/prometheus.yml << EOF
global:
scrape_interval: 15s # By default, scrape targets every 15 seconds.

# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels:
monitor: 'codelab-monitor'

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

static_configs:
- targets: ['${BP_ipv4}:9100']
labels:
alias: 'BP-Node'
type: 'system'
- targets: ['${relay1_ipv4_or_dns}:9100']
labels:
alias: 'Relay-1'
type: 'system'
- targets: ['${relay2_ipv4_or_dns}:9100']
labels:
alias: 'Relay-2'
type: 'system'
- targets: ['${BP_ipv4}:12798']
labels:
alias: 'BP-Node'
type: 'cardano-node'
- targets: ['${relay1_ipv4_or_dns}:12798']
labels:
alias: 'Relay-1'
type: 'cardano-node'
- targets: ['${relay2_ipv4_or_dns}:12798']
labels:
alias: 'Relay-2'
type: 'cardano-node'
EOF

prometheus.yml構文チェック

sudo promtool check config $HOME/prometheus.yml

ファイルを移動させます。

sudo mv $HOME/prometheus.yml /etc/prometheus/prometheus.yml

Grafanaプラグインのインストール

sudo grafana-cli plugins install yesoreyeram-infinity-datasource

サービス起動

sudo systemctl restart grafana-server.service
sudo systemctl restart prometheus.service
sudo systemctl restart prometheus-node-exporter.service

サービス起動確認

sudo systemctl --no-pager status grafana-server.service prometheus.service prometheus-node-exporter.service

3つのプログラムが 緑色 active (running) になっていること

備考

ポート転送とファイアウォールの設定に関する注意事項。

ブロック プロデューサー ノードのポート 12798 と 9100 は、Prometheus と Grafana をホストしている relaynode1 からアクセスできる必要があります。

  • ポート12798は、Cardano-NodeのPrometheusメトリック用です。
  • ポート9100は、ノードエクスポータメトリック用です。

Grafanaの設定

  1. ローカル ブラウザーで http://localhost:3000 (ssh トンネルを使用している場合、または relaynode1 上にある場合) または http://<your relaynode1 の IP アドレス>:3000 を開きます。
  2. usernameとPasswordは、admin / adminでログイン
  3. パスワードを変更します。
  4. 「Connections」配下の「Data sources」を選択します。
  5. Prometheusを選択
  6. 「Add data source」を選択し、検索窓に「Prometheus」と入力し、「Prometheus」を選択します。
  7. 名前はPrometheusとしてください。
  8. 「Connection」の入力欄に、 http://localhost:9090 を設定します。
  9. 「Save & test」を選択します。

Successfully queried the Prometheus API.

  1. 左ペインの「Data sources」をクリックします。
  2. 右上部の「+ Add new data source」を選択し、検索欄に「Infinity」と入力し、選択します。
  3. 「Save & Test」を選択し、以下が表示されたら成功です。

OK. Settings saved

  1. BPサーバーでGrafanaのPanel用JSONをダウンロードします。
cd $NODE_HOME
curl -s -o $NODE_HOME/mithril-signer-on-grafana-dashboard.json https://akyo3.github.io/AKYO/mainnet/dashboard/mithril-signer-on-grafana-dashboard.json
sed -i $NODE_HOME/mithril-signer-on-grafana-dashboard.json \
-e "s/bech32_id_of_your_pool/$(cat $NODE_HOME/pool-bech32.id)/g"
  1. BPのcnodeフォルダにあるmithril-signer-on-grafana-dashboard.jsonをローカルPCにダウンロードします。
  2. 左メニューの「Dashboards」→「New」→「+import」を選択します。
  3. 「Upload JSON file」をクリックし、10でダウンロードしたSJG_Grafana_Dashboard.jsonを指定します。
  4. 「Prometheus」と「Infinity」のプルダウンを選択しImportボタンを選択します。