經常有朋友問 Neo4j 部署完成后,怎么來實時監(jiān)控服務運行狀態(tài)呢?本文將簡單介紹 Prometheus 的部署及使用,為朋友們解惑杆查。
Prometheus【普羅米修斯】,是一項 SoundCloud 開源的監(jiān)控和報警解決方案宴咧,能夠實現(xiàn)與當下最流行的 Kubernetes 無縫連接根灯,使得 Prometheus 逐漸成為主流監(jiān)控方案。
從 Neo4j Enterprise 3.4 版本掺栅,可以使用開源工具 Prometheus 來對 Neo4j 運行狀況進行監(jiān)控烙肺。本文詳細介紹了 Prometheus 的基本實現(xiàn),以演示 Prometheus v2.17.1 和 Neo4j 之間的連接氧卧。
我的環(huán)境是:Mac Catalina 10.15.3桃笙,Neo4j Enterprise 3.5.14。
1沙绝、下載 prometheus-2.17.1.linux-amd64.tar.gz (57.4M):
2搏明、修改neo4j.conf文件,配置以下參數闪檬,并啟動 Neo4j :
# Enable the Prometheus endpoint. Default is 'false'.
metrics.prometheus.enabled=true
# The IP and port the endpoint will bind to in the format <hostname or IP address>:<port number>.
# The default is localhost:2004.
metrics.prometheus.endpoint=localhost:2004
啟動 Neo4j 后星著,可看到如下圖所示的輸出信息:
3、解壓 prometheus-2.17.1.linux-amd64.tar.gz
修改 prometheus 的prometheus.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: 'Neo4j-prometheus'
# metrics_path: /metrics
# scheme defaults to 'http'.
static_configs: - targets: ['localhost:2004']
注意:上面的配置是假設 Prometheus 與 Neo4j 部署在同一服務器上虚循, 如果部署在不同的服務器,只需將 prometheus.yml 文件中對 “l(fā)ocalhost” 的配置替換為 Neo4j 實例的 IP 地址样傍。
4横缔、啟動 prometheus:
prometheus --config.file=prometheus.yml
5、 http://<Prometheus Server IP>:9090 啟動 Prometheus 瀏覽器:
打開 localhost:9090 就可以看到 prometheus 的監(jiān)控頁面衫哥。
單擊菜單Status→ Targets茎刚, 如下圖所示:
點擊菜單Graph,可以選擇一個圖表來監(jiān)控 Neo4j 運行狀態(tài)撤逢。例如膛锭,在下圖中,該圖表示已啟動的事務數(neo4j_transaction_started):
更多監(jiān)控資料蚊荣,請查看 Neo4j 官網文檔初狰。
轉載請注明出處,謝謝妇押。