https://github.com/graphaware/neo4j-logging-logstash-elk
https://github.com/graphaware/neo4j-logging-logstash-elk
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/graphaware/neo4j-logging-logstash-elk
- Owner: graphaware
- Created: 2017-02-09T17:06:07.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-06T20:05:44.000Z (over 9 years ago)
- Last Synced: 2025-03-15T12:44:54.756Z (over 1 year ago)
- Size: 27.3 KB
- Stars: 3
- Watchers: 23
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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).