Logstash-尝试创建经过的过滤器

时间:2018-07-20 11:20:41

标签: elasticsearch filter logstash elapsed

我正在尝试创建一个经过的过滤器,但是未显示经过的字段。 这是输入:

statement => "SELECT TRANSACTION_ID, COMMUNICATION_ID, 
    BROKER_NAME, IS_NAME, SERVICE_NAME, OPERATION_NAME, OPERATION_VERSION, MESSAGE_TYPE, APPROACH, CLIENT_ID, 
    APPLICATION_ID, EXT_SESSION_ID, EXT_TRANSACTION_ID, EXT_ORIGIN, LANG_CODE, EXT_HOST, APPLICATION, CHANNEL, 
    NUM_RETRIES, STATUS_CODE, STATUS_MSG, DATE_CREATED, 
    DESTINATION_HOST, OPERATION_ID 
    FROM IIB_OPER.COMMUNICATION_LOG 
    WHERE DATE_CREATED > '2018-07-20'"

这是过滤器:

filter {
    if [message_type] == "Req" {
        mutate {
            add_tag => [ "taskStarted" ]
        }
    }
    if [message_type] == "Res" {
        mutate {
            add_tag => [ "taskTerminated" ]
        }
    }   
    elapsed {
        unique_id_field => "operation_id"
        start_tag => "taskStarted"
        end_tag => "taskTerminated"
        timeout => 20000
        new_event_on_match => true
    }
}

在Kibana中,索引模式中会显示字段,但是当我让logstash工作时,不会显示经过的字段。

知道为什么吗?

干杯

1 个答案:

答案 0 :(得分:0)

回答我自己的问题... 问题是我正在尝试将JSON中已经存在的列转换为导入到Elastic,因此使它成为另一个临时日期即可。

date {
    match => [ "temp_date", "yyyy-MM-dd HH:mm:ss,SSS"]
}
if [message_type] == "Req" {
    mutate {
        add_tag => [ "taskStarted" ]
    }
}
if [message_type] == "Res" {
    mutate {
        add_tag => [ "taskTerminated" ]
    }
}   
elapsed {
    unique_id_field => "operation_id"
    start_tag => "taskStarted"
    end_tag => "taskTerminated"
    timeout => 30
}

另一点...非常重要...超时以秒为单位,没有以毫秒为单位。

干杯