How to push logs in plain text format using fluentd to AWS cloudwatch?

4/22/2020

I want to send logs from Kubernetes pods to cloudwatch in plain text format. Is there a way to achieve this?

I am able to send logs in JSON format using fluent/fluentd-kubernetes-daemonset:v1.3.3-debian-cloudwatch-1.0 but I am not sure how to send it in plain text format. I will really appreciate any help.

Current log :

{
  "log": "2020-04-22 08:00:00.002  WARN 7 --- [viderScheduler1] c.o.c.a.p.c.SchedulerConfiguration       :  HELLO\n",
  "stream": "stdout",
  "docker": {
    "container_id": "ASDF"
  },
  "kubernetes": {
    "container_name": "CHART",
    "namespace_name": "NAMESPACE",
    "pod_name": "POD_NAME",
    "container_image": "IMAGE",
    "container_image_id": "IMAGE_ID",
    "pod_id": "ID",
    "labels": {
      "app": "app",
      "date": "1587541693",
      "environment": "env",
      "pod-template-hash": "bcbcb",
      "release": "asdf",
      "tier": "asdf",
      "version": "v1.2.3"
    },
    "host": "IP",
    "master_url": "master_URL",
    "namespace_id": "ns"
  }
}

Expected log :

2020-04-22 08:00:00.002  WARN 7 --- [viderScheduler1] c.o.c.a.p.c.SchedulerConfiguration       :  HELLO\n
-- manish
amazon-cloudwatch
fluentd
kubernetes

0 Answers