Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

jonathansp/go-metrics-logstash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-metrics logstash Build Status GoDoc

This package provides a reporter for the go-metrics library that will post the metrics to logstash. This library is based on go-metrics-datadog.

Installation

go get -u github.com/rcrowley/go-metrics
go get -u github.com/jonathansp/go-metrics-logstash

Usage

package main

import (
	"log"
	"time"

	metrics "github.com/rcrowley/go-metrics"
	"github.com/jonathansp/go-metrics-logstash"
)

func main() {
	registry := metrics.NewRegistry()

	metrics.RegisterDebugGCStats(registry)
	metrics.RegisterRuntimeMemStats(registry)

	reporter, err := logstash.NewReporter(
		registry,               // go-metrics registry, or nil
		"127.0.0.1:1984",       // logstash UDP address,
		map[string]interface{}{ // default values to be sent at each flush
			"client": "my-app",
		}
	)
	if err != nil {
		log.Fatal(err)
	}

	go metrics.CaptureDebugGCStats(registry, time.Second * 5)
	go metrics.CaptureRuntimeMemStats(registry, time.Second * 5)
	go reporter.FlushEach(time.Second * 10)

}

License

Distributed under the MIT license. See LICENSE file for details.

About

Logstash reporter for the go-metics library

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages