I am trying to filter the existing channels created for stack-driver alert notifications using gcloud
command based on the displayName. The channels are of type emails and webhook and below is structure of email notification channel:
creationRecord:
mutateTime: '2021-03-16T14:28:59.926805618Z'
displayName: 'Test Notifications Channel'
enabled: true
labels:
email_address: 1234fcb0.XXXPortal.onmicrosoft.com@ayd.teams.ms
mutationRecords:
- mutateTime: '2021-03-16T14:28:59.926805618Z'
name: projects/xxx/notificationChannels/13657854696054677020
type: email
I am using the following Gcloud command to list this channel to find out whether it actually exists.
gcloud alpha monitoring channels list --filter='displayName="Test Notifications Channel"' --format='value(name)' --project=xxx
The output is:
WARNING: The following filter keys were not present in any resource : displayName
Also the beta version of the command gives the same result. I need to find out if the channel exists and by the displayName.
Note: in the --filter='type="email"' is working, but I don't require that.
Which gcloud command and filter can I use to solve this issue?
Thanks for your responses below, i find that the filter is indeed working for the above code, as rightly pointed out there is some trailing space. What I have been actually trying is the the displayName is consisting of Test Notifications Channel Default.
But in the filter I have given only, omitting the Default:
gcloud alpha monitoring channels list --filter='displayName="Test Notifications Channel"' --format='value(name)' --project=xxx
but my requirement is to print all the channels starting with the displayName Test Notifications Channel so I want something like this:
gcloud alpha monitoring channels list --filter='displayName="Test Notifications Channel*"' --format='value(name)' --project=xxx
gcloud alpha monitoring channels list --filter='displayName:"Test Notifications Channel"' --format='value(name)' --project=xxx
This command gives all the Test Notifications like:
Test Notifications Channel Default
Test Notifications Channel Non-Default