Grok

Simple API that allows you to easily parse logs and other files

License

License

Categories

Categories

Graylog Application Layer Libs Logging
GroupId

GroupId

org.graylog2.repackaged
ArtifactId

ArtifactId

grok
Last Version

Last Version

0.1.9-graylog-2
Release Date

Release Date

Type

Type

jar
Description

Description

Grok
Simple API that allows you to easily parse logs and other files
Project URL

Project URL

http://maven.apache.org
Source Code Management

Source Code Management

https://github.com/graylog-labs/java-grok

Download grok

How to add to project

<!-- https://jarcasting.com/artifacts/org.graylog2.repackaged/grok/ -->
<dependency>
    <groupId>org.graylog2.repackaged</groupId>
    <artifactId>grok</artifactId>
    <version>0.1.9-graylog-2</version>
</dependency>
// https://jarcasting.com/artifacts/org.graylog2.repackaged/grok/
implementation 'org.graylog2.repackaged:grok:0.1.9-graylog-2'
// https://jarcasting.com/artifacts/org.graylog2.repackaged/grok/
implementation ("org.graylog2.repackaged:grok:0.1.9-graylog-2")
'org.graylog2.repackaged:grok:jar:0.1.9-graylog-2'
<dependency org="org.graylog2.repackaged" name="grok" rev="0.1.9-graylog-2">
  <artifact name="grok" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.graylog2.repackaged', module='grok', version='0.1.9-graylog-2')
)
libraryDependencies += "org.graylog2.repackaged" % "grok" % "0.1.9-graylog-2"
[org.graylog2.repackaged/grok "0.1.9-graylog-2"]

Dependencies

compile (3)

Group / Artifact Type Version
org.apache.commons : commons-lang3 jar 3.7
org.slf4j : slf4j-api jar 1.7.21
com.github.tony19 : named-regexp jar 0.2.3

test (3)

Group / Artifact Type Version
junit : junit jar 4.12
org.assertj : assertj-core jar 3.9.1
com.google.guava : guava jar 24.0-jre

Project Modules

There are no modules declared in this project.

Grok

Build Status

Java Grok is simple API that allows you to easily parse logs and other files (single line). With Java Grok, you can turn unstructured log and event data into structured data (JSON).


What can I use Grok for?

  • reporting errors and other patterns from logs and processes
  • parsing complex text output and converting it to json for external processing
  • apply 'write-once use-everywhere' to regular expressions
  • automatically providing patterns for unknown text inputs (logs you want patterns generated for future matching)

Maven repository

<dependency>
  <groupId>io.krakens</groupId>
  <artifactId>java-grok</artifactId>
  <version>0.1.9</version>
</dependency>

Or with gradle

compile "io.krakens:java-grok:0.1.9"

Old release (Link)

Usage (Grok java documentation)

Example of how to use java-grok:

/* Create a new grokCompiler instance */
GrokCompiler grokCompiler = GrokCompiler.newInstance();
grokCompiler.registerDefaultPatterns();

/* Grok pattern to compile, here httpd logs */
final Grok grok = grokCompiler.compile("%{COMBINEDAPACHELOG}");

/* Line of log to match */
String log = "112.169.19.192 - - [06/Mar/2013:01:36:30 +0900] \"GET / HTTP/1.1\" 200 44346 \"-\" \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.152 Safari/537.22\"";

Match gm = grok.match(log);

/* Get the map with matches */
final Map<String, Object> capture = gm.capture();

Build Java Grok

Java Grok support Gradle: ./gradlew assemble

Getting help

Mailling List

Thanks to

Any contributions are warmly welcome

Grok is inspired by the logstash inteceptor or filter available here

org.graylog2.repackaged

Graylog Labs

Graylog related repositories that are not officially supported yet

Versions

Version
0.1.9-graylog-2
0.1.9-graylog-1
0.1.9-graylog
0.1.8-graylog
0.1.7-graylog
0.1.6-graylog
0.1.3-graylog
0.1.2-graylog