raidman

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2015 License: Unlicense, MIT Imports: 12 Imported by: 0

README

Raidman

Go Riemann client

package main

import (
        "github.com/amir/raidman"
)

func main() {
        c, err := raidman.Dial("tcp", "localhost:5555")
        if err != nil {
                panic(err)
        }

        var event = &raidman.Event{
                State:   "success",
                Host:    "raidman",
                Service: "raidman-sample",
                Metric:  100,
                Ttl:     10,
        }

        // send one event
        err = c.Send(event)
        if err != nil {
                panic(err)
        }
        
        // send multiple events at once
        err = c.SendMulti([]*raidman.Event{
                &raidman.Event{
                        State:   "success",
                        Host:    "raidman",
                        Service: "raidman-sample",
                        Metric:  100,
                        Ttl:     10,
                },
                &raidman.Event{
                        State:   "failure",
                        Host:    "raidman",
                        Service: "raidman-sample",
                        Metric:  100,
                        Ttl:     10,
                },
                &raidman.Event{
                        State:   "success",
                        Host:    "raidman",
                        Service: "raidman-sample",
                        Metric:  100,
                        Ttl:     10,
                },
        })
        if err != nil {
                panic(err)
        }

        events, err := c.Query("host = \"raidman\"")
        if err != nil {
                panic(err)
        }

        if len(events) < 1 {
                panic("Submitted event not found")
        }

        c.Close()
}

Documentation

Overview

Go Riemann client

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Client represents a connection to a Riemann server

func Dial

func Dial(netwrk, addr string) (c *Client, err error)

Dial establishes a connection to a Riemann server at addr, on the network netwrk.

Known networks are "tcp", "tcp4", "tcp6", "udp", "udp4", and "udp6".

func DialWithTimeout

func DialWithTimeout(netwrk, addr string, timeout time.Duration) (c *Client, err error)

Dial establishes a connection to a Riemann server at addr, on the network netwrk, with a timeout of timeout

Known networks are "tcp", "tcp4", "tcp6", "udp", "udp4", and "udp6".

func (*Client) Close

func (c *Client) Close()

Close closes the connection to Riemann

func (*Client) Query

func (c *Client) Query(q string) ([]Event, error)

Query returns a list of events matched by query

func (*Client) Send

func (c *Client) Send(event *Event) error

Send sends an event to Riemann

func (*Client) SendMulti

func (c *Client) SendMulti(events []*Event) error

SendMulti sends multiple events to Riemann

type Event

type Event struct {
	Ttl         float32
	Time        int64
	Tags        []string
	Host        string // Defaults to os.Hostname()
	State       string
	Service     string
	Metric      interface{} // Could be Int, Float32, Float64
	Description string
	Attributes  map[string]string
}

An Event represents a single Riemann event

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL