Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/fenderdigital/logrus-redis-hook

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/fenderdigital/logrus-redis-hook

  • v0.0.0-20170918175336-1c73c0e5a4c4
  • Source
  • Go
  • Socket score

Version published
Created
Source

Redis Hook for Logrus :walrus:

Why?

Useful for centralized logging, using a RELK stack (Redis, Elasticsearch, Logstash and Kibana). When the hook is installed, all log messages are sent to a Redis server, in Logstash message V0 or V1 format, ready to be parsed/processed by Logstash.

Install

$ go get github.com/rogierlommers/logrus-redis-hook

Colored

Usage

package main

import (
	log "github.com/sirupsen/logrus"
	"github.com/rogierlommers/logrus-redis-hook"
)

func init() {
	hook, err := logredis.NewHook("localhost", 6379, "my_redis_key", "my_app_name")
	if err == nil {
		log.AddHook(hook)
	}
}

func main() {
	// when hook is injected succesfully, logs will be send to redis server
	log.Info("just some logging...")
}

Message types sent to redis

LogstashMessageV0
type LogstashMessageV0 struct {
	Type       string `json:"@type,omitempty"`
	Timestamp  string `json:"@timestamp"`
	Sourcehost string `json:"@source_host"`
	Message    string `json:"@message"`
	Fields     struct {
		Application string `json:"application"`
		File        string `json:"file"`
		Level       string `json:"level"`
	} `json:"@fields"`
}
LogstashMessageV1
type LogstashMessageV1 struct {
	Type        string `json:"@type,omitempty"`
	Timestamp   string `json:"@timestamp"`
	Sourcehost  string `json:"host"`
	Message     string `json:"message"`
	Application string `json:"application"`
	File        string `json:"file"`
	Level       string `json:"level"`
}

Testing

Please see the docker-compose directory for information about how to test. There is a readme inside.

License

MIT

FAQs

Package last updated on 18 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc