はじめに
OCI OpenSearchをPrometheusで監視する手順について説明します。
OCI OpenSearchは、高性能でスケーラブルな検索エンジンであり、全文検索、ベクトル検索、ログ分析等に広く使用されています。
Prometheusはオープンソースの監視ソリューションで、多様なシステムのメトリクスを収集・分析することができます。
OCIマネージドサービスであるSearch with OpenSearchは2024/7現在においてprometheus pluginに対応していないため、prometheus形式でのメトリクスを収集するために、elasticsearch exproterを使用します。
このツールを監視用サーバに入れて動かすことで、OpenSearchのapiエンドポイント(http:○○:9200)から、elasticsearch文脈でのメトリクスをスクレイピングして取得可能です。
取得できるメトリクスは上記リンクページにある「elasticsearch_*」の項目です。
環境構築
OpenSearchと監視用のサーバを1台用意します。
下記に手順を示します。なおバージョンは本記事執筆時点で最新のものです。
prometheus起動
wget https://github.com/prometheus/prometheus/releases/download/v2.53.1/prometheus-2.53.1.linux-amd64.tar.gz
tar xvfz prometheus-2.53.1.linux-amd64.tar.gz
prometheusのyamlファイルの末尾に以下を追記します↓
(前略)
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: "opensearch_exporter"
static_configs:
- targets: ["(exporter ip):9114"]
./prometheus --config.file=prometheus.yml
elastic exproter起動
wget https://github.com/prometheus-community/elasticsearch_exporter/releases/download/v1.7.0/elasticsearch_exporter-1.7.0.linux-amd64.tar.gz
tar xvfz elasticsearch_exporter-1.7.0.linux-amd64.tar.gz
例えば以下のように記述して実行します↓
export ES_USERNAME="(username)"
export ES_PASSWORD="(password)"
./elasticsearch_exporter --es.uri https://amaaaaaas......opensearch.us-ashburn-1.oci.oraclecloud.com:9200
結果確認
おわりに
OpenSearchをPrometheusで監視するための環境構築と設定手順について説明しました。
Prometheusを利用することで、OpenSearchの詳細なパフォーマンスデータを収集し、トラブルシューティングやパフォーマンスの最適化に役立てることができます。今回はgrafanaまでは入れていませんがOpenSearch監視の一案として参考になれば幸いです。