8.1. Metrics

This section describes how to log and display various metrics by using the Neo4j metrics output facilities.

This section describes the following:

8.1.1. Enable metrics logging

Neo4j can be configured to report metrics in two different ways:

  • Send metrics to Graphite or any monitoring tool based on the Graphite protocol.
  • Export metrics to CSV files.

Neo4j can expose metrics for the following parts of the database:

# Setting for enabling all supported metrics.

# Setting for enabling all Neo4j specific metrics.

# Setting for exposing metrics about transactions; number of transactions started, committed, etc.

# Setting for exposing metrics about the Neo4j page cache; page faults, evictions, flushes and exceptions, etc.

# Setting for exposing metrics about approximately entities are in the database; nodes, relationships, properties, etc.

# Setting for exposing metrics about the network usage of the HA cluster component.
metrics.neo4j.network.enabled=true Graphite

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

# Enable the Graphite integration. Default is 'false'.
# 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.
# How often to send data. Default is 3 seconds.
# Prefix for Neo4j metrics on Graphite server.

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. 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 'false'.
# Directory path for output files.
# Default is a "metrics" directory under NEO4J_HOME.
# How often to store data. Default is 3 seconds.

The CSV exporter does not automatically rotate the output files. When enabling the CSV exporter, it is recommended to configure a job to periodically archive the files.