Cloud Run服务在Google Cloud Logging中缺失



我正在尝试使用Google Cloud Operations Logging (Logging Explorer)分析在Cloud Run中运行的服务的日志。如果我使用Cloud Run中的logs部分,则会出现日志。然而,并非所有在Cloud Run中运行的服务都出现在Google Cloud Logging中。是否需要进行任何配置更改才能使云服务反映在日志记录中?

谢谢

这应该会给您一个简单的调和:

# The Project in which the Cloud Run services are deployed
PROJECT=.... # GCP Project ID
# The list of Cloud Run services in the project
SERVICES=$(gcloud run services list 
--project=${PROJECT} 
--format="value(metadata.name)") && echo ${SERVICES}
# For each service
for SERVICE in ${SERVICES}
do
# Filter the service's logs
FILTER="resource.type="cloud_run_revision" resource.labels.service_name="${SERVICE}""
# Count them (there is likely a better way)
COUNT=$(gcloud logging read "${FILTER}" 
--project=${PROJECT} 
--format="value(textPayload)" | wc -l)
# List the services and their log counts
printf "%stt%sn" ${SERVICE} ${COUNT}
done

相关内容

  • 没有找到相关文章

最新更新