Chapter 10. Forward logs to S3-compatible object storage
Forward logs to any S3-compatible object storage endpoint, including Amazon S3, MinIO, Ceph Object Gateway, and Red Hat OpenShift Data Foundation. Authentication supports AWS access keys or IAM roles for STS-enabled clusters.
10.1. Forward logs to Amazon S3 endpoint Copy linkLink copied to clipboard!
To configure log forwarding to an Amazon S3 endpoint, create a ClusterLogForwarder custom resource (CR) with an S3 output and a pipeline that uses it.
Prerequisites
- You have installed Red Hat OpenShift Logging Operator.
- You have administrator access to OpenShift Container Platform.
-
You have installed OpenShift CLI (
oc).
Procedure
Create a
SecretYAML file that uses theaws_access_key_idandaws_secret_access_keyfields to specify your base64-encoded AWS credentials. For example:apiVersion: v1 kind: Secret metadata: name: aws-secret namespace: <namespace_name> data: aws_access_key_id: QUtJQUlPU0ZPRE5ON0VYQU1QTEUK aws_secret_access_key: d0phbHJYVXRuRkVNSS9LN01ERU5HL2JQeFJmaUNZRVhBTVBMRUtFWQo=namespace-
Specify the namespace where your
ClusterLogForwarderCR is deployed. The secret must be in the same namespace as theClusterLogForwarderCR.
Create the secret. For example:
$ oc apply -f aws-secret.yamlCreate or edit a YAML file that defines the
ClusterLogForwarderCR object and specify the secret name. For example:apiVersion: observability.openshift.io/v1 kind: ClusterLogForwarder metadata: name: <log_forwarder_name> spec: serviceAccount: name: <service_account_name> outputs: - name: s3bucket type: s3 s3: authentication: type: awsAccessKey awsAccessKey: keyId: key: aws_access_key_id secretName: aws-secret keySecret: key: aws_secret_access_key secretName: aws-secret bucket: <bucket_name> keyPrefix: 's3{.log_type||"missing"}' region: us-east-1 url: 'https://s3.us-east-1.amazonaws.com' pipelines: - name: pipe1 inputRefs: - application outputRefs: - s3bucketserviceAccount.name- Specify the name of your service account.
outputs.name- Specify a name for the output.
type-
Specify the
s3type. secretName- Specify the name of the secret that has your AWS credentials.
bucket- Specify the Amazon S3 bucket name for log storage.
keyPrefix- Specify the S3 key prefix for log objects. The value can be a combination of static and dynamic values consisting of field paths separated by "||". Encase dynamic values in single curly brackets "{}". You must follow dynamic values with a static fallback value.
url-
Optional: Specify the S3 endpoint URL. If you do not specify this, the system uses the default AWS S3 endpoint
https://s3.<region>.amazonaws.combased on the region. Use this field for S3-compatible storage endpoints or custom endpoints.
Apply the CR object:
$ oc apply -f <file_name>.yaml
10.2. Forward logs to Amazon S3 endpoint from STS-enabled clusters Copy linkLink copied to clipboard!
You can forward logs from logging for Red Hat OpenShift deployed on Amazon Web Services (AWS) Security Token Service (STS)-enabled clusters to an S3 configured endpoint.
Prerequisites
- You have installed Red Hat OpenShift Logging Operator.
- You have configured a credential secret.
- You have administrator access to OpenShift Container Platform.
-
You have installed OpenShift CLI (
oc).
Procedure
Create or update a
ClusterLogForwardercustom resource (CR):apiVersion: observability.openshift.io/v1 kind: ClusterLogForwarder metadata: name: <log_forwarder_name> spec: serviceAccount: name: <service_account_name> outputs: - name: s3-output type: s3 s3: keyPrefix: 's3{.log_type||"missing"}' bucket: <bucket_name> region: us-east-2 authentication: type: iamRole iamRole: roleARN: key: role_arn secretName: sts-secret token: from: serviceAccount pipelines: - name: to-s3 inputRefs: - infrastructure - audit - application outputRefs: - s3-output-
keyPrefix: The S3 key prefix for log objects. You can use static or dynamic values consisting of field paths separated by||and ending with a static fallback value. -
bucket: The S3 bucket name for log storage.
-
Apply the
ClusterLogForwarderCR by running the following command:$ oc apply -f <filename>.yaml