知识库

如何使用 Prometheus 监控 Neo4j

从 Neo4j Enterprise 3.4 版发布开始,现在可以使用开源监控工具 Prometheus 来监控 Neo4j。以下文章详细介绍了一个基本的 Prometheus 实现,以演示 Prometheus v2.2.1 与 Neo4j 之间的连接。

安装 Prometheus 后,需要通过 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

并且 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 安装在同一服务器上。如果您选择在不同的服务器上安装,只需将上文中的 localhost 替换为 Neo4j 实例的 IP 地址。

http://的 Prometheus 服务器:9090 打开 Prometheus 浏览器,点击菜单选项 StatusTargets 应显示

image

返回到第 3 个菜单项 Graphs,可以定义一个图表来监控 Neo4j 指标。例如,下图中的图表表示已启动的事务数量(neo4j_transaction_started)

image

© . This site is unofficial and not affiliated with Neo4j, Inc.