influxdb

package module
v0.0.0-...-4a83bc6 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2017 License: MIT Imports: 8 Imported by: 0

README

go-metrics-influxdb

This is a reporter for the go-metrics library which will post the metrics to InfluxDB. go-metrics-influxdb uses latest influxDB client via HTTP/UDP protocol.

Note

This is only compatible with InfluxDB 0.9+.

Usage

import "github.com/sevenNt/go-metrics-influxdb"

// send metrics via HTTP protocol
go influxdb.InfluxDB(
    metrics.DefaultRegistry, // metrics registry
    time.Second * 10,        // interval
    "http://localhost:8086", // the InfluxDB address
    "mydb",                  // your InfluxDB database
    "myuser",                // your InfluxDB user
    "mypassword",            // your InfluxDB password
)

// send metrics via UDP protocol
go influxdb.InfluxDB(
    metrics.DefaultRegistry, // metrics registry
    time.Second * 10,        // interval
    "udp://localhost:8089",  // the InfluxDB address
    "",                      // UDP database is setted in your configuration file
    "",                      // your InfluxDB user
    "",                      // your InfluxDB password
)

//send guage metries(field) in registry only one time not by time interval
go influxdb.InfluxDBWithTagsV2(
    metrics.DefaultRegistry, // metrics registry
    "http://localhost:8086", // the InfluxDB address
    "mydb",                  // your InfluxDB database
    "myuser",                // your InfluxDB user
    "mypassword",            // your InfluxDB password
    "tableName",// your new table name
    "tags", // tags info,  not field
)

License
-------

go-metrics-influxdb is licensed under the MIT license. See the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InfluxDB

func InfluxDB(r metrics.Registry, d time.Duration, addr, database, username, password string)

InfluxDB starts a InfluxDB reporter which will post the metrics from the given registry at each d interval.

func WithTags

func WithTags(r metrics.Registry, d time.Duration, addr, database, username, password string, tags map[string]string)

WithTags starts a InfluxDB reporter which will post the metrics from the given registry at each d interval with the specified tags

Types

type Reporter

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

Reporter 发送给数据库的client对象

func NewReporter

func NewReporter(address, database, username, password string) *Reporter

NewReporter 发送批量的metrics数据(当前为gauge)到influxDB, 非定时发送

func (*Reporter) Send

func (r *Reporter) Send(item *ReporterItem, measureName string) error

Send 发送一条logItem类型的数据(一个registry, 多个tag)

type ReporterItem

type ReporterItem struct {
	Reg  metrics.Registry
	Tags map[string]string
}

ReporterItem 发送一条数据的内容

Jump to

Keyboard shortcuts

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