Logstash Extract Elasticsearch Nested Fields

Hello Team

I am using Elasticsearch version 7.8.0 and Logstash version 7.8.0

I am having ES Index having following mappings :

    "mappings" : {
      "properties" : {
        "appEvents" : {
          "properties" : {
            "attribute" : {
              "properties" : {
                "filesPendingForUpload" : {
                  "type" : "text",
                  "fields" : {
                    "keyword" : {
                      "type" : "keyword",
                      "ignore_above" : 256
                    }
                  }
                },
                "filesUploadedSinceLastEvent" : {
                  "type" : "text",
                  "fields" : {
                    "keyword" : {
                      "type" : "keyword",
                      "ignore_above" : 256
                    }
                  }
                },
                "launch" : {
                  "type" : "text",
                  "fields" : {
                    "keyword" : {
                      "type" : "keyword",
                      "ignore_above" : 256
                    }
                  }
                }
              }
            },

Now i want to extract the data from ES Index to CSV file using logstash.

In logstash conf file I have specified

output {
  csv {
    fields => ["[appEvents][attribute][filesPendingForUpload]"]
    path => "/tmp/exp.csv"
  }
}

But I am not getting respective field data in csv.

As per my understanding, I am not writing fields in proper format...

Could you please help me in getting data into csv.

Thank You.

I meant to ask that .. how to mention fields having multi-nested ones in logstash ...

Hello Team

I tried using filter = mutate = for merging multiple fields into single field ...

filter {
    mutate {
        add_field => { "filesPendingForUpload" => "%{[appEvents][attribute_num][filesPendingForUpload]}" }
        add_field => { "filesUploadedSinceLastEvent" => "%{[appEvents][attribute_num][filesUploadedSinceLastEvent]}" }
  }
}

But my output contains :

6018a66855b6471ebf976b2d551c9731,1623241661046,Y,WLC,Y,Y,CAM,Original,,OFF,%{[appEvents][attribute_num][filesPendingForUpload]},%{[appEvents][attribute_num][filesUploadedSinceLastEvent]}

Below data i want to extract using logstash into CSV file ...

I tried multiple ways , but not able to achieve it...

Could someone please help me ...

"appEvents":[{"attribute_num":{"filesPendingForUpload":8,"filesUploadedSinceLastEvent":173}}]```

can someone please help me how to mentioned deep nested fields in logstash

output plugin of csv : FIELDS