use*_*505 3 google-cloud-platform gcloud google-cloud-monitoring google-cloud-stackdriver
我正在尝试使用gcloud基于displayName 的命令来过滤为堆栈驱动程序警报通知创建的现有通道。通道的类型为电子邮件和 webhook,以下是电子邮件通知通道的结构:
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
Run Code Online (Sandbox Code Playgroud)
我正在使用以下 Gcloud 命令列出该频道以查明它是否确实存在。
gcloud alpha monitoring channels list --filter='displayName="Test Notifications Channel"' --format='value(name)' --project=xxx
Run Code Online (Sandbox Code Playgroud)
输出是:
警告:任何资源中都不存在以下过滤器键:displayName
该命令的beta版本也给出了相同的结果。我需要通过displayName查明频道是否存在。
注意:在 --filter='type="email"' 中有效,但我不要求这样做。
我可以使用哪个 gcloud 命令和过滤器来解决此问题?
感谢您在下面的回复,我发现过滤器确实适用于上述代码,正如正确指出的那样,有一些尾随空格。我实际上一直在尝试的是 displayName由Test Notifications Channel Default组成。
但在我只给出的过滤器中,省略了默认值:
gcloud alpha monitoring channels list --filter='displayName="Test Notifications Channel"' --format='value(name)' --project=xxx
Run Code Online (Sandbox Code Playgroud)
但我的要求是打印以displayName测试通知通道开头的所有通道,所以我想要这样的东西:
gcloud alpha monitoring channels list --filter='displayName="Test Notifications Channel*"' --format='value(name)' --project=xxx
Run Code Online (Sandbox Code Playgroud)
gcloud alpha monitoring channels list --filter='displayName:"Test Notifications Channel"' --format='value(name)' --project=xxx
Run Code Online (Sandbox Code Playgroud)
此命令给出所有测试通知,例如:
测试通知通道默认值
测试通知通道非默认
| 归档时间: |
|
| 查看次数: |
3871 次 |
| 最近记录: |