Hi,
I have two fields and I want to compare it
- field1: 20220720091723
- field2: 07/20/22 09:17
I want to compare it so i don't know if i should convert to date then compare and how or can someone please tell me what i should do
Thanks!
Hi,
I have two fields and I want to compare it
Thanks!
i tryed this in logstash :
date {
match => [ "field1", "yyyyMMddHHmmss" ]
}
but still doesn't work it stays String... and if I convert these two fields so I can compare it, right?
I think i found the solution but there is somthing wrong
date {
match => [ "field1", "yyyyMMddHHmmss" ]
target => "field1"
}
date {
match => [ "field2", "dd/MM/yy HH:mm" ]
target => "field2"
}
output:
Any help would be sincerely appreciate!
Thanks!
Maybe. See this thread.
Thanks for the reply
there is a little thing that i don't understand here the original field 20220720185907
after matching and target ... it looks like this now field1: 2022-07-20T17:59:07.000Z
it was changed for one hour honestly i don't know why.
after ruby filter and thanks for this it gives me someField000: 2022-07-20 18:07
ruby filter :
ruby {
code => '
t = Time.at(event.get("Date Transmission").to_f)
event.set("someField", t.strftime("%Y-%m-%d"))
event.set("someField000", t.strftime("%Y-%m-%d %H:%m"))
'
}
But I specified the minute not the second. did i do something wrong ?
Thanks!
When you parse a string with a date filter the result is always in UTC (note the Z at the end of [field1]. Is the timezone of the machine running logstash one hour ahead of UTC, as much of Europe is?
Yes ok thanks, just about the ruby filter event.set("someField000", t.strftime("%Y-%m-%d %H:%m"))
I specified the minute not the second and it gives me someField000: 2022-07-20 18:07
there is somthing wrong right ?
Looks OK to me. Why do you think it is wrong?
I mean it should give me someField000:2022-07-20 18:59
not someField000:2022-07-20 18:07
i specified %H:%m
not %H: %s
no?
%H:%m
is hour and month, not hour and minute. Try %H:%M
.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.