admin管理员组文章数量:1353618
A similar question was asked nearly two years ago, but there was no confirmed answer. Is it now possible to add custom attributes to the automatically generated logs in Cloud Run?
I’m not referring to manually logging additional data (e.g., sending custom logs to Cloud Logging) but rather modifying the default logs to include custom values in the httpRequest or labels section.
For example, if an x-my-custom-header is included in an HTTP request, I would like it to appear in Cloud Logging logs like this:
{
"httpRequest": {
"myCustomHeader": "my custom value here",
"...": "default attributes set by Cloud Run"
},
"labels": {
"instanceId": "someid",
"mylabel": "mylabelvalue"
},
"logName": "projects/my-project/logs/run.googleapis%2Frequests",
"resource": {
"type": "cloud_run_revision",
"labels": {
"service_name": "myservice"
}
}
}
As of 2025, has Google Cloud introduced a way to modify these logs, for example, via middleware in Python? If so, what is the recommended approach?
I created a middleware in Python that adds a custom header to the request before passing it to the application. However, this header does not appear in the automatically generated Cloud Logging logs for Cloud Run.
I expected that modifying the request before it reaches the application would allow the custom header to be included in the httpRequest
section of the logs. However, even though the header is present in the request when processed by my application, it does not show up in the Cloud Run logs.
Is there a way to ensure that a custom header added via middleware is included in the automatic Cloud Logging logs?
版权声明:本文标题:python - Can custom headers be added to automatically generated Cloud Logging logs in Cloud Run? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743891666a2557031.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论