Google Cloud Logging:没有使用项目作为资源名称的 LogEntry
Google Cloud Logging: No LogEntry using project as resource name
使用了 REST 方法[1]。
要求:
{
"resourceNames": [
"projects/[PROJECT_ID]"
]
}
回复:
{
"nextPageToken": "..."
}
但是当替代资源以格式指定时
projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
返回日志条目。
有什么方法可以使用短资源格式获取日志?
一个技巧(!?)是添加一个过滤器来捕获日志条目,也许:
{
"resourceNames": [
"projects/[[PROJECT_ID]]"
],
"filter": "timestamp>=\"2021-09-02T15:00:00.000000Z\""
}
并使用 pageSize
验证这一点的一种方法是让 gcloud
显示底层 --log-http
调用:
gcloud logging read \
--project=${PROJECT} \
--log-http
=======================
==== request start ====
uri: https://logging.googleapis.com/v2/entries:list?alt=json
method: POST
== headers start ==
[[REDACTED]]
== headers end ==
== body start ==
{"filter": "timestamp>=\"2021-09-02T15:00:00.000000Z\"", "orderBy": "timestamp desc", "pageSize": 1000, "resourceNames": ["projects/${PROJECT}"]}
== body end ==
使用了 REST 方法[1]。 要求:
{
"resourceNames": [
"projects/[PROJECT_ID]"
]
}
回复:
{
"nextPageToken": "..."
}
但是当替代资源以格式指定时
projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
返回日志条目。 有什么方法可以使用短资源格式获取日志?
一个技巧(!?)是添加一个过滤器来捕获日志条目,也许:
{
"resourceNames": [
"projects/[[PROJECT_ID]]"
],
"filter": "timestamp>=\"2021-09-02T15:00:00.000000Z\""
}
并使用 pageSize
验证这一点的一种方法是让 gcloud
显示底层 --log-http
调用:
gcloud logging read \
--project=${PROJECT} \
--log-http
=======================
==== request start ====
uri: https://logging.googleapis.com/v2/entries:list?alt=json
method: POST
== headers start ==
[[REDACTED]]
== headers end ==
== body start ==
{"filter": "timestamp>=\"2021-09-02T15:00:00.000000Z\"", "orderBy": "timestamp desc", "pageSize": 1000, "resourceNames": ["projects/${PROJECT}"]}
== body end ==