Help us shape the future of Go! Take the 2026 Go Developer Survey

graphite

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: Apache-2.0 Imports: 4 Imported by: 6

README

go-graphite-client Build Status Coverage Status

go-graphite-client - Simple Golang graphite client.

Example usage (also present in example_text.go)

package main

import (
	"log"

	graphite "github.com/jtaczanowski/go-graphite-client"
)

func main() {
	graphiteClient := graphite.NewClient("localhost", 2003, "metrics.prefix", "tcp")

	// metrics
	exampleMetric1 := map[string]float64{"test_metric": 1234.1234}
	exampleMetric2 := map[string]float64{"test_metric2": 12345.12345}
	// list of the metrics
	metricsToSend := []map[string]float64{exampleMetric1, exampleMetric2}

	// graphiteClient.SendData(data []map[string]float64) error - this method receives a list of metrics as an argument
	if err := graphiteClient.SendData(metricsToSend); err != nil {
		log.Printf("Error sending metrics: %v", err)
	}
}

Documentation

Overview

Simple Graphite client

Example
package main

import (
	"log"

	"github.com/jtaczanowski/go-graphite-client"
)

func main() {
	graphiteClient := graphite.NewClient("localhost", 2003, "metrics.prefix", "tcp")

	// metrics
	exampleMetric1 := map[string]float64{"test_metric": 1234.1234}
	exampleMetric2 := map[string]float64{"test_metric2": 12345.12345}
	// list of the metrics
	metricsToSend := []map[string]float64{exampleMetric1, exampleMetric2}

	// graphiteClient.SendData(data []map[string]float64) error - this method receives a list of metrics as an argument
	if err := graphiteClient.SendData(metricsToSend); err != nil {
		log.Printf("Error sending metrics: %v", err)
	}
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client - struct with Graphite connection settings

func NewClient

func NewClient(Host string, Port int, Prefix string, Protocol string) *Client

NewClient - returns new Client

func (*Client) SendData

func (g *Client) SendData(data []map[string]float64) error

SentData - pushes data to Graphite server. Default connect timeout is set to 3s

SentData receives as argument []map[string]int64 where string is metric name, float64 is metric value, example:

map[string]float64{"test": 1234.1234}

Jump to

Keyboard shortcuts

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