Expose metrics

This chapter describes how to expose the metrics using the default and third-party monitoring tools.

Neo4j supports the following ways of exposing data for monitoring purposes:

  • CSV files — retrieve metrics from CSV files (true by default).

  • JMX MBeans — expose metrics over JMX MBeans (true by default).

  • Graphite — send metrics to Graphite or any monitoring tool based on the Graphite protocol (false by default).

  • Prometheus — publish metrics for polling as Prometheus endpoint (false by default).

CSV files

Export metrics to CSV files.

Add the following settings to neo4j.conf in order to enable export of metrics into local .CSV files:

# Enable the CSV exporter. Default is 'true'.
metrics.csv.enabled=true
# Directory path for output files.
# Default is a "metrics" directory under NEO4J_HOME.
#dbms.directories.metrics='/local/file/system/path'
# How often to store data. Default is 30 seconds.
metrics.csv.interval=30s
# The maximum number of CSV files that will be saved. Default is 7.
metrics.csv.rotation.keep_number=7
# The file size at which the csv files will auto-rotate. Default is 10M.
metrics.csv.rotation.size=10M
# Compresses the metric archive files.
metrics.csv.rotation.compression=zip

metrics.csv.rotation.compression selects the compression scheme to use on the files after rotation. Since CSV files are highly compressible, it is recommended to enable compression of the files to save disk space.

JMX MBeans

From version 4.2.2 onwards, the JMX metrics are exposed by default over JMX MBeans.

Graphite

Send metrics to Graphite or any monitoring tool based on the Graphite protocol.

Add the following settings to neo4j.conf in order to enable integration with Graphite:

# Enable the Graphite integration. Default is 'false'.
metrics.graphite.enabled=true
# The IP and port of the Graphite server on the format <hostname or IP address>:<port number>.
# The default port number for Graphite is 2003.
metrics.graphite.server=localhost:2003
# How often to send data. Default is 30 seconds.
metrics.graphite.interval=30s
# Prefix for Neo4j metrics on Graphite server.
metrics.prefix=Neo4j_1

Start Neo4j and connect to Graphite via a web browser in order to monitor your Neo4j metrics.

If you configure the Graphite server to be a hostname or DNS entry you should be aware that the JVM resolves hostnames to IP addresses and by default caches the result indefinitely for security reasons. This is controlled by the value of networkaddress.cache.ttl in the JVM Security properties. See https://docs.oracle.com/javase/8/docs/technotes/guides/net/properties.html for more information.

Prometheus

Publish metrics for polling as Prometheus endpoint.

Add the following settings to neo4j.conf in order to enable the Prometheus endpoint.

# 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

When Neo4j is fully started, a Prometheus endpoint will be available at the configured address.