Neo4j Slow Queries Monitor and more

  1. The server load — the strain on the machine hosting Neo4j.
  2. The Neo4j load — the strain on Neo4j.
  3. The cluster health — to ensure the cluster is working as expected.
  4. The workload of a Neo4j instance.

Additional metrics…

Out of the hundreds ( !!! ) of metrics available to us we found that there is still something missing for us.
One of those is the ability to monitor queries running inside the Neo4j system and to have alerts based on that.


The first thing we need to do is find out the namespace in which the pod is running with our application. By default the namespace to be used is placed in a file at /var/run/secrets/ in each container running in the Kubernetes cluster. Let’s use the following command to assign this value to a variable:

Database Statuses

The first thing that we would like to have in monitoring and what is not out of the box is database statuses. The database may go into a state other than “online” and we would like to have a notification from monitoring about this.

Long-running queries

The second important thing is monitoring slow requests, we will do so to monitor queries running for more than 10 seconds. First, let’s define a variable for storing such queries:

Generating a page with metrics

And eventually we generate a page with metrics for Prometheus at /metrics:

Code and Dashboard

The full program can be found in this repository including a dedicated Grafana dashboard:


Thus, by adding this small Pod with an exporter to each of our Neo4j clusters, we automatically expanded the current monitoring implementation. This improved the convenience for the development team as they were able to observe potentially problematic long-running queries in real time, and the SRE team was able to receive notifications about databases in a non-online state.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store