Skip to content

Commit

Permalink
Configuration updates
Browse files Browse the repository at this point in the history
Timeout is now optional

Adding examples and defaults to the README.md
  • Loading branch information
janboll committed Sep 8, 2022
1 parent 2220421 commit 2f4b682
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 13 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ vpc:
- "us-east-1"
- "eu-central-1"
timeout: 30s
interval: 300s
cache_ttl: 500s
ec2:
enabled: true
regions:
Expand All @@ -84,6 +86,7 @@ route53:
enabled: true
region: "us-east-1"
timeout: 60s
interval: 90s
```
Some exporters might expose different configuration values, see the example files for possible keys.
Expand All @@ -96,6 +99,13 @@ tweak this behavior.
- `LOGS_METRICS_WORKERS`: Number of workers to request log metrics in parallel (default=10)
- `LOGS_METRICS_TTL`: Cache TTL for rds logs related metrics (default=300)


Defaults:
- interval: 15 seconds
- cache_ttl: 35 seconds
- timeout: 10 seconds


To view all available command-line flags, run `./aws-resource-exporter -h`.

## License
Expand Down
5 changes: 1 addition & 4 deletions aws-resource-exporter-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ vpc:
- "us-east-1"
- "eu-central-1"
- "eu-west-1"
timeout: 30s
route53:
enabled: true
region: "us-east-1"
timeout: 300s
ec2:
enabled: true
regions:
- "us-east-1"
- "eu-central-1"
- "us-west-1"
timeout: 30s
- "us-west-1"
2 changes: 1 addition & 1 deletion ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewEC2Exporter(sessions []*session.Session, logger log.Logger, config EC2Co
cache: *pkg.NewMetricsCache(*config.CacheTTL),

logger: logger,
timeout: config.Timeout,
timeout: *config.Timeout,
interval: *config.Interval,
}
}
Expand Down
21 changes: 15 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,20 @@ type RDSConfig struct {

type VPCConfig struct {
BaseConfig `yaml:"base,inline"`
Timeout time.Duration `yaml:"timeout"`
Regions []string `yaml:"regions"`
Timeout *time.Duration `yaml:"timeout"`
Regions []string `yaml:"regions"`
}

type Route53Config struct {
BaseConfig `yaml:"base,inline"`
Timeout time.Duration `yaml:"timeout"`
Region string `yaml:"region"` // Use only a single Region for now, as the current metric is global
Timeout *time.Duration `yaml:"timeout"`
Region string `yaml:"region"` // Use only a single Region for now, as the current metric is global
}

type EC2Config struct {
BaseConfig `yaml:"base,inline"`
Timeout time.Duration `yaml:"timeout"`
Regions []string `yaml:"regions"`
Timeout *time.Duration `yaml:"timeout"`
Regions []string `yaml:"regions"`
}

type Config struct {
Expand Down Expand Up @@ -117,6 +117,15 @@ func loadExporterConfiguration(logger log.Logger, configFile string) (*Config, e
config.EC2Config.Interval = durationPtr(15 * time.Second)
}

if config.VpcConfig.Timeout == nil {
config.VpcConfig.Timeout = durationPtr(10 * time.Second)
}
if config.Route53Config.Timeout == nil {
config.Route53Config.Timeout = durationPtr(10 * time.Second)
}
if config.EC2Config.Timeout == nil {
config.EC2Config.Timeout = durationPtr(10 * time.Second)
}
return &config, nil
}

Expand Down
2 changes: 1 addition & 1 deletion route53.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func NewRoute53Exporter(sess *session.Session, logger log.Logger, config Route53
cache: *pkg.NewMetricsCache(*config.CacheTTL),
logger: logger,
interval: *config.Interval,
timeout: config.Timeout,
timeout: *config.Timeout,
}
return exporter
}
Expand Down
2 changes: 1 addition & 1 deletion vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func NewVPCExporter(sess []*session.Session, logger log.Logger, config VPCConfig
IPv4BlocksPerVpcQuota: prometheus.NewDesc(prometheus.BuildFQName(namespace, "", "vpc_ipv4blockspervpc_quota"), "The quota of ipv4 blocks per vpc", []string{"aws_region"}, nil),
IPv4BlocksPerVpcUsage: prometheus.NewDesc(prometheus.BuildFQName(namespace, "", "vpc_ipv4blockspervpc_usage"), "The usage of ipv4 blocks per vpc", []string{"aws_region", "vpcid"}, nil),
logger: logger,
timeout: config.Timeout,
timeout: *config.Timeout,
cache: *pkg.NewMetricsCache(*config.CacheTTL),
interval: *config.Interval,
}
Expand Down

0 comments on commit 2f4b682

Please sign in to comment.