All Projects → wavefrontHQ → go-metrics-wavefront

wavefrontHQ / go-metrics-wavefront

Licence: Apache-2.0 license
Wavefront plugin for go-metrics

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to go-metrics-wavefront

wavefront-proxy
Wavefront Proxy Project
Stars: ✭ 45 (+275%)
Mutual labels:  time-series, wavefront
microprediction
If you can measure it, consider it predicted
Stars: ✭ 158 (+1216.67%)
Mutual labels:  time-series
ticktock
An OpenTSDB-like time series database, with much better performance.
Stars: ✭ 34 (+183.33%)
Mutual labels:  time-series
orderbook modeling
Example of order book modeling.
Stars: ✭ 38 (+216.67%)
Mutual labels:  time-series
Deep XF
Package towards building Explainable Forecasting and Nowcasting Models with State-of-the-art Deep Neural Networks and Dynamic Factor Model on Time Series data sets with single line of code. Also, provides utilify facility for time-series signal similarities matching, and removing noise from timeseries signals.
Stars: ✭ 83 (+591.67%)
Mutual labels:  time-series
ewstools
Python package for early warning signals (EWS) of bifurcations in time series data.
Stars: ✭ 29 (+141.67%)
Mutual labels:  time-series
msda
Library for multi-dimensional, multi-sensor, uni/multivariate time series data analysis, unsupervised feature selection, unsupervised deep anomaly detection, and prototype of explainable AI for anomaly detector
Stars: ✭ 80 (+566.67%)
Mutual labels:  time-series
DTW
Dynamic Time Warping in Python / C (using ctypes)
Stars: ✭ 26 (+116.67%)
Mutual labels:  time-series
walker
Bayesian Generalized Linear Models with Time-Varying Coefficients
Stars: ✭ 38 (+216.67%)
Mutual labels:  time-series
PlotTwist
PlotTwist - a web app for plotting and annotating time-series data
Stars: ✭ 21 (+75%)
Mutual labels:  time-series
Matrix-Profile
A Java library for Matrix Profile
Stars: ✭ 14 (+16.67%)
Mutual labels:  time-series
Time-Series-Forecasting
Rainfall analysis of Maharashtra - Season/Month wise forecasting. Different methods have been used. The main goal of this project is to increase the performance of forecasted results during rainy seasons.
Stars: ✭ 27 (+125%)
Mutual labels:  time-series
mf-nav-data
Historical NAV/price/time-series data of mutual funds and popular benchmark indices in India
Stars: ✭ 29 (+141.67%)
Mutual labels:  time-series
sknifedatar
sknifedatar is a package that serves primarily as an extension to the modeltime 📦 ecosystem. In addition to some functionalities of spatial data and visualization.
Stars: ✭ 30 (+150%)
Mutual labels:  time-series
modeltime.ensemble
Time Series Ensemble Forecasting
Stars: ✭ 65 (+441.67%)
Mutual labels:  time-series
LSTM-Mobility-Model
LSTM Mobility Model implementation using Tensorflow
Stars: ✭ 19 (+58.33%)
Mutual labels:  time-series
notebooks
Code examples for pyFTS
Stars: ✭ 40 (+233.33%)
Mutual labels:  time-series
SCINet
Forecast time series and stock prices with SCINet
Stars: ✭ 28 (+133.33%)
Mutual labels:  time-series
mlforecast
Scalable machine 🤖 learning for time series forecasting.
Stars: ✭ 96 (+700%)
Mutual labels:  time-series
cnn-rnn-bitcoin
Reusable CNN and RNN model doing time series binary classification
Stars: ✭ 28 (+133.33%)
Mutual labels:  time-series

go-metrics-wavefront build status Go Report Card GoDoc

This is a plugin for go-metrics which adds a Wavefront reporter and a simple abstraction that supports tagging at the host and metric level.

Imports

import (
	metrics "github.com/rcrowley/go-metrics"
	"github.com/wavefronthq/go-metrics-wavefront/reporting"
	"github.com/wavefronthq/wavefront-sdk-go/application"
	"github.com/wavefronthq/wavefront-sdk-go/senders"
)

Set Up a Wavefront Reporter

This SDK provides a WavefrontMetricsReporter that allows you to:

  • Report metrics to Wavefront at regular intervals or
  • Manually report metrics to Wavefront

The steps for creating a WavefrontMetricsReporter are:

  1. Create a Wavefront Sender for managing communication with Wavefront.
  2. Create a WavefrontMetricsReporter

1. Set Up a Wavefront Sender

A "Wavefront sender" is an object that implements the low-level interface for sending data to Wavefront. You can choose to send data using either the Wavefront proxy or direct ingestion.

  • If you have already set up a Wavefront sender for another SDK that will run in the same process, use that one. (For details, see Share a Wavefront Sender.)
  • Otherwise, follow the steps in Set Up a Wavefront Sender to configure a proxy Sender or a direct Sender.

The following example configures a direct Sender with default direct ingestion properties:

directCfg := &senders.DirectConfiguration{
  Server:               "https://INSTANCE.wavefront.com",
  Token:                "YOUR_API_TOKEN",
}

sender, err := senders.NewDirectSender(directCfg)
if err != nil {
  panic(err)
}

2. Create the WavefrontMetricsReporter

The WavefrontMetricsReporter supports tagging at the host level. Any tags passed to the reporter here will be applied to every metric before being sent to Wavefront.

To create the WavefrontMetricsReporter you initialize it with the sender instance you created in the previous step along with a few other properties:

reporter := reporting.NewMetricsReporter(
  sender,
  reporting.ApplicationTag(application.New("app", "srv")),
  reporting.Source("go-metrics-test"),
  reporting.Prefix("some.prefix"),
  reporting.LogErrors(true),
)

Tagging Metrics

In addition to tagging at the reporter level, you can add tags to individual metrics:

tags := map[string]string{
  "key1": "val1",
  "key2": "val2",
}
counter := metrics.NewCounter() // Create a counter
reporter.RegisterMetric("foo", counter, tags) // will create a 'some.prefix.foo.count' metric with tags
counter.Inc(47)

Extended Code Example

package main

import (
	"fmt"
	"math/rand"
	"os"
	"time"

	metrics "github.com/rcrowley/go-metrics"
	"github.com/wavefronthq/go-metrics-wavefront/reporting"
	"github.com/wavefronthq/wavefront-sdk-go/application"
	"github.com/wavefronthq/wavefront-sdk-go/senders"
)

func main() {

	//Tags we'll add to the metric
	tags := map[string]string{
		"key2": "val2",
		"key1": "val1",
		"key0": "val0",
		"key4": "val4",
		"key3": "val3",
	}

  // Create a direct sender
	directCfg := &senders.DirectConfiguration{
		Server:               "https://" + os.Getenv("WF_INSTANCE") + ".reporting.com",
		Token:                os.Getenv("WF_TOKEN"),
		BatchSize:            10000,
		MaxBufferSize:        50000,
		FlushIntervalSeconds: 1,
	}

	sender, err := senders.NewDirectSender(directCfg)
	if err != nil {
		panic(err)
	}

	reporter := reporting.NewMetricsReporter(
		sender,
		reporting.ApplicationTag(application.New("app", "srv")),
		reporting.Source("go-metrics-test"),
		reporting.Prefix("some.prefix"),
		reporting.LogErrors(true),
	)

	counter := metrics.NewCounter()                //Create a counter
	reporter.RegisterMetric("foo", counter, tags)  // will create a 'some.prefix.foo.count' metric with tags
	counter.Inc(47)

	histogram := reporting.NewHistogram()
	reporter.RegisterMetric("duration", histogram, tags) // will create a 'some.prefix.duration' histogram metric with tags

	histogram2 := reporting.NewHistogram()
	reporter.Register("duration2", histogram2) // will create a 'some.prefix.duration2' histogram metric with no tags

	deltaCounter := metrics.NewCounter()
	reporter.RegisterMetric(reporting.DeltaCounterName("delta.metric"), deltaCounter, tags)
	deltaCounter.Inc(10)

	fmt.Println("Search wavefront: ts(\"some.prefix.foo.count\")")
	fmt.Println("Entering loop to simulate metrics flushing. Hit ctrl+c to cancel")

	for {
		counter.Inc(rand.Int63())
		histogram.Update(rand.Int63())
		histogram2.Update(rand.Int63())
		deltaCounter.Inc(10)
		time.Sleep(time.Second * 10)
	}
}

Golang Runtime Metrics

To enable golang runtime metrics reporting, set the RuntimeMetric flag in reporter to true:

	reporting.NewMetricsReporter(
		sender,
		reporting.ApplicationTag(application.New("app", "srv")),
		reporting.Source("go-metrics-test"),
		reporting.Prefix("some.prefix"),
		reporting.RuntimeMetric(true),
	)
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].