Skip to content
AWS Kinesis hooks for logrus
Go
Branch: master
Clone or download
Latest commit 428603d Jun 20, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.travis.yml Initial commit Sep 9, 2016
LICENSE Initial commit Sep 9, 2016
README.md Update import path Sirupsen -> sirupsen Jun 20, 2017
config.go Add async and filter Sep 9, 2016
config_test.go Initial commit Sep 9, 2016
hook.go Update import path Sirupsen -> sirupsen Jun 20, 2017
hook_test.go Update import path Sirupsen -> sirupsen Jun 20, 2017

README.md

logrus_kinesis

Build Status Coverage Status codecov GoDoc

AWS Kinesis Hook for Logrus :walrus:

Usage

import (
    "github.com/evalphobia/logrus_kinesis"
    "github.com/sirupsen/logrus"
)

func main() {
    hook, err := logrus_kinesis.New("my_stream", Config{
        AccessKey: "ABC", // AWS accessKeyId
        SecretKey: "XYZ", // AWS secretAccessKey
        Region:    "ap-northeast-1",
    })

    // set custom fire level
    hook.SetLevels([]logrus.Level{
        logrus.PanicLevel,
        logrus.ErrorLevel,
    })

    // ignore field
    hook.AddIgnore("context")

    // add custome filter
    hook.AddFilter("error", logrus_kinesis.FilterError)


    // send log with logrus
    logger := logrus.New()
    logger.Hooks.Add(hook)
    logger.WithFields(f).Error("my_message") // send log data to kinesis as JSON
}

Special fields

Some logrus fields have a special meaning in this hook.

message if message is not set, entry.Message is added to log data in "message" field.
stream_name stream_name is a custom stream name for Kinesis. If not set, defaultStreamName is used as stream name.
partition_key partition_key is a custom partition key for Kinesis. If not set, defaultStreamName or entry.Message is used as stream name.
You can’t perform that action at this time.