Hi. I want to extract hour from timestamp and I do it but its type is String and I'm trying to change the type of hour
to integer but it doesn't effect. here is my logstash config:
input {
beats {
client_inactivity_timeout => 1200
port => 5044
}
}
filter {
grok {
match => {"message" => ["%{NOTSPACE:queueType}, (?<nothing>.{4})(?<part1>.{15})(?<nothing2>.{6}) %{NUMBER:part2}, %{INT:returnedCode}", "%{NOTSPACE:queueType}, (?<nothing>.{4})(?<part1>.{15})(?<nothing2>.{6}) %{NUMBER:part2}, %{INT:returnedCode}", "%{TIMESTAMP_ISO8601:timestamp}%{SPACE}%{LOGLEVEL:loglevel} %{NOTSPACE:webService} @ %{NOTSPACE:function}, System:(?<systemName>.), User:%{NOTSPACE:userId}, StudentIDs:\[%{NUMBER:studentId}\], GroupID:%{GREEDYDATA:groupId}, DocType:%{NOTSPACE:docType}, returned %{INT:returnedCode}", "%{TIMESTAMP_ISO8601:timestamp}%{SPACE}%{LOGLEVEL:loglevel} %{NOTSPACE:webService} @ batchAddOrUpdateStdMetadata, returned %{INT:returnedCode}", "%{TIMESTAMP_ISO8601:timestamp}%{SPACE}%{LOGLEVEL:loglevel} %{NOTSPACE:webService} @ getInternalID, System:(?<systemName>.), resultCode:%{INT:resultCode}, returned %{INT:returnedCode}"]}
}
if "_grokparsefailure" in [tags] {
drop { }
}
if [queueType]{
mutate {
add_tag => ["taskTerminated"]
add_field => {
"timestamp" => "%{part1} %{part2}"
}
remove_field => ["part1", "part2", "nothing", "nothing2"]
}
}
else{
mutate{
gsub => ["timestamp", "\,\d{3}$", ""]
add_tag => ["taskStarted"]
}
}
date {
match => ["timestamp", "MMM dd HH:mm:ss YYYY", "MMM d HH:mm:ss YYYY", "YYYY-MM-dd HH:mm:ss"]
timezone => "Asia/Tehran"
target => "@timestamp"
}
mutate {
add_field => {"[hour]" => "%{+HH}"}
}
mutate {
convert => {
"hour" => "integer"
}
}
elapsed {
start_tag => "taskStarted"
end_tag => "taskTerminated"
unique_id_field => "returnedCode"
timeout => 10000
new_event_on_match => false
}
}
output {
elasticsearch {
hosts => ["http://localhost:9200"]
index => "%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"
#user => "elastic"
#password => "changeme"
}
}
thanks for your help.