Google compute engine 一个人如何使用;gcloud计算操作列表“;是否按实例名称使用筛选器?

Google compute engine 一个人如何使用;gcloud计算操作列表“;是否按实例名称使用筛选器?,google-compute-engine,Google Compute Engine,根本问题是,我有一个项目,它有成千上万的操作,因此很难跟踪与正在创建或删除的特定实例相关的操作。所以,我正在寻找一种按目标列出操作的方法 不推荐使用的gcutil文档谈到将筛选器表达式设置为可能的实例名称或实例自链接,但在gcloud计算操作列表中似乎没有提到类似的筛选器表达式: 此处列出的唯一非全局标志如下: --global If provided, only global resources are shown. --limit LIMIT The maximum number of re

根本问题是,我有一个项目,它有成千上万的操作,因此很难跟踪与正在创建或删除的特定实例相关的操作。所以,我正在寻找一种按目标列出操作的方法

不推荐使用的
gcutil
文档谈到将筛选器表达式设置为可能的实例名称或实例自链接,但在
gcloud计算操作列表中似乎没有提到类似的筛选器表达式:

此处列出的唯一非全局标志如下:

--global
If provided, only global resources are shown.
--limit LIMIT
The maximum number of results.
--regexp REGEXP, -r REGEXP
A regular expression to filter the names of the results on. Any names that do not match the entire regular expression will be filtered out.
--regions [REGION,…]
If provided, only regional resources are shown. If arguments are provided, only resources from the given regions are shown.
--sort-by SORT_BY
A field to sort by. To perform a descending-order sort, prefix the value of this flag with a tilde (~).
--uri
If provided, the list command will only print URIs for the resources returned. If this flag is not provided, the list command will print a human-readable table of useful resource data.
--zones [ZONE,…]
If provided, only zonal resources are shown. If arguments are provided, only resources from the given zones are shown.
此外,
gcutil
文档给出的示例似乎不起作用:

$ gcutil listoperations --zone us-east1-a --filter="target eq '.*dhuo.*'"
WARNING: 'gcutil' has been deprecated and soon will be removed from Cloud SDK distribution.
WARNING: Please use 'gcloud compute' instead.
WARNING: For more information see https://cloud.google.com/compute/docs/gcutil
Error: Invalid value for field 'filter': 'target eq '.*dhuo.*''.  Unrecognized field name in list filter: target.
尽管原始API文档将“目标”描述为:


是否有我做错了什么,是否确实可以根据我尝试插入的实例的名称过滤区域操作?

我不知道如何使用gcloud,但您仍然可以使用gcutil:

gcutil listoperations --zone us-east1-a --filter="targetLink eq '.*dhuo.*'"

因此,它几乎与您的相同,但应该使用“targetLink”而不是“target”。

如果您想使用
gcloud
并专门搜索目标,也可以这样做:

$ gcloud compute operations list | awk '$3 ~ /dhuo\./ {print $0}'

只需将命令的输出通过管道传输并按如下方式进行过滤:$gcloud compute operations list--zones us-east1-a | grep dhuo。我打开了一个公共问题跟踪器来修复gcloud命令中的标志。启动并获取更新通知。
gcutil listoperations --zone us-east1-a --filter="targetLink eq '.*dhuo.*'"
$ gcloud compute operations list | awk '$3 ~ /dhuo\./ {print $0}'