Giter VIP home page Giter VIP logo

fluent-bit-go-redis-output's Introduction

fluent-bit redis output plugin

Build Status codecov Go Report Card

This plugin is used to have redis output from fluent-bit. You can use fluent-bit redis instead of logstash in a configuration where you have a redis and optional stunnel in front of your elasticsearch infrastructure.

The configuration typically looks like:

fluent-bit --> stunnel --> redis <-- logstash --> elasticsearch

If you have multiple elastic search servers, each covered with a redis cache in front it might look like this:

           /-> stunnel --> redis <-- logstash --> elasticsearch 
           |
fluent-bit --> stunnel --> redis <-- logstash --> elasticsearch
           |
           \-> stunnel --> redis <-- logstash --> elasticsearch

Usage

docker run -it --rm -v /path/to/fluent-bit.conf:/fluent-bit/etc/fluent-bit.conf majst01/fluent-bit-go-redis-output

Building

docker build --no-cache --tag fluent-bit-go-redis-output .
docker run -it --rm -v /path/to/fluent-bit.conf:/fluent-bit/etc/fluent-bit.conf fluent-bit-go-redis-output

Configuration Options

Key Description Default
Hosts Host(s) of redis servers, whitespace separated ip/host:port 127.0.0.1:6379
Password Optional redis password for all redis instances ""
DB redis database (integer) 0
UseTLS connect to redis with tls False
TlsSkipVerify if tls is configured skip tls certificate validation for self signed certificates True
Key the key where to store the entries in redis "logstash"

Example:

add this section to fluent-bit.conf

[Output]
    Name redis
    Match *
    UseTLS true
    TLSSkipVerify true
    # if port is ommited, 6379 is used
    Hosts 172.17.0.1 172.17.0.1:6380 172.17.0.1:6381 172.17.0.1:6382 172.17.0.1:6383
    Password homer
    DB 0
    Key elastic-logstash

Useful links

Redis format

Logstash Redis Output

TODO

Strategies for redis connection error handling

  1. crash on connection errors

Given a list of 4 Redis databases, we pick on start a random one, if during operation this fails we panic and on restart the next hopefully working is selected.

  1. rely on FLB_RETRY

With a list of redis databases we can create a list of pools, one pool per database and instead of doing a pool.Get(), call list.Get() with selects the next random redis database. If a failure occurs return FLB_RETRY and the library will retry.

fluent-bit-go-redis-output's People

Contributors

burningalchemist avatar cosmo0920 avatar majst01 avatar ulrichschreiner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fluent-bit-go-redis-output's Issues

createJSON function does not prevent base64 encoding

A function createJSON has a code which should handle base64 encoding of data but it does not work for all cases.

The function is located here:

func createJSON(timestamp time.Time, tag string, record map[interface{}]interface{}) (*logmessage, error) {
m := make(map[string]interface{})
// convert timestamp to RFC3339Nano which is logstash format
m["@timestamp"] = timestamp.UTC().Format(time.RFC3339Nano)
m["@tag"] = tag
for k, v := range record {
switch t := v.(type) {
case []byte:
// prevent encoding to base64
m[k.(string)] = string(t)
default:
m[k.(string)] = v
}
}
js, err := json.Marshal(m)
if err != nil {
return nil, fmt.Errorf("error creating message for REDIS: %v", err)
}
return &logmessage{data: js}, nil
}

But for example data:

	mapInterface := map[interface{}]interface{}{
		"annotations": map[interface{}]interface{}{
			"checksum/config": [13]int{111, 98, 115, 101, 114, 118, 97, 98, 105, 108, 105, 116, 121},
			"namespace_name":  [13]int{111, 98, 115, 101, 114, 118, 97, 98, 105, 108, 105, 116, 121},
		},
	}

it will produce base64 encoding in values for keys "checksum/config", "namespace_name".

Recursive call would be needed here.

Such cases will occur often, it is enough to enable fluent-bit kubernetes filter plugin.

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.