elasticsearchlogstashkibanaelklogstash-file

how to get only date from timestamp in logstash?


I have date format 12/1/2020 12:08:27 AM, I want only date like 12/1/2020. Is any way to get date in logstash? I have tried to find out the date but didn't get, What I want then I separated each term like day,month, year. But Actually I want complete date format as mentioned above.


Solution

  • You can use grok instead of date. The date filter is for converting strings to timestamps only. Here's an example (using the field name from your comment).

    filter {
      grok {
        match => { "SMSDate" => "^%{NUMBER:day}\/%{NUMBER:month}\/%{NUMBER:year}" }
      }
    }
    

    The approach in your own comment, which uses Logstash's date math on the @timestamp field, is also valid.