Neo4j Monitoring Setup

Rushikesh Chavan
3 min readApr 12, 2021

Neo4j can be Monitored using Prometheus and Grafana.

The Neo4j Graph Database provides a complete set of metrics that allow continuous monitoring of status, performance, and usage of everything important, from transactions lifecycle, memory utilization, driver sessions all the way to cluster communication.

When you need to integrate with an existing monitoring infrastructure, it is not always possible or desirable to install new tools. As Prometheus becomes a widely used solution, it is likely to be the choice of preference in many organizations for storing and querying time series data. Grafana is also a very popular choice because it offers a single place to watch all metrics, whatever the source.

You can enable monitoring for a single node Neo4j database or a Neo4j Causal Cluster using the same procedure described below.

Step1: Configure Neo4j

Support for the powerful open source monitoring and alerting tool Prometheus was first introduced in Neo4j in version 3.4. This feature is only available in the Enterprise edition of Neo4j. You can enable it with these two entries to the neo4j.conf

# 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=<node-ip-address>:2004

For causal cluster include this setting in each of the nodes within the cluster. Use the respective endpoints in the settings as per the node.

Save these settings.

Step 2: Install Prometheus

Use the below guide to install and run Prometheus on the system eiri/README.md

Note: In the Causal Cluster, install Prometheus on only one node among the cluster (no need to install it on all the nodes).

Once installed, make the below configuration in the prometheus.yml file:

# A scrape configuration containing the Neo4j endpoint to scrape: scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'neo4j-prometheus'
scrape_interval: 10s
static_configs:
# target: ip address of the Neo4j server
- targets: ['<node1-ip-address>:2004','<node2-ip-address>:2004','<noden-ip-address>:2004']

Note: for causal cluster include all the nodes IP addresses in the ‘targets list’ above, for single node Neo4j db include only it’s IP address

Next, go to /etc/systemd/system and create a prometheus.service file and include the below setting in it:

[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target
[Service]
#User=root
#Group=root
Type=simple 10ExecStart=/etc/prometheus/prometheus \
--config.file /etc/prometheus/prometheus.yml \
--storage.tsdb.path /etc/prometheus/data \
--web.console.templates=/etc/prometheus/consoles \
--web.console.libraries=/etc/prometheus/console_libraries
[Install]
WantedBy=multi-user.target

Once done save the file and run the following command:
systemctl daemon-reload

Then restart all your neo4j nodes with the updated settings using the command:
service neo4j restart

Then start the Prometheus service using the command:
service prometheus start

Check if it is working by opening Prometheus browser at <ip-address>:9090 and visiting the Status/Targets page. It should list your ‘neo4j-prometheus’ job.

Step 3: Install Grafana

Install the latest version of Grafa-Enterprise using the below link:
https://grafana.com/docs/grafana/latest/installation/debian/

Once installed, configure the Grafa’s configuration file grafana.ini which will be located at /etc/grafana location:

[server]
# Protocol (http, https, h2, socket)
;protocol = http
# The ip address to bind to, empty will bind to all interfaces
http_addr = <node-IP-address>
# The http port to use
http_port = 9000

Note: In the Causal Cluster install Grafana on only one node among the cluster (no need to install it on all the nodes).

Then start the Grafana Service using the command:
service grafana-server start

Check if it is working by opening the Grafana browser at <ip-address>:9000
The initial credentials of Grafana are username — admin, password — admin. Log in with these credentials and then reset the username and password.

In order to verify that everything is working as expected, you can
1. Use the Explore page from the Grafana sidebar menu.
2. Choose Prometheus as the data source (input the address of the Prometheus server e.g. <ip-address>:9090).
3. Go to the Dashboard section from the sidebar and select import dashboard. Please download the dashboard JSON file from here and upload it in the import section.

It will look somewhat like this:

This completes your Neo4j Monitoring

--

--

Rushikesh Chavan

Certified Neo4j Developer | Full Stack Developer | Android Application Developer | Data Science Enthusiastic | NoSql | Elasticsearch | DotNet | SQL |