我已经使用gcloud命令创建了GCP日志接收器,它可以工作。现在,我想将该代码移到CloudBuild.Yaml的等效文件中。有人能给我指一下log sink cloud build yaml模板吗?或者你是否可以将下面的命令转换为cloudbuild.yaml文件?
我的gcloud命令如下,它在云外壳中成功工作:
gcloud logging sinks create test3-${_ENV} pubsub.googleapis.com/projects/amer-xxxxxx-us-yyyy-dv/topics/pppp-topic-qqq-pubsub-dv --log-filter='(resource.labels.job_name=("amer-xxx-dv-df-xhxh-sel-details") jsonPayload.message:("completed successfully") jsonPayload.step=("WriteSuccessfulRecords/BatchLoads/SinglePartitionWriteTables/ParMultiDo(WriteTables)")) OR (resource.labels.job_name=("amer-xxxx-dv-df-pqpq-sel-review") jsonPayload.message:("completed successfully") jsonPayload.step=("WriteSuccessfulRecords/BatchLoads/SinglePartitionWriteTables/ParMultiDo(WriteTables)")) OR (resource.labels.job_name=("amer-xxxx-dv-df-pqpq-order") jsonPayload.message:("completed successfully") jsonPayload.step=("WriteSuccessfulRecords/BatchLoads/SinglePartitionWriteTables/ParMultiDo(WriteTables)"))'
有什么困难?
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- -c
- |
gcloud logging sinks create test3-${_ENV} pubsub.googleapis.com/projects/amer-xxxxxx-us-yyyy-dv/topics/pppp-topic-qqq-pubsub-dv --log-filter='(resource.labels.job_name=("amer-xxx-dv-df-xhxh-sel-details") jsonPayload.message:("completed successfully") jsonPayload.step=("WriteSuccessfulRecords/BatchLoads/SinglePartitionWriteTables/ParMultiDo(WriteTables)")) OR (resource.labels.job_name=("amer-xxxx-dv-df-pqpq-sel-review") jsonPayload.message:("completed successfully") jsonPayload.step=("WriteSuccessfulRecords/BatchLoads/SinglePartitionWriteTables/ParMultiDo(WriteTables)")) OR (resource.labels.job_name=("amer-xxxx-dv-df-pqpq-order") jsonPayload.message:("completed successfully") jsonPayload.step=("WriteSuccessfulRecords/BatchLoads/SinglePartitionWriteTables/ParMultiDo(WriteTables)"))'
并在调用Cloud Build 时正确设置_ENV替换变量