11.14. 将日志转发到 Google Cloud Platform (GCP)

除了默认的 OpenShift Container Platform 日志存储外,您还可以将日志转发到 Google Cloud Logging

注意

不支持在 Fluentd 中使用此功能。

先决条件

  • Red Hat OpenShift Operator 5.5.1 及更新版本的日志记录子系统

流程

  1. 使用 Google 服务帐户密钥创建 secret。

    $ oc -n openshift-logging create secret generic gcp-secret --from-file google-application-credentials.json=<your_service_account_key_file.json>
  2. 使用以下模板创建 ClusterLogForwarder 自定义资源 YAML:

    apiVersion: "logging.openshift.io/v1"
    kind: "ClusterLogForwarder"
    metadata:
      name: "instance"
      namespace: "openshift-logging"
    spec:
      outputs:
        - name: gcp-1
          type: googleCloudLogging
          secret:
            name: gcp-secret
          googleCloudLogging:
            projectId : "openshift-gce-devel" 1
            logId : "app-gcp" 2
      pipelines:
        - name: test-app
          inputRefs: 3
            - application
          outputRefs:
            - gcp-1
    1
    根据您要将日志存储在 GCP 资源层次结构中的位置,设置 projectId, folderId, organizationId, 或 billingAccountId 的项及其相应的值。
    2
    将值设为添加到 Log EntrylogName 字段的值。
    3
    使用管道指定要转发的日志类型:application, infrastructure, 或 audit