Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/seatgeek/telemetria
A golang wrapper around the influxdb client for easier app instrumentation
https://github.com/seatgeek/telemetria
golang influxdb instrumentation
Last synced: 1 day ago
JSON representation
A golang wrapper around the influxdb client for easier app instrumentation
- Host: GitHub
- URL: https://github.com/seatgeek/telemetria
- Owner: seatgeek
- Created: 2017-03-02T10:29:07.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-03-25T19:51:03.000Z (almost 5 years ago)
- Last Synced: 2024-06-20T05:28:45.352Z (8 months ago)
- Topics: golang, influxdb, instrumentation
- Language: Go
- Size: 16.6 KB
- Stars: 0
- Watchers: 87
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# telemetria
This package aims to make is simple to connect and send metrics to influxdb, either by using the
http or udp protocol.The official influxdb client is good enough, yet a bit verbose when trying to quickly send stats
to the database. Telemetria offers a friendlier face for performing those operations, without exposing
the richer and more complex internal API from influxdb.## Installation
Install it using the `go get` command:
go get github.com/seatgeek/telemetria
## Usage
You first need to create a `Recorder` that can be used later on for sending metrics to the database.
Recorders support the http and udp protocol. In order to create a client to you need to pass a
URL string accordingly.### Creating a recorder using HTTP
```go
import (
"github/seatgeek/telemetria"
)recorder := telemetria.NewRecorder("http://user:pass@localhost:8086/my_database")
```### Creating a recorder using UDP
```go
import (
"github/seatgeek/telemetria"
)recorder := telemetria.NewRecorder("udp://localhost:8089")
```Note that there is no way to specify a database when using the UDP protocol. This needs to be handled
directly in the UDP configuration for influxdb or telegraf.### Sending metrics
Metrics are created using the `Metric` struct and passing them to `WriteOne` or `WriteMany`. Theses structs
have fields for specifying both the values and tags that should be stored in the series table.Here's an example showing all supported properties:
```go
recorder.WriteOne(Metric{
Name: "cpu_usage",
Fields: map[string]interface{}{
"idle": 10.1,
"system": 53.3,
"user": 46.6,
},
Tags: map[string]string{"cpu": "cpu-total"}
})
```You batch-send many metrics using the `WriteMany` method:
```go
metrics := []Metric{ metric1, metric2, metric3 }
recorder.WriteMany(metrics)
```