cloudwatch

package
v1.3000030.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: MIT Imports: 37 Imported by: 0

README

Amazon CloudWatch Exporter for Open Telemetry

The AmazonCloudWatch Exporter will convert the OTEL metrics to MetricDatum and send them to Amazon CloudWatch

Status
Stability [stable]
Supported pipeline types metrics
Distributions [amazon-cloudwatch-agent]

Amazon Authentication

The AmazonCloudWatch Exporter uses a credential chain for Authentication with the EC2 API endpoint. In the following order the plugin will attempt to authenticate.

  1. STS Credentials if Role ARN is specified
  2. Explicit credentials from 'access_key' and 'secret_key'
  3. Shared profile from 'profile' (https://stackoverflow.com/a/66121705)

The next will be the default credential chain from AWS SDK Go

  1. Environment Variables
  2. Share Credentials Files with default profile
  3. ECS Task IAM Role
  4. EC2 Instance Profile

The IAM User or Role making the calls must have permissions to call the EC2 DescribeTags API.

Exporter Configuration:

The following receiver configuration parameters are supported.

Name Description Default
region is the Amazon region that you wish to connect to. (e.g us-west-2, us-west-2) ""
namespace is the namespace used for AWS CloudWatch metrics. "CWAgent
endpoint_override is the endpoint you want to use other than the default endpoint based on the region information. ""

Documentation

Overview

Package cloudwatch provides a metric exporter for the OpenTelemetry collector.

Index

Constants

View Source
const (
	MaxDimensions = 30
)
View Source
const (
	TypeStr component.Type = "awscloudwatch"
)

Variables

This section is empty.

Functions

func BuildDimensions

func BuildDimensions(tagMap map[string]string) []*cloudwatch.Dimension

BuildDimensions converts the given map of strings to a list of dimensions. CloudWatch supports up to 30 dimensions per metric. So keep up to the first 30 alphabetically. This always includes the "host" tag if it exists. See https://github.com/aws/amazon-cloudwatch-agent/issues/398

func ConvertOtelDimensions added in v1.300025.0

func ConvertOtelDimensions(attributes pcommon.Map) []*cloudwatch.Dimension

ConvertOtelDimensions will returns a sorted list of dimensions.

func ConvertOtelHistogramDataPoints added in v1.300025.0

func ConvertOtelHistogramDataPoints(
	dataPoints pmetric.HistogramDataPointSlice,
	name string,
	unit string,
	scale float64,
) []*aggregationDatum

ConvertOtelHistogramDataPoints converts each datapoint in the given slice to Distribution.

func ConvertOtelMetric added in v1.300025.0

func ConvertOtelMetric(m pmetric.Metric) []*aggregationDatum

ConvertOtelMetric creates a list of datums from the datapoints in the given metric and returns it. Only supports the metric DataTypes that we plan to use. Intentionally not caching previous values and converting cumulative to delta. Instead use cumulativetodeltaprocessor which supports monotonic cumulative sums.

func ConvertOtelMetrics added in v1.300025.0

func ConvertOtelMetrics(m pmetric.Metrics) []*aggregationDatum

ConvertOtelMetrics only uses dimensions/attributes on each "datapoint", not each "Resource". This is acceptable because ResourceToTelemetrySettings defaults to true.

func ConvertOtelNumberDataPoints added in v1.300025.0

func ConvertOtelNumberDataPoints(
	dataPoints pmetric.NumberDataPointSlice,
	name string,
	unit string,
	scale float64,
) []*aggregationDatum

ConvertOtelNumberDataPoints converts each datapoint in the given slice to 1 or more MetricDatums and returns them.

func GetUniqueRollupList

func GetUniqueRollupList(inputLists [][]string) [][]string

GetUniqueRollupList filters out duplicate dimensions within the sets and filters duplicate sets.

func NewFactory added in v1.300025.0

func NewFactory() exporter.Factory

func NumberDataPointValue added in v1.300025.0

func NumberDataPointValue(dp pmetric.NumberDataPoint) float64

NumberDataPointValue converts to float64 since that is what AWS SDK will use.

Types

type Aggregator

type Aggregator interface {
	AddMetric(m *aggregationDatum)
}

func NewAggregator

func NewAggregator(metricChan chan<- *aggregationDatum, shutdownChan <-chan struct{}, wg *sync.WaitGroup) Aggregator

type CloudWatch

type CloudWatch struct {
	// contains filtered or unexported fields
}

func (*CloudWatch) BuildMetricDatum

func (c *CloudWatch) BuildMetricDatum(metric *aggregationDatum) []*cloudwatch.MetricDatum

BuildMetricDatum may just return the datum as-is. Or it might expand it into many datums due to dimension aggregation. There may also be more datums due to resize() on a distribution.

func (*CloudWatch) Capabilities added in v1.300025.0

func (c *CloudWatch) Capabilities() consumer.Capabilities

func (*CloudWatch) Close

func (c *CloudWatch) Close() error

func (*CloudWatch) Connect

func (c *CloudWatch) Connect() error

func (*CloudWatch) ConsumeMetrics added in v1.300025.0

func (c *CloudWatch) ConsumeMetrics(ctx context.Context, metrics pmetric.Metrics) error

ConsumeMetrics queues metrics to be published to CW. The actual publishing will occur in a long running goroutine. This method can block when publishing is backed up.

func (*CloudWatch) Description

func (c *CloudWatch) Description() string

func (*CloudWatch) IsDropping added in v1.247350.0

func (c *CloudWatch) IsDropping(metricName string) bool

func (*CloudWatch) ProcessRollup

func (c *CloudWatch) ProcessRollup(rawDimensions []*cloudwatch.Dimension) [][]*cloudwatch.Dimension

ProcessRollup creates the dimension sets based on the dimensions available in the original metric.

func (*CloudWatch) SampleConfig

func (c *CloudWatch) SampleConfig() string

func (*CloudWatch) Shutdown added in v1.300025.0

func (c *CloudWatch) Shutdown(ctx context.Context) error

func (*CloudWatch) Start added in v1.300025.0

func (c *CloudWatch) Start(_ context.Context, host component.Host) error

func (*CloudWatch) Write

func (c *CloudWatch) Write(metrics []telegraf.Metric) error

func (*CloudWatch) WriteToCloudWatch

func (c *CloudWatch) WriteToCloudWatch(req interface{})

type Config added in v1.300025.0

type Config struct {
	Region                   string          `mapstructure:"region"`
	EndpointOverride         string          `mapstructure:"endpoint_override,omitempty"`
	AccessKey                string          `mapstructure:"access_key,omitempty"`
	SecretKey                string          `mapstructure:"secret_key,omitempty"`
	RoleARN                  string          `mapstructure:"role_arn,omitempty"`
	RegionType               string          `mapstructure:"region_type,omitempty"`
	Mode                     string          `mapstructure:"mode,omitempty"`
	Profile                  string          `mapstructure:"profile,omitempty"`
	SharedCredentialFilename string          `mapstructure:"shared_credential_file,omitempty"`
	Token                    string          `mapstructure:"token,omitempty"`
	ForceFlushInterval       time.Duration   `mapstructure:"force_flush_interval"`
	MaxDatumsPerCall         int             `mapstructure:"max_datums_per_call"`
	MaxValuesPerDatum        int             `mapstructure:"max_values_per_datum"`
	RollupDimensions         [][]string      `mapstructure:"rollup_dimensions,omitempty"`
	DropOriginalConfigs      map[string]bool `mapstructure:"drop_original_metrics,omitempty"`
	Namespace                string          `mapstructure:"namespace"`

	// ResourceToTelemetrySettings is the option for converting resource
	// attributes to telemetry attributes.
	// "Enabled" - A boolean field to enable/disable this option. Default is `false`.
	// If enabled, all the resource attributes will be converted to metric labels by default.
	ResourceToTelemetrySettings resourcetotelemetry.Settings `mapstructure:"resource_to_telemetry_conversion"`
	// MiddlewareID is an ID for an extension that can be used to configure the AWS client.
	MiddlewareID *component.ID `mapstructure:"middleware,omitempty"`
}

Config represent a configuration for the CloudWatch metrics exporter.

func (*Config) Validate added in v1.300025.0

func (c *Config) Validate() error

Validate checks if the exporter configuration is valid.

type MetricDatumBatch

type MetricDatumBatch struct {
	MaxDatumsPerCall int
	Partition        []*cloudwatch.MetricDatum
	BeginTime        time.Time
	Size             int
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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