How to set a value in timestamp

I have two values as my date and hour data and i want them to be my timestamp:

"F-MESSAGE-CAB": "20221018","H-MESSAGE-CAB": "601006"
"F-MESSAGE-CAB": "20221018","H-MESSAGE-CAB": "1338311"

What i'm trying to do is putting them together into one value and then overwrite the timestamp value but it doesn't work, i had tried with different date formats but the timestamp doesn't change from the actual date

This is the code

	mutate{
		add_field => {
			"DATE" => "%{F-MESSAGE-CAB}%{H-MESSAGE-CAB}" 
		}
	}
	date{
		match => ["DATE", "yyyy-MM-dd h:mm:ss"]
		target => "@timestamp"
	}

}

What does that number represent?

It's the hour "1338311" as 13:38:311

Try this:

Is that 311 seconds, or 31.1?

31.1 seconds

    ruby { code => 'event.set("H-MESSAGE-CAB", event.get("H-MESSAGE-CAB").to_s.rjust(7, "0"))' }
    mutate { add_field => { "[@metadata][date]" => "%{F-MESSAGE-CAB} %{H-MESSAGE-CAB}" } }
    date{ match => ["[@metadata][date]", "yyyyMMdd HHmmssS"] }

will produce

{
"H-MESSAGE-CAB" => "0601006",
"F-MESSAGE-CAB" => "20221018", 
   "@timestamp" => 2022-10-18T10:01:00.600Z, ...
}
{
"H-MESSAGE-CAB" => "1338311",
"F-MESSAGE-CAB" => "20221018",
   "@timestamp" => 2022-10-18T17:38:31.100Z, ...
2 Likes

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