How can I set current time in field

Hi,
Could you please share with me info how I can to set current system time in field "@timestamp".
In my case, I successfully copy field with @timestamp in filed "real_timestamp".
And then I would like to set @timestamp with system time of the server we logstash running.

You could try the following:

    ruby { 
         code => "event.set('systemtime', Time.now());"
    }
1 Like

Hi guys,
Thanx @Eniqmatic
I've done this job with the following config:

 mutate {
    add_field => { "realtimestamp" => "%{@timestamp}" }
        }

      ruby {
        code => "event.set('logstash_processed_at', Time.now());"
        }

    mutate {
    convert => { "logstash_processed_at" => "string" }
        }

    date {
    match => [ "logstash_processed_at", "ISO8601" ]
    target => "@timestamp"
    add_tag => "timestamp_changed"
    }
1 Like

Correct well done!

Please mark as solved! :slight_smile:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.