awslabs / collectd-cloudwatch

A collectd plugin for sending data to Amazon CloudWatch
MIT License
199 stars 131 forks source link

call V2 first, then fall back to V1 if V2 fails #98

Closed yimuniao closed 3 years ago

yimuniao commented 3 years ago

Issue #, if available: call IMDSV2 first, then fallback to V1 if there is anything wrong.

Description of changes: reorder the sequence of API calls.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Test:

[2021-03-11 21:59:18] [info] [AmazonCloudWatchPlugin][cloudwatch.modules.configuration.metadatareader] [debug] Try IMDSV2
[2021-03-11 21:59:18] [info] [AmazonCloudWatchPlugin][cloudwatch.modules.configuration.metadatareader] [debug] unauthorized token, try IMDSV2 again.
[2021-03-11 21:59:18] [info] [AmazonCloudWatchPlugin][cloudwatch.modules.configuration.metadatareader] [debug] Try IMDSV2
[2021-03-11 22:00:18] [info] [AmazonCloudWatchPlugin][cloudwatch.modules.flusher] [debug] flushing metrics cpu--percent-active[6] memory--percent-used[6] df-root-percent_bytes-used[6]
[2021-03-11 22:00:18] [info] [AmazonCloudWatchPlugin][cloudwatch.modules.configuration.metadatareader] [debug] Try IMDSV2