Skip to content

Latest commit

 

History

History
45 lines (34 loc) · 1.18 KB

README.md

File metadata and controls

45 lines (34 loc) · 1.18 KB

godoc license CodeFactor

Go Graylog package

This package implement Graylog GELF interface to send message using UDP or TCP transport, in Golang.

Example

package main

import (
	"github.com/thomasdseao/go-graylog"
)

func main() {
	// Create Gelf instance
	gelf := graylog.NewGelf(graylog.Config{
		"graylog1.example.com",
		2202,
		graylog.UDP,
		true,
	})
    
	// Create message and JSON encode it
	message := graylog.Message{
		Version:      "1.1",
		Host:         "example.com",
		ShortMessage: "This is the short message",
	}
	jsonMessage, _ := json.Marshal(message)
	
	// Send message
	sent, err := gelf.Send(jsonMessage)

}

Tests

go test

Contribute

Feel free to submit PR with another implementations of Graylog or improvements.