Class EmfMetricLoggingPublisher

  • All Implemented Interfaces:
    AutoCloseable, MetricPublisher, SdkAutoCloseable

    @ThreadSafe
    @Immutable
    public final class EmfMetricLoggingPublisher
    extends Object
    implements MetricPublisher
    A metric publisher implementation that converts metrics into CloudWatch Embedded Metric Format (EMF). EMF allows metrics to be published through CloudWatch Logs using a structured JSON format, which CloudWatch automatically extracts and processes into metrics.

    This publisher is particularly well-suited for serverless environments like AWS Lambda and container environments like Amazon ECS that have built-in integration with CloudWatch Logs. Using EMF eliminates the need for separate metric publishing infrastructure as metrics are automatically extracted from log entries.

    The EMF publisher converts metric collections into JSON-formatted log entries that conform to the CloudWatch EMF specification. The logGroupName field is required for EMF to work. CloudWatch automatically processes these logs to generate corresponding metrics that can be used for monitoring and alerting.

    See Also:
    The base interface for metric publishers, For the collection of metrics to be published, For configuration options, For the conversion logic