aws-emf

module
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2025 License: MIT

README

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

Directories

Path Synopsis
Package emf helps with AWS Embedded Metric Format.
Package emf helps with AWS Embedded Metric Format.
examples
emf-example command
Package main implements the tool.
Package main implements the tool.
emf-example-cw-cli command
Package main implements the tool.
Package main implements the tool.
emf-example-cw-putlogevents command
Package main implements the tool.
Package main implements the tool.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL