Skip to content

udhos/aws-emf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

license Go Report Card Go Reference

aws-emf

This Go module https://github.com/udhos/aws-emf helps in utilizing the AWS CloudWatch Embedded Metric Format.

Synopsis

metric := emf.New(emf.Options{})

dim1 := map[string]string{"dimKey1": "dimVal1"}
dim2 := map[string]string{"dimKey1": "dimVal1", "dimKey2": "dimVal2"}

metric1 := emf.MetricDefinition{
    Name:              "metric1",
    Unit:              "Bytes/Second",
    StorageResolution: 1,
}

metric2 := emf.MetricDefinition{
    Name: "metric2",
}

// If you previously sent a metric that now is not being overwritten with
// Record(), call Reset() to drop all previous values. Otherwise any
// non-overwritten metric is going to get reissued with the old value.
metric.Reset()

metric.Record("emf-test-ns1", metric1, nil, 10)  // metric without dimension
metric.Record("emf-test-ns1", metric1, dim1, 20) // metric with 1 dimension
metric.Record("emf-test-ns1", metric1, dim2, 30) // metric with 2 dimensions
metric.Record("emf-test-ns1", metric2, nil, 40)  // another metric without dimension
metric.Record("emf-test-ns2", metric1, nil, 50)  // metric without dimension but at another namespace

metric.Println() // Send metrics to stdout

Examples

Example issuing logs to stdout

./examples/emf-example/main.go

Example issuing logs to stdout in the format required by CLI (aws logs put-log-events)

emf-example-cw-cli > events

aws logs put-log-events --log-group-name my-logs --log-stream-name 20150601 --log-events file://events

./examples/emf-example-cw-cli/main.go

Example issuing logs directly to CloudWatch Log Group

./examples/emf-example-cw-putlogevents/main.go

About

This Go module https://github.com/udhos/aws-emf helps in utilizing the AWS CloudWatch Embedded Metric Format.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published