Prometheus を試した
Prometheus 導入
- https://prometheus.io/download/ から prometheus-2.11.1.windows-amd64.tar.gz ダウンロード。
- 解凍し prometheus.exe 実行
- ブラウザで http://localhost:9090/graph を開く
- クエリに
prometheus_target_interval_length_seconds
と入力し execute
Prometheus の監視の仕組み
scrape_configs: - job_name: prometheus honor_timestamps: true scrape_interval: 15s scrape_timeout: 10s metrics_path: /metrics <--- scheme: http <--- static_configs: - targets: - localhost:9090 <---
- scheme + targets + metrics_path を組み合わせる。 http://localhost:9090/metrics
- これをブラウザ等で確認。リロードすると数字が変化するのがわかる
# HELP go_gc_duration_seconds A summary of the GC invocation durations. # TYPE go_gc_duration_seconds summary go_gc_duration_seconds{quantile="0"} 0 go_gc_duration_seconds{quantile="0.25"} 0 go_gc_duration_seconds{quantile="0.5"} 0 go_gc_duration_seconds{quantile="0.75"} 0 go_gc_duration_seconds{quantile="1"} 0.001997 go_gc_duration_seconds_sum 0.0029972 go_gc_duration_seconds_count 15 # HELP go_goroutines Number of goroutines that currently exist. # TYPE go_goroutines gauge go_goroutines 42
というわけでPrometheusは設定scrape_configsの監視対象をプル(scrape)していることがわかる。
expoter 追加
- https://prometheus.io/download/ からテキトーなエキスポーター ... blackbox_exporter をダウンロード
- 監視対象(localhost)で blackbox_exporter を実行
- blackbox_exporter のコンソールを確認
Listening on address" address=:9115
と表示されていた - http://localhost:9115/metrics を確認
# HELP blackbox_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, and goversion from which blackbox_exporter was built. # TYPE blackbox_exporter_build_info gauge blackbox_exporter_build_info{branch="HEAD",goversion="go1.11.5",revision="bba7ef76193948a333a5868a1ab38b864f7d968a",version="0.14.0"} 1 # HELP blackbox_exporter_config_last_reload_success_timestamp_seconds Timestamp of the last successful configuration reload. # TYPE blackbox_exporter_config_last_reload_success_timestamp_seconds gauge blackbox_exporter_config_last_reload_success_timestamp_seconds 1.564051261737019e+09 # HELP blackbox_exporter_config_last_reload_successful Blackbox exporter config loaded successfully. # TYPE blackbox_exporter_config_last_reload_successful gauge blackbox_exporter_config_last_reload_successful 1
- ↑を監視対象(scrape)に追加。prometheus.yml を編集する
- job_name: 'blackbox' metrics_path: /metrics static_configs: - targets: ['localhost:9115']
- prometheus 再起動
- blackbox_exporter_build_info を execulte
まったく面白くないが監視対象は追加できた。
ここ http://localhost:9090/targets にも、balckbox が追加されている。
prometheus architecture
今回試したのはこのあたり