raidman

package module
v0.0.0-...-c74861f Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2016 License: Unlicense Imports: 14 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           `json:"ttl,omitempty"`
	Time        int64             `json:"time,omitempty"`
	Tags        []string          `json:"tags,omitempty"`
	Host        string            `json:"host,omitempty"` // Defaults to os.Hostname()
	State       string            `json:"state,omitempty"`
	Service     string            `json:"service,omitempty"`
	Metric      interface{}       `json:"metric,omitempty"` // Could be Int, Float32, Float64
	Description string            `json:"description,omitempty"`
	Attributes  map[string]string `json:"attributes,omitempty"`
}

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