You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
I wish fetch-config would not delete the .json config file #1218
It's counterproductive that running fetch-config deletes the input .json config file.
When I'm debugging issues I want to just edit the file and rerun the fetch-config command. The fact that fetch-config deletes the file makes this more of a hassle.
And to me it seems like the configuration is overcomplicated (converting to a different .toml format, there's also a .yaml file there for some reason). It would be way more straightforward if we just specify .json file or SSM parameter or whatever as the configuration source, and the CloudWatch agent just leaves that as the source of truth, i.e. always reads from that file or SSM parameter on startup instead of fetching it and storing it in some other format.
Hi! Thank you for providing the logs. The fetch-config shouldn't delete the json file by design. I will try to re-create this issue and get back to you as soon as possible.
Any updates to this issue? We are experiencing the same thing. Is it expected instead that the config.json file gets transposed into the .toml file and the .json file is removed as it is no longer needed?
@okankoAMZ I just noticed this in the journal after re-fetching the config... the main PID is logging:
/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json does not exist or cannot read. Skipping it.
I want to emphasize again, the number of different files and formats CWAgent seems to shuffle the config through doesn't inspire confidence. It seems like asking for bugs.
● amazon-cloudwatch-agent.service - Amazon CloudWatch Agent
Loaded: loaded (/etc/systemd/system/amazon-cloudwatch-agent.service; enabled; preset: disabled)
Active: active (running) since Tue 2024-09-17 00:48:53 UTC; 5s ago
Main PID: 435744 (amazon-cloudwat)
Tasks: 8 (limit: 2257)
Memory: 105.1M
CPU: 888ms
CGroup: /system.slice/amazon-cloudwatch-agent.service
└─435744 /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent -config /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.toml -envconfig /opt/aws/amazon-cloudwatch-agent/etc/env-config.json -otelconfig /opt/aws/amazon-cloud>
Sep 17 00:48:54 ip-172-31-32-255.us-west-2.compute.internal start-amazon-cloudwatch-agent[435749]: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json does not exist or cannot read. Skipping it.
Sep 17 00:48:54 ip-172-31-32-255.us-west-2.compute.internal start-amazon-cloudwatch-agent[435749]: 2024/09/17 00:48:54 Reading json config file path: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/file_amazon-cloudwatch-agent.json ...
Sep 17 00:48:54 ip-172-31-32-255.us-west-2.compute.internal start-amazon-cloudwatch-agent[435749]: 2024/09/17 00:48:54 I! Valid Json input schema.
Sep 17 00:48:54 ip-172-31-32-255.us-west-2.compute.internal start-amazon-cloudwatch-agent[435749]: I! Detecting run_as_user...
Sep 17 00:48:54 ip-172-31-32-255.us-west-2.compute.internal start-amazon-cloudwatch-agent[435749]: I! Trying to detect region from ec2
Sep 17 00:48:54 ip-172-31-32-255.us-west-2.compute.internal start-amazon-cloudwatch-agent[435749]: 2024/09/17 00:48:54 D! ec2tagger processor required because append_dimensions is set
Sep 17 00:48:54 ip-172-31-32-255.us-west-2.compute.internal start-amazon-cloudwatch-agent[435749]: 2024/09/17 00:48:54 D! pipeline hostDeltaMetrics has no receivers
Sep 17 00:48:54 ip-172-31-32-255.us-west-2.compute.internal start-amazon-cloudwatch-agent[435749]: 2024/09/17 00:48:54 Configuration validation first phase succeeded
Sep 17 00:48:54 ip-172-31-32-255.us-west-2.compute.internal start-amazon-cloudwatch-agent[435744]: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json does not exist or cannot read. Skipping it.
Sep 17 00:48:54 ip-172-31-32-255.us-west-2.compute.internal start-amazon-cloudwatch-agent[435744]: I! Detecting run_as_user...
amazon-cloudwatch-agent-ctl deletes this file, so maybe it uses it for some other purpose in some cases?
In any case, using some other file path should work around this.
Once again, this process of importing the config in one file format and outputting in another file format seems like a mess. Would be much cleaner if instead, the main cloudwatch agent process just supported loading its config on startup directly from either a toml, yaml, or json file and we didn't need to run this import step at all.
Reacted by Greg Warner, DaveQB, Danny Butroyd, Oleksandr Kuzminskyi and taz_atwell
Activity
okankoAMZ commentedon Jul 18, 2024
Hi
Using the
fetch-configcommand should not deleting the config file. Could you provide some logs and outputs demonstrating this issue?Thank you!
jedwards1211 commentedon Jul 18, 2024
In the
/opt/aws/amazon-cloudwatch-agent/etcdirectory:You can see that
amazon-cloudwatch-agent.jsonis gone in output of the finalls.amazon-cloudwatch-agent.log:okankoAMZ commentedon Jul 19, 2024
Hi! Thank you for providing the logs. The
fetch-configshouldn't delete the json file by design. I will try to re-create this issue and get back to you as soon as possible.platymatt commentedon Aug 23, 2024
Any updates to this issue? We are experiencing the same thing. Is it expected instead that the config.json file gets transposed into the .toml file and the .json file is removed as it is no longer needed?
jedwards1211 commentedon Sep 17, 2024
@okankoAMZ I just noticed this in the journal after re-fetching the config... the main PID is logging:
I want to emphasize again, the number of different files and formats CWAgent seems to shuffle the config through doesn't inspire confidence. It seems like asking for bugs.
solomongit3 commentedon Sep 27, 2024
Hi any update on the file getting deleted
bkolendowski commentedon Oct 12, 2024
This occurs on EC2 (Linux 2023) as well by default.
umutsesen commentedon Dec 16, 2024
still happens on 24.04 build, wasted 1 hour
massimocode commentedon Dec 19, 2024
This is happening to us too, as a first time user of cloudwatch agent, this was incredibly confusing
Here's our status so you can see the version number. Running on Ubuntu v22 LTS on EC2.
massimocode commentedon Dec 19, 2024
I ran the following:
** Check out the last line, that fetch-config command is definitely trying to delete the config!**
jedwards1211 commentedon Dec 20, 2024
Aha:
amazon-cloudwatch-agent/packaging/dependencies/amazon-cloudwatch-agent-ctl
Line 306 in 43d475d
jedwards1211 commentedon Dec 20, 2024
The problem seems to be putting my config in exactly this file before running the import command:
amazon-cloudwatch-agent-ctldeletes this file, so maybe it uses it for some other purpose in some cases?In any case, using some other file path should work around this.
Once again, this process of importing the config in one file format and outputting in another file format seems like a mess. Would be much cleaner if instead, the main cloudwatch agent process just supported loading its config on startup directly from either a toml, yaml, or json file and we didn't need to run this import step at all.
DaveQB commentedon May 14, 2025
I can confirm this happens in ver1.300053.0b1046
adile-cyclope commentedon May 14, 2025
same issue with version 1.300055.0b1095
Fix CloudWatch agent config file deletion loop
Fix CloudWatch agent config file deletion loop (#205)