filtergrok

package
v0.0.0-...-c13075e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 5 Imported by: 1

README

gogstash grok filter module

Synopsis

filter:
  - type: grok
    # (optional) grok patterns, default: ["%{COMMONAPACHELOG}"]
    match: ["%{COMMONAPACHELOG}"]
    # (optional) message field to parse, default: "message"
    source: "message"
    # (optional) grok patterns file path, default: empty
    patterns_path: "path/to/file"

NOTICE: If you using yaml config file, \ should be written in \\ in match patterns. For example: "\\[%{HTTPDATE:nginx.access.time}\\]".

Faster grok parser

If you need faster grok parse speed (by using C code binding regexp library: Onigmo), you can compile gogstash from source code.

A Dockerfile example:

FROM golang:alpine

ARG version

RUN apk --update add --no-cache ca-certificates git tzdata build-base

# build onigmo
WORKDIR /src/build/
RUN git clone https://github.com/k-takata/Onigmo.git --depth=1 \
  && cd Onigmo && ./configure && make && make install

WORKDIR /go/src/github.com/tsaikd/gogstash
COPY . /go/src/github.com/tsaikd/gogstash
RUN sed -i -e 's/github.com\/vjeantet\/grok/github.com\/tengattack\/grok/' /go/src/github.com/tsaikd/gogstash/filter/grok/filtergrok.go \
  && go get -d -v ./...
RUN go build -ldflags "-X main.Version=$version"

Documentation

Index

Constants

View Source
const ErrorTag = "gogstash_filter_grok_error"

ErrorTag tag added to event when process module failed

View Source
const ModuleName = "grok"

ModuleName is the name used in config file

Variables

This section is empty.

Functions

func InitHandler

func InitHandler(
	ctx context.Context,
	raw config.ConfigRaw,
	control config.Control,
) (config.TypeFilterConfig, error)

InitHandler initialize the filter plugin

Types

type FilterConfig

type FilterConfig struct {
	config.FilterConfig

	PatternsPath      string            `json:"patterns_path"`       // path to patterns file
	Patterns          map[string]string `json:"patterns"`            // pattern definitions
	Match             []string          `json:"match"`               // match pattern
	Source            string            `json:"source"`              // source message field name
	RemoveEmptyValues bool              `json:"remove_empty_values"` // remove empty values
	// contains filtered or unexported fields
}

FilterConfig holds the configuration json fields and internal objects

func DefaultFilterConfig

func DefaultFilterConfig() FilterConfig

DefaultFilterConfig returns an FilterConfig struct with default values

func (*FilterConfig) Event

Event the main filter event

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL