|
| 1 | +--- |
| 2 | +title: 'Container Logs Collector Configuration' |
| 3 | +description: |
| 4 | + This page introduces Collector configuration for Container Logs for the ADOT Collector. |
| 5 | +path: '/docs/getting-started/adot-eks-add-on/config-container-logs' |
| 6 | +--- |
| 7 | +The Container Logs collector configuration launches a preconfigured OpenTelemetry Collector custom resource |
| 8 | +to tail all Kubernetes pod logs with the [filelog](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/filelogreceiver) receiver. By opting into the |
| 9 | +[available pipeline](/docs/getting-started/adot-eks-add-on/config-container-logs/#container-logs-pipelines) |
| 10 | +you can control where the collected logs are sent. In this preconfigured custom resource, |
| 11 | +the collector will run as a [DaemonSet](https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/) in order to capture all logs on each node. |
| 12 | + |
| 13 | +## Prerequisites |
| 14 | + |
| 15 | +### Setup an IAM role to associate with the service account |
| 16 | + |
| 17 | +An IAM Role with the following policies must be created for the following Kubernetes |
| 18 | +service account and namespace. |
| 19 | + |
| 20 | +| Service Account Name | Namespace | IAM Policies | |
| 21 | +| -------------------------- | --------- | ------------ | |
| 22 | +| <nobr>adot-col-container-logs</nobr> | <nobr>opentelemetry-operator-system</nobr> | CloudWatchAgentServerPolicy | |
| 23 | +**Note:** Only attach the minimum set of policies necessary for your advanced configuration. |
| 24 | + |
| 25 | +The [IAM Roles for Service Accounts documentation (IRSA)](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.htmlhttps://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html) contains instructions for creating the IAM |
| 26 | +role. The following examples will use [eksctl](https://eksctl.io/usage/iamserviceaccounts/https://eksctl.io/usage/iamserviceaccounts/) to achieve this. |
| 27 | + |
| 28 | +To create this IAM role, run the following command: |
| 29 | + |
| 30 | +```console |
| 31 | +eksctl create iamserviceaccount \ |
| 32 | + --name adot-col-container-logs \ |
| 33 | + --namespace opentelemetry-operator-system \ |
| 34 | + --cluster <your_cluster_name> \ |
| 35 | + --attach-policy-arn arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy \ |
| 36 | + --approve \ |
| 37 | + --role-only |
| 38 | +``` |
| 39 | + |
| 40 | +This IAM role generated by the above command needs to be inserted into the annotations |
| 41 | +field of the advanced configuration as seen below: |
| 42 | +```yaml |
| 43 | +collector: |
| 44 | + containerLogs: |
| 45 | + serviceAccount: |
| 46 | + annotations: |
| 47 | + eks.amazonaws.com/role-arn: <iam_role_arn> |
| 48 | +``` |
| 49 | +
|
| 50 | +## Container Logs pipelines |
| 51 | +The following pipelines are available for the Container Logs preconfigured custom resource. |
| 52 | +Pipelines can be enabled by setting their `enabled` field to `true`. |
| 53 | + |
| 54 | +### Logs |
| 55 | + |
| 56 | +- #### cloudwatchLogs |
| 57 | +Logs collected by a filelog receiver are sent to Amazon CloudWatch Logs. |
| 58 | + |
| 59 | +### Container Logs Advanced Configuration pipeline |
| 60 | +```yaml |
| 61 | +collector: |
| 62 | + containerLogs: |
| 63 | + serviceAccount: |
| 64 | + annotations: |
| 65 | + eks.amazonaws.com/role-arn: <iam_role_arn> |
| 66 | + pipelines: |
| 67 | + logs: |
| 68 | + cloudwatchLogs: |
| 69 | + enabled: true |
| 70 | +``` |
| 71 | + |
| 72 | +## Container Logs exporters |
| 73 | +The following exporters can be configured for the Container Logs preconfigured custom resource. |
| 74 | + |
| 75 | +### awscloudwatchlogs |
| 76 | + |
| 77 | +- #### log_group_name |
| 78 | +The name for the Amazon CloudWatch log group. Must follow pattern: `[\\.\\-_/#A-Za-z0-9]+` |
| 79 | + |
| 80 | +- #### log_stream_name |
| 81 | +The name for the Amazon CloudWatch log stream. Must follow pattern: `[^:*]*` |
| 82 | + |
| 83 | +### Container Logs Advanced Configuration exporters |
| 84 | +```yaml |
| 85 | +collector: |
| 86 | + containerLogs: |
| 87 | + serviceAccount: |
| 88 | + annotations: |
| 89 | + eks.amazonaws.com/role-arn: <iam_role_arn> |
| 90 | + pipelines: |
| 91 | + logs: |
| 92 | + cloudwatchLogs: |
| 93 | + enabled: true |
| 94 | + exporters: |
| 95 | + awscloudwatchlogs: |
| 96 | + log_group_name: <log_group_name> |
| 97 | + log_stream_name: <log_stream_name> |
| 98 | +``` |
| 99 | + |
| 100 | +## Container Logs configurable values |
| 101 | + |
| 102 | +Shown below is the complete list of configurable fields, along with their default values, for the containerLogs resource. |
| 103 | +`$CLUSTER_NAME` refers to the name of the EKS cluster and `$NODE_NAME` refers to the name of the Kubernetes node in the daemonset. |
| 104 | + |
| 105 | +```yaml |
| 106 | +collector: |
| 107 | + containerLogs: |
| 108 | + resources: |
| 109 | + limits: |
| 110 | + cpu: 1000m |
| 111 | + memory: 750Mi |
| 112 | + requests: |
| 113 | + cpu: 300m |
| 114 | + memory: 512Mi |
| 115 | + serviceAccount: |
| 116 | + annotations: |
| 117 | + pipelines: |
| 118 | + logs: |
| 119 | + cloudwatchLogs: |
| 120 | + enabled: false |
| 121 | + exporters: |
| 122 | + awscloudwatchlogs: |
| 123 | + log_group_name: $CLUSTER_NAME/container/logs |
| 124 | + log_stream_name: $NODE_NAME |
| 125 | +
|
| 126 | +``` |
| 127 | +*Note that in Fargate, resource requests and limits must be equal, see |
| 128 | +this [troubleshooting guide](https://docs.aws.amazon.com/eks/latest/userguide/troubleshooting-adot.html) for more information. |
| 129 | + |
| 130 | +## [Previous Topic: Add-on Advanced Configuration: Collector Deployment](/docs/getting-started/adot-eks-add-on/add-on-configuration-collector-deployment) |
| 131 | + |
| 132 | +## Related Topics: |
| 133 | + |
| 134 | +### [Collector Configuration for Prometheus Metrics](/docs/getting-started/adot-eks-add-on/config-prometheus-metrics) |
| 135 | + |
| 136 | +### [Collector Configuration for OTLP Ingest](/docs/getting-started/adot-eks-add-on/config-otlp-ingest) |
| 137 | + |
| 138 | +## [Next Topic: Updating and Cleanup](/docs/getting-started/adot-eks-add-on/update-and-cleanup) |
0 commit comments