Skip to content

Commit

Permalink
correctly convert static YACE jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
berler committed Sep 14, 2023
1 parent d610871 commit 9a4cb4f
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ Main (unreleased)

- Fixed a bug where documented default settings in `otelcol.exporter.loadbalancing` were never set. (@rfratto)

- Fixed a bug where converting `YACE` cloudwatch config to river skipped converting static jobs. (@berler)

v0.36.1 (2023-09-06)
--------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func toCloudwatchExporter(config *cloudwatch_exporter.Config) *cloudwatch.Argume
Debug: config.Debug,
DiscoveryExportedTags: config.Discovery.ExportedTags,
Discovery: toDiscoveryJobs(config.Discovery.Jobs),
Static: []cloudwatch.StaticJob{},
Static: toStaticJobs(config.Static),
}
}

Expand All @@ -56,6 +56,29 @@ func toDiscoveryJob(job *cloudwatch_exporter.DiscoveryJob) cloudwatch.DiscoveryJ
}
}

func toStaticJobs(jobs []cloudwatch_exporter.StaticJob) []cloudwatch.StaticJob {
var out []cloudwatch.StaticJob
for _, job := range jobs {
out = append(out, toStaticJob(&job))
}
return out
}

func toStaticJob(job *cloudwatch_exporter.StaticJob) cloudwatch.StaticJob {
return cloudwatch.StaticJob{
Name: job.Name,
Auth: cloudwatch.RegionAndRoles{
Regions: job.Regions,
Roles: toRoles(job.Roles),
},
CustomTags: toTags(job.CustomTags),
Namespace: job.Namespace,
Dimensions: toDimensions(job.Dimensions),
Metrics: toMetrics(job.Metrics),
NilToZero: job.NilToZero,
}
}

func toRoles(roles []cloudwatch_exporter.Role) []cloudwatch.Role {
var out []cloudwatch.Role
for _, role := range roles {
Expand All @@ -79,6 +102,14 @@ func toTags(tags []cloudwatch_exporter.Tag) cloudwatch.Tags {
return out
}

func toDimensions(dimensions []cloudwatch_exporter.Dimension) cloudwatch.Dimensions {
out := make(cloudwatch.Dimensions)
for _, dimension := range dimensions {
out[dimension.Name] = dimension.Value
}
return out
}

func toMetrics(metrics []cloudwatch_exporter.Metric) []cloudwatch.Metric {
var out []cloudwatch.Metric
for _, metric := range metrics {
Expand Down
23 changes: 23 additions & 0 deletions converter/internal/staticconvert/testdata/integrations.river
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,29 @@ prometheus.exporter.cloudwatch "integrations_cloudwatch_exporter" {
nil_to_zero = true
}

static "single_ec2_instance" {
regions = ["us-east-2"]
custom_tags = {}
namespace = "AWS/EC2"
dimensions = {
InstanceId = "i-0e43cee369aa44b52",
}

metric {
name = "CPUUtilization"
statistics = ["Average"]
period = "5m0s"
nil_to_zero = false
}

metric {
name = "NetworkPacketsIn"
statistics = ["Average"]
period = "5m0s"
}
nil_to_zero = true
}

decoupled_scraping { }
}

Expand Down
19 changes: 19 additions & 0 deletions converter/internal/staticconvert/testdata/integrations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,25 @@ integrations:
period: 5m
statistics:
- Average
static:
- name: single_ec2_instance
regions:
- us-east-2
namespace: AWS/EC2
dimensions:
- name: InstanceId
value: i-0e43cee369aa44b52
nil_to_zero: true
metrics:
- name: CPUUtilization
period: 5m
statistics:
- Average
nil_to_zero: false
- name: NetworkPacketsIn
period: 5m
statistics:
- Average
consul_exporter:
enabled: true
dnsmasq_exporter:
Expand Down

0 comments on commit 9a4cb4f

Please sign in to comment.