amazon-cloudwatch-agent icon indicating copy to clipboard operation
amazon-cloudwatch-agent copied to clipboard

Remove --sample-config flag from amazon-cloudwatch-agent executable

Open straussb opened this issue 2 years ago • 6 comments

The --sample-config flag is useless, it prints out a TOML config which is not relevant for a CWAgent customer. Not to mention it panics because it tries to print the config for one of the container processors, which expects /rootfs to exist - see below. The existence of this flag is confusing to customers because they might think it could show them a sample JSON config.

This flag should be removed, along with the --section-filter, --input-filter, --output-filter, --aggregator-filter, and --processor-filter flags which are only used in conjunction with --sample-config.

Panic output:

2022-10-19T13:56:51Z E! /rootfs/proc does not exist
panic: E! /rootfs/proc does not exist

goroutine 1 [running]:
log.Panic({0xc0009bf738?, 0xc00050f500?, 0x3ad4dc0?})
        /usr/lib/golang/src/log/log.go:385 +0x65
github.com/aws/amazon-cloudwatch-agent/internal/containerinsightscommon.NewNodeCapacity()
        /builddir/build/BUILD/amazon-cloudwatch-agent-1.247354.0b251981/amazon-cloudwatch-agent/internal/containerinsightscommon/nodeCapacity.go:21 +0x7c
github.com/aws/amazon-cloudwatch-agent/plugins/processors/ecsdecorator.init.0.func1()
        /builddir/build/BUILD/amazon-cloudwatch-agent-1.247354.0b251981/amazon-cloudwatch-agent/plugins/processors/ecsdecorator/ecsdecorator.go:166 +0x19
github.com/influxdata/telegraf/plugins/processors.upgradeToStreamingProcessor.func1()
        /builddir/build/BUILD/amazon-cloudwatch-agent-1.247354.0b251981/amazon-cloudwatch-agent/vendor/github.com/influxdata/telegraf/plugins/processors/registry.go:24 +0x1d
github.com/influxdata/telegraf/config.printFilteredProcessors({0xc0006da180, 0x5, 0x8?}, 0x1?)
        /builddir/build/BUILD/amazon-cloudwatch-agent-1.247354.0b251981/amazon-cloudwatch-agent/vendor/github.com/influxdata/telegraf/config/config.go:577 +0x266
github.com/influxdata/telegraf/config.PrintSampleConfig({0xc0009bfcf0, 0x0, 0x0}, {0x560d170?, 0x0, 0x0}, {0x560d170?, 0x0, 0x0}, {0xc0009bfcf0, ...}, ...)
        /builddir/build/BUILD/amazon-cloudwatch-agent-1.247354.0b251981/amazon-cloudwatch-agent/vendor/github.com/influxdata/telegraf/config/config.go:519 +0x6a5
main.main()
        /builddir/build/BUILD/amazon-cloudwatch-agent-1.247354.0b251981/amazon-cloudwatch-agent/cmd/amazon-cloudwatch-agent/amazon-cloudwatch-agent.go:473 +0xb9a

straussb avatar Oct 19 '22 14:10 straussb

Would it make sense to repurpose the sample config flag (maybe still remove those other additional flags), to spit out the default config JSON for the host OS? We have all of those hard coded in the agent code, I think we could print them out to stdout. Idk if that alone is more useful than just making it more obvious that customers can start the agent with -c default in the ctl script.

SaxyPandaBear avatar Oct 24 '22 14:10 SaxyPandaBear

We also have the wizard for generating configs... I wouldn't have a problem with what you're proposing, but would be easier to just remove :) and less duplication.

straussb avatar Oct 24 '22 16:10 straussb

I think where I'm coming from is that there is a gap in the initial setup/getting started part of using the agent. There is another gap in that amazon-cloudwatch-agent-ctl -a fetch-config -s -c default doesn't actually spit out the JSON config for that default. I'm not sure if that config overlaps with the configuration options that you can get through the wizard.

SaxyPandaBear avatar Oct 24 '22 16:10 SaxyPandaBear

This issue was marked stale due to lack of activity.

github-actions[bot] avatar Jan 23 '23 00:01 github-actions[bot]

Still an issue

straussb avatar Jan 24 '23 02:01 straussb

Hi @straussb , @SaxyPandaBear

I have completed some implementation for this fix. However, removing other flags like --section-filter, --input-filter, --output-filter, --aggregator-filter and --processor-filter will require a much deeper refactor according to my understanding, if this issue is a part of the release maybe?

The PR: https://github.com/aws/amazon-cloudwatch-agent/pull/745

Ahmadkashif avatar May 05 '23 21:05 Ahmadkashif