Hello!
I am trying to copy the day and hour from the timestamp field and add each to their own fields.
Here is my code:
if [source] =~ "tableBASEtest" {
mutate{ add_field => {
"[@metadata][timestamp]" => "%{SMF30DTE} %{SMF30TME}"
}}
date{ match => [
"[@metadata][timestamp]", "yyyy-MM-dd HH:mm:ss:SS"
]}
mutate {
add_field => {"hour" => "%{+HH}"}
add_field => {"day" => "%{+EEE}"}
}
}
For some reason, when this runs, no new fields are created. And sometimes kibana defaults to an old index from a previous configuration (no clue as to what would cause that).
Also,
I've tried this as well:
if [source] =~ "tableBASEtest" {
mutate{ add_field => {
"[@metadata][timestamp]" => "%{SMF30DTE} %{SMF30TME}"
}}
date{ match => [
"[@metadata][timestamp]", "yyyy-MM-dd HH:mm:ss:SS"
]}
ruby{
code => "event.set('[day_of_week]',event.get('@timestamp').time.strftime '%a')"
}
}
This just errors out with:
[2019-10-21T18:58:28,368][ERROR][org.logstash.Logstash ] java.lang.IllegalStateException: Logstash stopped processing because of an error: (SyntaxError) (ruby filter code):2: syntax error, unexpected tSTRING_BEG
event.set('day_of_week',event.get('@timestamp').time.strftime '%a')
Any help would be awesome.