diff --git a/docs/patterns/images/ADOT_container_logs.png b/docs/patterns/images/ADOT_container_logs.png new file mode 100644 index 00000000..d05106b0 Binary files /dev/null and b/docs/patterns/images/ADOT_container_logs.png differ diff --git a/docs/patterns/images/ADOT_container_logs_group.png b/docs/patterns/images/ADOT_container_logs_group.png new file mode 100644 index 00000000..160e9bdc Binary files /dev/null and b/docs/patterns/images/ADOT_container_logs_group.png differ diff --git a/docs/patterns/images/ADOT_container_logs_insights.png b/docs/patterns/images/ADOT_container_logs_insights.png new file mode 100644 index 00000000..5c95dc04 Binary files /dev/null and b/docs/patterns/images/ADOT_container_logs_insights.png differ diff --git a/docs/patterns/images/ADOT_container_logs_insights_results.png b/docs/patterns/images/ADOT_container_logs_insights_results.png new file mode 100644 index 00000000..6ee5c917 Binary files /dev/null and b/docs/patterns/images/ADOT_container_logs_insights_results.png differ diff --git a/docs/patterns/images/logs-fargate-fluentbit.png b/docs/patterns/images/logs-fargate-fluentbit.png new file mode 100644 index 00000000..0741eda8 Binary files /dev/null and b/docs/patterns/images/logs-fargate-fluentbit.png differ diff --git a/docs/patterns/single-new-eks-observability-accelerators/single-new-eks-container-logs-opensource-observability.md b/docs/patterns/single-new-eks-observability-accelerators/single-new-eks-container-logs-opensource-observability.md new file mode 100644 index 00000000..7084bb7d --- /dev/null +++ b/docs/patterns/single-new-eks-observability-accelerators/single-new-eks-container-logs-opensource-observability.md @@ -0,0 +1,84 @@ +# Single Cluster Open Source Observability - Container Logs Collection + +## Objective + +Following the [announcement](https://aws.amazon.com/about-aws/whats-new/2023/11/logs-support-aws-distro-opentelemetry/) of logs support in AWS Distro for OpenTelemetry, this pattern demonstrates how to use the _New EKS Cluster Open Source Observability Accelerator_ to forward container logs to cloud watch using ADOT containers log collector. + +## Prerequisites + +Ensure that you have installed the following tools on your machine. + +1. [aws cli](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) +2. [kubectl](https://Kubernetes.io/docs/tasks/tools/) +3. [cdk](https://docs.aws.amazon.com/cdk/v2/guide/getting_started.html#getting_started_install) +4. [npm](https://docs.npmjs.com/cli/v8/commands/npm-install) + +## Deploying + +Please follow the _Deploying_ instructions of the [New EKS Cluster Open Source Observability Accelerator](./single-new-eks-opensource-observability.md) pattern, except for step 7, where you need to replace "context" in `~/.cdk.json` with the following: + +```typescript + "context": { + "fluxRepository": { + "name": "grafana-dashboards", + "namespace": "grafana-operator", + "repository": { + "repoUrl": "https://github.com/aws-observability/aws-observability-accelerator", + "name": "grafana-dashboards", + "targetRevision": "main", + "path": "./artifacts/grafana-operator-manifests/eks/infrastructure" + }, + "values": { + "GRAFANA_CLUSTER_DASH_URL" : "https://raw.githubusercontent.com/aws-observability/aws-observability-accelerator/main/artifacts/grafana-dashboards/eks/infrastructure/cluster.json", + "GRAFANA_KUBELET_DASH_URL" : "https://raw.githubusercontent.com/aws-observability/aws-observability-accelerator/main/artifacts/grafana-dashboards/eks/infrastructure/kubelet.json", + "GRAFANA_NSWRKLDS_DASH_URL" : "https://raw.githubusercontent.com/aws-observability/aws-observability-accelerator/main/artifacts/grafana-dashboards/eks/infrastructure/namespace-workloads.json", + "GRAFANA_NODEEXP_DASH_URL" : "https://raw.githubusercontent.com/aws-observability/aws-observability-accelerator/main/artifacts/grafana-dashboards/eks/infrastructure/nodeexporter-nodes.json", + "GRAFANA_NODES_DASH_URL" : "https://raw.githubusercontent.com/aws-observability/aws-observability-accelerator/main/artifacts/grafana-dashboards/eks/infrastructure/nodes.json", + "GRAFANA_WORKLOADS_DASH_URL" : "https://raw.githubusercontent.com/aws-observability/aws-observability-accelerator/main/artifacts/grafana-dashboards/eks/infrastructure/workloads.json" + }, + "kustomizations": [ + { + "kustomizationPath": "./artifacts/grafana-operator-manifests/eks/infrastructure" + } + ] + }, + "adotcontainerlogs.pattern.enabled": true + } +``` + +!! warning This scenario might need larger worker node for the pod. + + +Once completed the rest of the _Deploying_ steps, you can move on with the deployment of the Nginx workload. + +## Viewing Logs in CloudWatch Log Groups and Logs Insights + +Navigate to CloudWatch, then go to "Log groups" + +Search for log group with the name "/aws/eks/single-new-eks-mixed-observability-accelerator" and open it + +You will see log streams created using the node name + +![ADOT_container_logs_group](../images/ADOT_container_logs_group.png) + +Open the log stream and you view the logs forwarded by the container logs collector to CloudWatch + +![ADOT_container_logs](../images/ADOT_container_logs.png) + +Navigate to CloudWatch, then go to "Logs Insights" + +In the dropdown, select log group with name "/aws/eks/single-new-eks-mixed-observability-accelerator" and run a query. + +![ADOT_container_logs_insights](../images/ADOT_container_logs_insights.png) + +Then you can view the results of your query: + +![ADOT_container_logs_insights](../images/ADOT_container_logs_insights_results.png) + +## Teardown + +You can teardown the whole CDK stack with the following command: + +```bash +make pattern single-new-eks-opensource-observability destroy +``` diff --git a/docs/patterns/single-new-eks-observability-accelerators/single-new-eks-fargate-opensource-observability.md b/docs/patterns/single-new-eks-observability-accelerators/single-new-eks-fargate-opensource-observability.md index 08004375..fe7e0071 100644 --- a/docs/patterns/single-new-eks-observability-accelerators/single-new-eks-fargate-opensource-observability.md +++ b/docs/patterns/single-new-eks-observability-accelerators/single-new-eks-fargate-opensource-observability.md @@ -194,8 +194,10 @@ You should now see a new dashboard named `Java/JMX`, under `Observability Accele ## Viewing Logs -By default, we deploy a FluentBit daemon set in the cluster to collect worker logs for all namespaces. Logs are collected and exported to Amazon CloudWatch Logs, which enables you to centralize the logs from all of your systems, applications, -and AWS services that you use, in a single, highly scalable service. +Amazon EKS on Fargate offers a built-in log router based on Fluent Bit. This means that you don't explicitly run a Fluent Bit container as a sidecar, but Amazon runs it for you. All that you have to do is configure the log router. The configuration happens through a dedicated [`ConfigMap`](../../../lib/common/resources/fluent-bit/fluent-bit-fargate-config.ytpl). Logs are collected and exported to Amazon CloudWatch Logs, which enables you to centralize the logs from all of your systems, applications, +and AWS services that you use, in a single, highly scalable service. By default, the logs are exported to us-east-1 region but you can modify the `ConfigMap` for your region of choice. At least one supported `OUTPUT` plugin has to be provided in the `ConfigMap` to enable logging. You can also modify the destination from cloudwatch to Cloudwatch (default), Amazon OpenSearch Service or Kinesis Data Firehose. Read more about [EKS Fargate logging](https://docs.aws.amazon.com/eks/latest/userguide/fargate-logging.html). + +![fargate-fluentbit](../images/logs-fargate-fluentbit.png) ## Teardown diff --git a/lib/common/resources/fluent-bit/fluent-bit-fargate-config.ytpl b/lib/common/resources/fluent-bit/fluent-bit-fargate-config.ytpl new file mode 100644 index 00000000..53871b4d --- /dev/null +++ b/lib/common/resources/fluent-bit/fluent-bit-fargate-config.ytpl @@ -0,0 +1,42 @@ +kind: Namespace +apiVersion: v1 +metadata: + name: aws-observability + labels: + aws-observability: enabled +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: aws-logging + namespace: aws-observability +data: + flb_log_cw: "{{enableFlbProcessLogs}}" # Set to true to ship Fluent Bit process logs to CloudWatch. + filters.conf: | + [FILTER] + Name parser + Match * + Key_name log + Parser crio + [FILTER] + Name kubernetes + Match kube.* + Merge_Log On + Keep_Log Off + Buffer_Size 0 + Kube_Meta_Cache_TTL 300s + output.conf: | + [OUTPUT] + Name cloudwatch_logs + Match kube.* + region {{awsRegion}} + log_group_name {{logGroupName}} + log_stream_prefix {{log_stream_prefix}} + auto_create_group true + parsers.conf: | + [PARSER] + Name crio + Format Regex + Regex ^(?