精华 Neo4j 企业版因果集群监控方案 — Prometheus
发布于 4 年前 作者 yusonglin 1839 次浏览 来自 分享

v2-f736942928a808ff780f23a628144809_1200x500.jpg 经常有朋友问 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):

11.jpg

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 后,可看到如下图所示的输出信息: 12.jpg

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

4、启动 prometheus:

prometheus --config.file=prometheus.yml

1.png

5、 http://<Prometheus Server IP>:9090 启动 Prometheus 浏览器:

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

单击菜单Status→ Targets, 如下图所示: 3.png

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

Neo4j 集群的监控图如下: 当然,Neo4j 还有多种其它监控方案可以选择更多监控资料,请查看 Neo4j 官网文档。

转载请注明出处,谢谢。

更多技术咨询:

联系人:于先生 Email:yusonglin@we-yun.com 微信号:ysllong_0226 微云数聚网址:www.we-yun.com

回到顶部