Skip to content

cloudmetrics is a go-metrics reporter that publishes data to Amazon CloudWatch

License

Notifications You must be signed in to change notification settings

weareyolo/cloudmetrics

 
 

Repository files navigation

cloudmetrics

GoDoc

This is a reporter for the go-metrics that will posts metrics to CloudWatch.

Usage

import "github.com/weareyolo/cloudmetrics"

go cloudmetrics.Publish(metrics.DefaultRegistry,
    "/sample/", // namespace
)

Configuration

cloudmetrics supports a number of configuration options:

package main

import (
    "context"
    "time"

    "github.com/aws/aws-sdk-go/service/cloudwatch"
    "github.com/weareyolo/go-metrics"
    "github.com/weareyolo/cloudmetrics"
)

func main() {
    p := cloudmetrics.NewPublisher(
        metrics.DefaultRegistry,                            // metrics registry
        "/sample/",                                         // namespace
        cloudmetrics.WithDimensions(map[string]string{
            "k1": "v1",
            "k2": "v2",
        }),                                                 // allows for custom dimensions
        cloudmetrics.WithInterval(5*time.Minute),           // custom interval
        cloudmetrics.WithContext(context.Background()),     // enables graceful shutdown via contexts
        cloudmetrics.WithPercentiles([]float64{.5, .99}),   // customize percentiles for histograms and timers
        cloudmetrics.WithUnits(map[string]string{
            "size": cloudwatch.StandardUnitGigabytes,
        }),                                                 // customize units based on metric names
    )
    go p.Publish()
    for {
        time.Sleep(5 * time.Minute)
    }
}

About

cloudmetrics is a go-metrics reporter that publishes data to Amazon CloudWatch

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%