Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch the toToml unit test from using string to Toml struct comparison #357

Merged
merged 2 commits into from
Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ require (
github.com/go-kit/kit v0.10.0
github.com/gobwas/glob v0.2.3
github.com/google/cadvisor v0.36.0
github.com/google/go-cmp v0.4.0 // indirect
github.com/hashicorp/golang-lru v0.5.4
github.com/imdario/mergo v0.3.8 // indirect
github.com/influxdata/telegraf v0.0.0-00010101000000-000000000000
github.com/influxdata/toml v0.0.0-20190415235208-270119a8ce65
github.com/influxdata/wlog v0.0.0-20160411224016-7c63b0a71ef8
github.com/kardianos/service v1.0.0
github.com/kr/pretty v0.2.0 // indirect
github.com/oklog/run v1.1.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.5.1
Expand Down
2 changes: 1 addition & 1 deletion translator/toenvconfig/toEnvConfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func TestCsmOnlyConfig(t *testing.T) {
checkIfTranslateSucceed(t, ReadFromFile("../totomlconfig/sampleConfig/csm_only_config.json"), "linux", expectedEnvVars)
}

func TestCsmServiceAdressesConfig(t *testing.T) {
func TestCsmServiceAddressesConfig(t *testing.T) {
resetContext()
expectedEnvVars := map[string]string{
"AWS_CSM_ENABLED": "TRUE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@
role_arn = "metrics_role_arn_value_test"
rollup_dimensions = [["ImageId"], ["InstanceId", "InstanceType"], ["d1"], []]
tagexclude = ["host", "metricPath"]
[outputs.cloudwatch.drop_original_metrics]
cpu = ["cpu_usage_idle", "time_active"]

[[outputs.cloudwatch.metric_decoration]]
category = "cpu"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"resources": [
"*"
],
"drop_original_metrics": ["cpu_usage_idle", "time_active"],
"measurement": [
{
"name": "cpu_usage_idle",
Expand Down
150 changes: 92 additions & 58 deletions translator/totomlconfig/toTomlConfig_test.go

Large diffs are not rendered by default.

196 changes: 196 additions & 0 deletions translator/totomlconfig/tomlConfigTemplate/agentToml.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
[agent]
collection_jitter = "0s"
debug = true
flush_interval = "1s"
flush_jitter = "0s"
hostname = ""
interval = "10s"
logfile = "/opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log"
logtarget = "lumberjack"
metric_batch_size = 1000
metric_buffer_limit = 10000
omit_hostname = false
precision = ""
quiet = false
round_interval = false

[inputs]

[[inputs.cpu]]
collect_cpu_time = true
fieldpass = ["usage_idle", "usage_nice", "usage_guest", "time_active", "usage_active"]
interval = "10s"
percpu = true
report_active = true
totalcpu = false
[inputs.cpu.tags]
"aws:StorageResolution" = "true"
d1 = "foo"
d2 = "bar"
metricPath = "metrics"

[[inputs.disk]]
fieldpass = ["free", "total", "used"]
ignore_fs = ["sysfs", "devtmpfs"]
interval = "60s"
mount_points = ["/", "/dev", "/sys"]
tagexclude = ["mode"]
[inputs.disk.tags]
d3 = "foo3"
d4 = "bar4"
metricPath = "metrics"

[[inputs.diskio]]
fieldpass = ["reads", "writes", "read_time", "write_time", "io_time"]
interval = "60s"
[inputs.diskio.tags]
metricPath = "metrics"
report_deltas = "true"

[[inputs.logfile]]
destination = "cloudwatchlogs"
file_state_folder = "/opt/aws/amazon-cloudwatch-agent/logs/state"

[[inputs.logfile.file_config]]
file_path = "/opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log"
from_beginning = true
log_group_name = "amazon-cloudwatch-agent.log"
log_stream_name = "amazon-cloudwatch-agent.log"
pipe = false
retention_in_days = 5
timezone = "UTC"

[[inputs.logfile.file_config]]
auto_removal = true
file_path = "/opt/aws/amazon-cloudwatch-agent/logs/test.log"
from_beginning = true
log_group_name = "test.log"
log_stream_name = "test.log"
pipe = false
retention_in_days = -1
timezone = "UTC"
[inputs.logfile.tags]
metricPath = "logs"

[[inputs.mem]]
fieldpass = ["used", "cached", "total"]
interval = "1s"
[inputs.mem.tags]
"aws:StorageResolution" = "true"
metricPath = "metrics"

[[inputs.net]]
fieldpass = ["bytes_sent", "bytes_recv", "drop_in", "drop_out"]
interfaces = ["eth0"]
[inputs.net.tags]
"aws:StorageResolution" = "true"
metricPath = "metrics"
report_deltas = "true"

[[inputs.netstat]]
fieldpass = ["tcp_established", "tcp_syn_sent", "tcp_close"]
interval = "60s"
[inputs.netstat.tags]
metricPath = "metrics"

[[inputs.processes]]
fieldpass = ["running", "sleeping", "dead"]
[inputs.processes.tags]
"aws:StorageResolution" = "true"
metricPath = "metrics"

[[inputs.procstat]]
fieldpass = ["cpu_usage", "memory_rss"]
pid_file = "/var/run/example1.pid"
pid_finder = "native"
tagexclude = ["user", "result"]
[inputs.procstat.tags]
"aws:StorageResolution" = "true"
metricPath = "metrics"

[[inputs.socket_listener]]
data_format = "emf"
name_override = "emf"
service_address = "udp://127.0.0.1:25888"
[inputs.socket_listener.tags]
metricPath = "logs_socket_listener"

[[inputs.socket_listener]]
collectd_auth_file = "/etc/collectd/auth_file"
collectd_security_level = "encrypt"
collectd_typesdb = ["/usr/share/collectd/types.db"]
data_format = "collectd"
name_prefix = "collectd_"
service_address = "udp://127.0.0.1:25826"
[inputs.socket_listener.tags]
"aws:AggregationInterval" = "60s"
metricPath = "metrics"

[[inputs.statsd]]
interval = "10s"
metric_separator = "_"
parse_data_dog_tags = true
service_address = ":8125"
[inputs.statsd.tags]
"aws:AggregationInterval" = "60s"
metricPath = "metrics"

[[inputs.swap]]
fieldpass = ["used", "free", "used_percent"]
[inputs.swap.tags]
"aws:StorageResolution" = "true"
metricPath = "metrics"
[outputs]

[[outputs.cloudwatch]]
endpoint_override = "https://monitoring-fips.us-west-2.amazonaws.com"
force_flush_interval = "60s"
max_datums_per_call = 1000
max_values_per_datum = 5000
namespace = "CWAgent"
region = "us-west-2"
role_arn = "metrics_role_arn_value_test"
rollup_dimensions = [["ImageId"], ["InstanceId", "InstanceType"], ["d1"], []]
tagexclude = ["host", "metricPath"]
[outputs.cloudwatch.drop_original_metrics]
cpu = ["cpu_usage_idle", "time_active"]

[[outputs.cloudwatch.metric_decoration]]
category = "cpu"
name = "usage_idle"
rename = "CPU_USAGE_IDLE"
unit = "unit"

[[outputs.cloudwatch.metric_decoration]]
category = "cpu"
name = "usage_nice"
unit = "unit"

[[outputs.cloudwatch.metric_decoration]]
category = "disk"
name = "free"
rename = "DISK_FREE"
unit = "unit"
[outputs.cloudwatch.tagpass]
metricPath = ["metrics"]

[[outputs.cloudwatchlogs]]
endpoint_override = "https://logs-fips.us-west-2.amazonaws.com"
force_flush_interval = "60s"
log_stream_name = "LOG_STREAM_NAME"
region = "us-west-2"
role_arn = "log_role_arn_value_test"
tagexclude = ["metricPath"]
[outputs.cloudwatchlogs.tagpass]
metricPath = ["logs", "logs_socket_listener"]

[processors]

[[processors.delta]]

[[processors.ec2tagger]]
ec2_instance_tag_keys = ["aws:autoscaling:groupName"]
ec2_metadata_tags = ["ImageId", "InstanceId", "InstanceType"]
refresh_interval_seconds = "0s"
[processors.ec2tagger.tagpass]
metricPath = ["metrics"]
Loading