I'm trying to get logs from an application running in AWS, while excluding logs that contain a certain phrase:
aws logs filter-log-events --log-group-name $MY_LOG_GROUP --filter-pattern -"dont want"
The above works. However, if I instead try:
aws logs filter-log-events --log-group-name $MY_LOG_GROUP --filter-pattern -"dontwant"
I get:
aws: error: argument --filter-pattern: expected one argument
I assume my shell is parsing it as an additional flag, instead of an argument to --filter-pattern. So, first question: How do I force aws cli to treat it as an argument?
If I instead try:
aws logs filter-log-events --log-group-name "$MY_LOG_GROUP" --filter-pattern -"GET /healthcheck"
I get:
An error occurred (InvalidParameterException) when calling the FilterLogEvents operation: Invalid filter pattern
Second question(s): what's the issue here, and how do I fix it?
Try this instead:
aws logs filter-log-events --log-group-name $MY_LOG_GROUP --filter-pattern=-"dont want"
The aws cli supports the <option>=<value> syntax also. Looks like this has been an issue for awhile.
As for the second example, the slash causes issues but I think this works so it will not try to interpret the slash; also an issue for awhile:
aws logs filter-log-events --log-group-name "$MY_LOG_GROUP" --filter-pattern='-"GET /healthcheck"'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With