-
Notifications
You must be signed in to change notification settings - Fork 189
/
config.go
52 lines (45 loc) · 2.25 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT
package cloudwatch
import (
"errors"
"time"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry"
"go.opentelemetry.io/collector/component"
)
// Config represent a configuration for the CloudWatch logs exporter.
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"`
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"`
}
var _ component.Config = (*Config)(nil)
// Validate checks if the exporter configuration is valid.
func (c *Config) Validate() error {
if c.Region == "" {
return errors.New("'region' must be set")
}
if c.Namespace == "" {
return errors.New("'namespace' must be set")
}
if c.ForceFlushInterval < time.Millisecond {
return errors.New("'force_flush_interval' must be at least 1 millisecond")
}
return nil
}