繁体   English   中英

用于列出不适用于过滤器的通知通道的 Gcloud 命令

[英]Gcloud command for listing notification channels not working with filter

我正在尝试使用基于displayNamegcloud命令过滤为堆栈驱动程序警报通知创建的现有通道。 这些通道是电子邮件和网络挂钩类型,下面是电子邮件通知通道的结构:

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

我正在使用以下 Gcloud 命令列出此频道以查明它是否实际存在。

gcloud alpha monitoring channels list --filter='displayName="Test Notifications Channel"' --format='value(name)' --project=xxx

输出是:

警告:以下筛选键不存在于任何资源中:displayName

该命令的测试版也给出了相同的结果。 我需要通过displayName确定频道是否存在。

注意:在 --filter='type="email"' 中有效,但我不需要。

我可以使用哪个 gcloud 命令和过滤器来解决这个问题?

更新

感谢您在下面的回复,我发现过滤器确实适用于上述代码,正如正确指出的那样,有一些尾随空间。 我实际上一直在尝试的是displayNameTest Notifications Channel Default组成。

但在我只给出的过滤器中,省略了默认值:

gcloud alpha monitoring channels list --filter='displayName="Test Notifications Channel"' --format='value(name)' --project=xxx

但我的要求是打印所有以displayName Test Notifications Channel 开头的频道,所以我想要这样的东西:

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

此命令提供所有测试通知,例如

测试通知通道默认

测试通知渠道非默认

@JohnHanley 感谢您的提示。

我可以使用以下命令获取频道详细信息

gcloud beta monitoring channels list

对于您的特定用例

gcloud beta monitoring channels list --filter='displayName:"Test Notifications Channel"' --format='value(name)' --project=xxx

参考:

https://cloud.google.com/monitoring/alerts/using-channels-api#api-list-channels

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM