Graylog2 / graylog-plugin-pipeline-processor

[DEPRECATED] Graylog Pipeline Message Processor Plugins
https://www.graylog.org/
GNU General Public License v3.0
21 stars 15 forks source link

Implement non-equality comparison of DateTime values #86

Closed hc4 closed 8 years ago

hc4 commented 8 years ago

Problem description

I want to drop old messages in rule. So I need to compare timestamp of message with current time

Environment

edmundoa commented 8 years ago

Hi,

You can use the now() function to get the current time. Here is an example of how to use it: https://github.com/Graylog2/graylog-plugin-pipeline-processor/blob/68dabe5bd39697f94b9604e47de5b59170f1f308/src/test/resources/org/graylog/plugins/pipelineprocessor/functions/dates.txt

hc4 commented 8 years ago

And again I didn't find needed function :) Maybe create some reflection to search for available functions, likie it done for REST API?

hc4 commented 8 years ago

And still unable to compare dates, because timestamp field is Object image

edmundoa commented 8 years ago

I think you need to parse the date time in the timestamp field of your message, probably with something like:

let timestamp = parse_date($message.timestamp, "yyyy-MM-dd'T'HH:mm:ssZZ");

And then you could subtract the two months from the timestamp variable, which should be a DateTime instance at that point.

hc4 commented 8 years ago

but field timestamp already should be DateTime? It is strange to convert it to string and then parse again...

hc4 commented 8 years ago

plus/minus-methods not avaialble for DateTime: image

edmundoa commented 8 years ago

I'm not sure if we are implicitly converting all message timestamps into DateTime objects, to be honest. It is also not possible to call DateTime's methods, only access its properties. I would say we are still missing some math functions for dates.

kroepke commented 8 years ago

This seems to be a bug. Special handling for DateTime is implemented in == and != but not in the other comparison operators.

After that fix it should work as expected.

kroepke commented 8 years ago

Tentative for 1.1.0, not sure if we can get to it.