Skip to content

cryptowatch/go-graylog

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

go-graylog

GoDoc

Graylog GELF messages sending using UDP, TCP or TCP/TLS, written in Golang.

Examples

package main

import (
	"time"

	"github.com/Devatoria/go-graylog"
)

func main() {
    // Initialize a new graylog client with TLS
	g, err := graylog.NewGraylogTLS(graylog.Endpoint{
		Transport: graylog.TCP,
		Address:   "localhost",
		Port:      12202,
	}, 3*time.Second, nil)
	if err != nil {
		panic(err)
	}

    // Send a message
	err = g.Send(graylog.Message{
		Version:      "1.1",
		Host:         "localhost",
		ShortMessage: "Sample test",
		FullMessage:  "Stacktrace",
		Timestamp:    time.Now().Unix(),
		Level:        1,
		Extra: map[string]string{
			"MY-EXTRA-FIELD": "extra_value",
		},
	})
    if err != nil {
        panic(err)
    }

    // Close the graylog connection
    if err := g.Close(); err != nil {
        panic(err)
    }
}

About

Graylog GELF messages sending using UDP, TCP or TCP/TLS, written in Golang.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%