Skip to content

Go module groupcache_awsemf exports groupcache metrics to AWS CloudWatch Logs using Embedded Metric Format.

License

Notifications You must be signed in to change notification settings

udhos/groupcache_awsemf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

license Go Report Card Go Reference

groupcache_awsemf

groupcache_awsemf exports groupcache metrics to AWS CloudWatch Logs using Embedded Metric Format.

Synopsis

import (
	"github.com/aws/aws-sdk-go-v2/aws"
	"github.com/aws/aws-sdk-go-v2/config"
	"github.com/modernprogram/groupcache/v2"
	"github.com/udhos/groupcache_awsemf/exporter"
	"github.com/udhos/groupcache_exporter"
	"github.com/udhos/groupcache_exporter/groupcache/modernprogram"
)

workspace := groupcache.NewWorkspace()

caches := startGroupcache(workspace)

//
// metrics exporter
//

var awsConfig *aws.Config
if cloudwatchSend {
    cfg, err := config.LoadDefaultConfig(context.TODO())
    if err != nil {
        log.Fatalf("aws sdk config error: %v", err)
    }
    awsConfig = &cfg
}

exporter, errExport := exporter.New(exporter.Options{
    Application: "my-application-name",
    AwsConfig:   awsConfig, // if nil, metric is echoed to stdout
    ListGroups: func() []groupcache_exporter.GroupStatistics {
        return modernprogram.ListGroups(workspace)
    },
    ExportInterval: 20 * time.Second,
})
if errExport != nil {
    log.Fatal(errExport)
}
defer exporter.Close()

Examples

Findind EMF metrics sent to CloudWatch

By default:

1 - EMF logs are issued to log group /groupache/{Application}. See option LogGroup to change the log group.

2 - EMF metrics are issued to namespace groupcache. See option Namespace to change the namespace.

3 - EMF metrics have dimension application={Application}. See option Application to set the application name.

About

Go module groupcache_awsemf exports groupcache metrics to AWS CloudWatch Logs using Embedded Metric Format.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published