graphite

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

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

Go to latest
Published: Jan 14, 2018 License: Apache-2.0 Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-graphite-client

Package go-graphite-client is a simple client used to send mertics to graphite server using TCP or UDP. It could be used to send a single metric or batch of mertics.

Installation

To install go-graphite-client:

go get github.com/almariah/go-graphite-client

Examples

To send single metric:

To send batch of metrics:

Example:

package main

import (
  "github.com/almariah/go-graphite-client"
  "fmt"
)

func main() {

  // craete client
  client := &Client{
    Host: graphiteHost,
    Port: graphitePort,
    Protocol: TCP,
  }

  // connect a graphite server
  err := client.Connect()
  if err != nil {
    fmt.Println(err)
    os.Exit(1)
  }

  // send Metric
  client.Send("stats.test.metric", "1")         

}

Documentation

Overview

Package go-graphite-client is a simple client used to send mertics to graphite server using TCP or UDP. It could be used to send a single metric or batch of mertics.

Example:

package main

import (
    "github.com/almariah/go-graphite-client"
    "fmt"
)

func main() {

    // craete client
    client := &Client{Host: graphiteHost, Port: graphitePort, Protocol: TCP}

    // connect a graphite server
    err := client.Connect()
    if err != nil {
        fmt.Println(err)
        exit
    }

    client.Send("stats.test.metric", "1")
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Host       string
	Port       int
	Protocol   string
	Timeout    time.Duration
	Connection net.Conn
}

Client defines a graphite client

func (*Client) Connect

func (client *Client) Connect() error

Connect is used to connect to graphite server

func (*Client) Disconnect

func (client *Client) Disconnect() error

Disconnect is used to disconnect to graphite server

func (*Client) Send

func (client *Client) Send(stat string, value string) error

func (*Client) SendMetric

func (client *Client) SendMetric(metric Metric) error

type Metric

type Metric struct {
	Name      string
	Value     string
	Timestamp int64
}

Mertic defines a graphite metric of name, value and timestamp

Jump to

Keyboard shortcuts

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