An open API service indexing awesome lists of open source software.

https://github.com/graphaware/neo4j-logging-logstash-elk


https://github.com/graphaware/neo4j-logging-logstash-elk

Last synced: 8 months ago
JSON representation

Awesome Lists containing this project

README

          

neo4j-logging-logstash-elk
=====================

The neo4j-logging-logstash-elk project provides a concrete implementation and documentation of how to configure [Neo4j](https://neo4j.com) to make use of [Logback](https://logback.qos.ch/) and [LogStash](https://www.elastic.co/products/logstash) to broadcast log statements to [ElasticSearch](https://www.elastic.co/)/[LogStash](https://www.elastic.co/products/logstash)/[Kibana](https://www.elastic.co/products/kibana) (ELK).

This implementation and configuration is performed at the Neo4j level, as opposed to configuring individual Neo4j module(s)/plugin(s), making the broadcasting of log statements to ELK available to all participating Neo4j modules/plugins.

These instructions have been tested using logstash-logback-encoder 4.8 and Neo4j Enterprise 3.0.6.

Making use of this project falls into three basic steps:

1) [Building this project](#building-this-project)

2) [Configure Neo4j](#configure-neo4j)

3) [Update your code](#update-your-code)

--------------------
## Building This Project

The neo4j-logging-logstash-elk project builds an uber jar containing all of the transitive dependencies required for the logstash-logback-encoder to function. This uber jar is then placed into the $neo4j_home/plugins directory, seamlessly providing Neo4j with all of the dependencies in one deployment.

To build this project and deploy it to your Neo4j instance(s):
```
git clone https://github.com/graphaware/neo4j-logging-logstash-elk
cd neo4j-logging-logstash-elk

mvn clean install

cp target/neo4j-logging-logstash-elk-*.jar $neo4j_home/plugin
```

--------------------
## Configure Neo4j

Neo4j (or perhaps more accurately, Logback) must be configured to make use of the logstash-logback-encoder. To do this, copy either the example below or the logback.xml file contained within this project to your Neo4j's config directory and customize as needed.

For convenient reference, below is an example logback.xml that outputs log statements to the console, to a file located in $neo4j_home/logs/application.log, and broadcasts to ELK on **192.168.99.100:5000**.

```



%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n


../logs/application.log
true

%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n

192.168.99.100:5000
5 minutes










```

Having performed the steps above to build the project, simply copy the above sample into $neo4j_home/config/logback.xml and restart Neo4j.

--------------------

## Update Your Code

In order for the logstash-logback-encoder to broadcast to ELK, the [SLF4j](https://www.slf4j.org) logging framework must be used rather than GraphAware's typically used org.neo4j.logging.Log, com.graphaware.common.log.LoggerFactory, or org.neo4j.logging.LogProvider classes.

This means that for your log statements to be broadcast to ELK your project **must** use:



import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

...
private static final Logger LOG = LoggerFactory.getLogger(Example.class);

rather than
```
import import org.neo4j.logging.Log;
import com.graphaware.common.log.LoggerFactory;
...
private static final Log LOG = LoggerFactory.getLogger(Example.class);
```
After performing the above code updates as well as following all sections of this document, rebuild and redeploy your Neo4j module/plugin and restart Neo4j. You will now see log statements appear in your console, the $neo4j_home/log/application.log, and within your running ELK instance available at [http://192.168.99.100:5601](http://192.168.99.100:5601).