Code Monkey home page Code Monkey logo

drill-logfile2's Introduction

Drill Logfile Plugin

Plugin for Apache Drill that allows Drill to read and query log files of any format.

If you wanted to analyze log files such as the MySQL log sample shown below using Drill, it may be possible using various string fucntions, or you could write a UDF specific to this data type as shown here: http://www.dremio.com/blog/querying-google-analytics-json-with-a-custom-sql-function/. However, this is time consuming, difficult and results in some unnecessarily complex queries.

070823 21:00:32       1 Connect     root@localhost on test1
070823 21:00:48       1 Query       show tables
070823 21:00:56       1 Query       select * from category
070917 16:29:01      21 Query       select * from location
070917 16:29:12      21 Query       select * from location where id = 1 LIMIT 1

This plugin will allow you to configure Drill to directly query logfiles of any configuration.

Installation:

This library has no dependencies, so simply build this using Maven by typing: mvn clean install -DskipTests Next, go to the targets/ directory and copy the .jar file to <path to drill>/jars/3rdParty/. Alternatively you can directly download the .jar file from the releases page here: https://github.com/cgivre/drill-logfile-plugin/releases.

Usage

After installing the .jar file, go to the server configuration and add the following section in the <extensions> section of dfs. In order to use the plugin, you will have to configure the dfs plugin on in your Storage Plugins section.

Configuration Options

  • pattern: This is the regular expression which defines how the log file lines will be split. You must enclose the parts of the regex in grouping parentheses that you wish to extract. Note that this plugin uses Java regular expressions and requires that shortcuts such as \d have an additional slash: ie \\d.
  • fieldNames: This is a list of field names which you are extracting. Note that you must have the same number of fields as extracting groups in your pattern.
  • dataTypes: This field allows you to define the data types for all the fields extracted from your log. You may either leave the list blank entirely, in which case all fields will be interpreted as VARCHAR or you must define a data tyoe for every field. At this time, it supports: INT or INTEGER, DOUBLE or FLOAT8, FLOAT or FLOAT4, VARCHAR, DATE, TIME, and TIMESTAMP.
  • dateFormat: This defines the default date format which will be used to parse dates. Leave blank if not needed.
  • timeFormat: This defines the default time format which will be used to parse time. Leave blank if not needed.
  • type: This tells Drill which extension to use. In this case, it must be log.
  • extensions: This option tells Drill which file extensions should be mapped to this configuration. Note that you can have multiple configurations of this plugin to allow you to query various log files.
  • errorOnMismatch: False by default, but allows the option of either throwing an error on lines that don't match the pattern or dumping the line to a field called unmatched_lines when false.

Example Usage:

The configuration below demonstrates how to configure Drill to query the example MySQL log file shown above.

"log" : {
      "type" : "log",
      "extensions" : [ "log" ],
      "fieldNames" : [ "date", "time", "pid", "action", "query" ],
      "dataTypes" : [ "DATE", "TIME", "INT", "VARCHAR", "VARCHAR" ],
      "dateFormat" : "yyMMdd",
      "timeFormat" : "HH:mm:ss",
      "pattern" : "(\\d{6})\\s(\\d{2}:\\d{2}:\\d{2})\\s+(\\d+)\\s(\\w+)\\s+(.+)",
      "errorOnMismatch" : false
      }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.