根本问题是我的项目有数万个操作,因此很难跟踪与正在创建或删除的特定实例相关的操作。所以,我正在寻找一种按目标列出操作的方法。
已弃用的gcutil
文档讨论了将过滤器表达式设置为可能的filter operations by target实例名称或实例selfLink,但似乎没有提到{{1中的类似过滤器表达式}} described here:
gcloud compute operations list
其中列出的唯一非全局标志如下:
gcloud compute operations list [NAME …] [--format FORMAT] [--help] [--limit LIMIT] [--log-http] [--project PROJECT_ID] [--quiet, -q] [--regexp REGEXP, -r REGEXP] [--sort-by SORT_BY] [--trace-token TRACE_TOKEN] [--uri] [--global | --regions [REGION,…] | --zones [ZONE,…]] [-h]
此外,--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
尽管原始API文档描述了' target'作为example here:
$ 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.
我做错了什么,是否有可能根据我尝试插入的实例的名称过滤区域操作?
答案 0 :(得分:1)
我不确定如何使用gcloud,但你仍然可以使用gcutil:
gcutil listoperations --zone us-east1-a --filter="targetLink eq '.*dhuo.*'"
所以它几乎与你的相同,但应该使用'targetLink'而不是'target'。
答案 1 :(得分:0)
如果你想使用gcloud
并专门搜索目标,你也可以这样做:
$ gcloud compute operations list | awk '$3 ~ /dhuo\./ {print $0}'