d1dbe421038146dc983a2fd70fa36cca

经常有朋友问 Neo4j 部署完成后,怎么来实时监控服务运行状态呢?本文将简单介绍 Prometheus 的部署及使用,为朋友们解惑。

Prometheus【普罗米修斯】是一项 SoundCloud 开源的监控和报警解决方案,能够实现与当下最流行的 Kubernetes 无缝连接,使得 Prometheus 逐渐成为主流监控方案。

从 Neo4j Enterprise 3.4 版本,可以使用开源工具 Prometheus 来对 Neo4j 运行状况进行监控。本文详细介绍了 Prometheus 的基本实现,以演示 Prometheus v2.17.1 和 Neo4j 之间的连接。

我的环境是:Mac Catalina 10.15.3,Neo4j Enterprise 3.5.14。

1、下载 prometheus-2.17.1.linux-amd64.tar.gz( 57.4M ) :

42d2a43cf2a140b2bd43d0b875f1efff

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 :. # The default is localhost:2004. metrics.prometheus.endpoint=localhost:2004

启动 Neo4j 后,可看到如下图所示的输出信息:

4ea7944b6f154912bd4d27df345f1de8

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=` 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 文件中对 “localhost” 的配置替换为 Neo4j 实例的 IP 地址。

4、启动 prometheus:

prometheus --config.file=prometheus.yml

65cfebab5fd846a19cd5668c194e1f34

5、 http://:9090 启动 Prometheus 浏览器:

打开 localhost:9090 就可以看到 prometheus 的监控页面。

331039dddc024ee085bcec1873904d30

单击菜单Status→ Targets,看到“Neo4j-prometheus (1/1 up)”,“State”“UP”, 则监控状态正常。如下图所示:

ca33b2941139413581cfd732c0f19ae0

点击菜单Graph,可以选择一个图表来监控 Neo4j 运行状态。例如,在下图中,该图表示已启动的事务数(neo4j_transaction_started):

9696456ab9674cf8910b9afcbbb8adc3

更多监控资料,请查看 Neo4j 官网文档。​neo4j.com

转载请注明出处,谢谢。

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐