Skip to content

Commit

Permalink
[Doc] Logging: Delete the sections from `Set up logging on a DaemonSe…
Browse files Browse the repository at this point in the history
…t with Fluent Bit` to `Check the CloudWatch dashboard`. (ray-project#48936)

Signed-off-by: win5923 <[email protected]>
Signed-off-by: hjiang <[email protected]>
  • Loading branch information
win5923 authored and dentiny committed Dec 7, 2024
1 parent 2aff4be commit 0a58eff
Showing 1 changed file with 0 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,105 +134,6 @@ Examine the FluentBit sidecar's STDOUT to see logs for Ray's component processes
kubectl logs raycluster-complete-logs-head-xxxxx -c fluentbit
```

(kuberay-fluentbit-ds)=
## Set up logging on a DaemonSet with Fluent Bit

Fluent Bit is a lightweight agent that allows you to collect logs from your Kubernetes cluster and send them to a variety of destinations such as Elasticsearch, CloudWatch, S3, etc.
The following steps set up [Fluent Bit][FluentBit] as a DaemonSet to send logs to CloudWatch Logs.

### Setup for AWS EKS

Create an Amazon EKS cluster named `fluent-bit-demo` in `us-west-2` region using `eksctl`, as shown in the [EKS docs](https://docs.aws.amazon.com/eks/latest/userguide/getting-started-eksctl.html).

```shell
eksctl create cluster --name fluent-bit-demo --region us-west-2
```

View your cluster nodes:
```shell
$ kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
ip-192-168-59-62.us-west-2.compute.internal Ready <none> 157m v1.27.5-eks-43840fb 192.168.59.62 54.190.144.241 Amazon Linux 2 5.10.192-183.736.amzn2.x86_64 containerd://1.6.19
ip-192-168-86-99.us-west-2.compute.internal Ready <none> 157m v1.27.5-eks-43840fb 192.168.86.99 34.219.16.107 Amazon Linux 2 5.10.192-183.736.amzn2.x86_64 containerd://1.6.19
```

EKS cluster nodes need to have access to CloudWatch Logs for Fluent Bit.
Attach the `CloudWatchLogsFullAccess` policy to the IAM role that is attached to the cluster nodes:

```shell
ROLE_NAME=$(eksctl get nodegroup --cluster fluent-bit-demo --region us-west-2 -o json | jq -r '.[].NodeInstanceRoleARN' | cut -f2 -d/)

aws iam attach-role-policy \
--role-name $ROLE_NAME \
--policy-arn arn:aws:iam::aws:policy/CloudWatchLogsFullAccess
```

### Deploy Fluent Bit DaemonSet

If you don't already have a namespace called `amazon-cloudwatch`, create one by entering the following command:

```bash
kubectl apply -f https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/latest/k8s-deployment-manifest-templates/deployment-mode/daemonset/container-insights-monitoring/cloudwatch-namespace.yaml
```

Run the following command to create a ConfigMap named `cluster-info` with the cluster name and the Region to send logs to:

```shell
ClusterName=fluent-bit-demo
RegionName=us-west-2
FluentBitHttpPort='2020'
FluentBitReadFromHead='Off'
[[ ${FluentBitReadFromHead} = 'On' ]] && FluentBitReadFromTail='Off'|| FluentBitReadFromTail='On'
[[ -z ${FluentBitHttpPort} ]] && FluentBitHttpServer='Off' || FluentBitHttpServer='On'
kubectl create configmap fluent-bit-cluster-info \
--from-literal=cluster.name=${ClusterName} \
--from-literal=http.server=${FluentBitHttpServer} \
--from-literal=http.port=${FluentBitHttpPort} \
--from-literal=read.head=${FluentBitReadFromHead} \
--from-literal=read.tail=${FluentBitReadFromTail} \
--from-literal=logs.region=${RegionName} -n amazon-cloudwatch
```

Deploy the Fluent Bit DaemonSet to the cluster by running the following commands:

```shell
kubectl apply -f https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/latest/k8s-deployment-manifest-templates/deployment-mode/daemonset/container-insights-monitoring/fluent-bit/fluent-bit.yaml
```

Validate whether you successfully deployed Fluent Bit by entering the following command:

```shell
kubectl -n amazon-cloudwatch logs ds/fluent-bit
```

Verify that the command created log groups:

```shell
...
[2023/10/10 06:13:55] [ info] [output:cloudwatch_logs:cloudwatch_logs.0] Created log group /aws/containerinsights/fluent-bit-demo/application
[2023/10/10 06:13:57] [ info] [output:cloudwatch_logs:cloudwatch_logs.2] Created log group /aws/containerinsights/fluent-bit-demo/host
[2023/10/10 06:13:57] [ info] [output:cloudwatch_logs:cloudwatch_logs.1] Created log group /aws/containerinsights/fluent-bit-demo/dataplane
...
```

### Check the CloudWatch dashboard

Finally, check the CloudWatch dashboard to see the logs.
Open the CLoudWatch console at https://console.aws.amazon.com/cloudwatch/.

Type `/aws/containerinsights/fluent-bit-demo/` in the search box.

![CloudWatch Dashboard](images/cloudwatch-dashboard.png)

Select `/aws/containerinsights/fluent-bit-demo/application`. You should see the logs from the application pods including Ray.

Under the log streams, click any log stream. You should see the logs from the pods:

![CloudWatch Logs](images/cloudwatch-logs.png)

You can specify filters based on pod name, namespace, etc.
Learn how to write filters in this [filter pattern syntax doc](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html#matching-terms-events).

[Vector]: https://vector.dev/
[FluentBit]: https://docs.fluentbit.io/manual
[FluentBitStorage]: https://docs.fluentbit.io/manual
Expand Down

0 comments on commit 0a58eff

Please sign in to comment.