GithubHelp home page GithubHelp logo

jeromer / riemann-go-client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from riemann/riemann-go-client

0.0 1.0 0.0 57 KB

Riemann Go client

License: MIT License

Makefile 1.68% Go 96.57% Shell 1.76%

riemann-go-client's Introduction

Riemann client (Golang)

Introduction

A Go client library for Riemann.

Features:

  • Idiomatic concurrency
  • Sending events, queries.
  • Support TCP, UDP, TLS clients.
  • Second and Microsecond time resolution

This client is a fork of Goryman, a Riemann go client written by Christopher Gilbert. Thanks and full credit to him!

The initial Goryman repository has been deleted. We've used @rikatz's fork to create this repository.

We've also renamed the client to riemanngo instead of goryman to make its purpose clearer.

Build Status

Build Status

Installation

To install the package for use in your own programs:

go get github.com/riemann/riemann-go-client

If you're a developer, Riemann uses Google Protocol Buffers, so make sure that's installed and available on your PATH.

go get github.com/golang/protobuf/{proto,protoc-gen-go}

Getting Started

First, we'll need to import the library:

import (
    "github.com/riemann/riemann-go-client"
)

Next, we'll need to establish a new client. The parameters are the Riemann address and the connection timeout duration. You can use a TCP client:

c := riemanngo.NewTcpClient("127.0.0.1:5555", 5*time.Second)
err := c.Connect()
if err != nil {
    panic(err)
}

Or a UDP client:

c := riemanngo.NewUdpClient("127.0.0.1:5555", 5*time.Second)
err := c.Connect()
if err != nil {
    panic(err)
}

You can also create a TLS client. The second parameter is the path to your client certificate, the third parameter the path to your client key. The next parameter allows you to create an insecure connection (insecure certificate check). The last parameter is the connect and write timeout. You can find more informations about how to configure TLS in Riemann here.

c := riemanngo.NewTlsClient("127.0.0.1:5554", "/path/to/cert.pem", "/path/to/key.key", true, 5*time.Second)
err := c.Connect()
if err != nil {
    panic(err)
}

Don't forget to close the client connection when you're done:

defer c.Close()

Sending events is easy (list of valid event properties):

result, err := riemanngo.SendEvent(c, &riemanngo.Event{
		Service: "hello",
		Metric:  100,
		Tags: []string{"riemann ftw"},
	})

The host name and time in events will automatically be replaced with the hostname of the server and the current time if none is specified.

You can also send batch of events:

events = []riemanngo.Event {
    riemanngo.Event{
        Service: "hello",
        Metric:  100,
        Tags: []string{"hello"},
    },
riemanngo.Event{
        Service: "goodbye",
        Metric:  200,
        Tags: []string{"goodbye"},
    },
}

You can also query the Riemann index (using the TCP or TLS client):

events, err := c.QueryIndex("service = \"hello\"")
if err != nil {
    panic(err)
}

Uint metric type

The event Metric value can have uint (or uint32, uint64) as type. In this case, this value will be converted to int64, which can cause issues.

Tests

You can lauch tests using

make test

and integration tests using:

make integ-test

This command will download Riemann, start it, launch integration tests, and kill it.

You can also use:

go test -tags=integration

if you already have a Riemann instance listening on localhost

Copyright

See LICENSE document

riemann-go-client's People

Contributors

mcorbin avatar jamtur01 avatar jeromer avatar pradeepchhetri avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.