Skip to content

divolgin/gostash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

gostash

logstash client written in Go

Examples

Calling gostash directly

package main

import (
	"github.com/divolgin/gostash"
)

func main() {
	config := gostash.Config{}
	config.LogstashHost = "logstash_host"
	config.LogstashPort = "9125"
	config.InputType = "mylogformat"

	logstash := gostash.NewLogstashClient(&config)
	defer logstash.Close()

	metadata := map[string]string{
		"host.name": "myserver",
		"pid":       "345",
	}

	logstash.SendMessage("message logged from myserver by process 345", metadata)
}

Logging with loggo

package main

import (
	"github.com/divolgin/gostash"
	"github.com/lookio/loggo"
)

func main() {
	config := gostash.Config{}
	config.LogstashHost = "logstash_host"
	config.LogstashPort = "9125"
	config.InputType = "mylogformat"

	logstash := gostash.NewLogstashClient(&config)
	loggoWriter := loggo.NewSimpleWriter(logstash, logstash.Formatter())
	loggo.RegisterWriter("logstash", loggoWriter, loggo.DEBUG)

	logger := loggo.GetLogger("")
	logger.Debugf("this message will be sent to logstash")
	logger.Errorf("this message will be printed to console and sent to logstash")
}

About

logstash client written in Go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages