Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement non-equality comparison of DateTime values #86

Closed
hc4 opened this issue Aug 15, 2016 · 9 comments
Closed

Implement non-equality comparison of DateTime values #86

hc4 opened this issue Aug 15, 2016 · 9 comments
Labels
Milestone

Comments

@hc4
Copy link

@hc4 hc4 commented Aug 15, 2016

Problem description

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

Environment

  • Graylog Version: 2.1.0-beta3
  • Pipeline Processor plugin version: 1.1.0-beta3
@edmundoa
Copy link
Member

@edmundoa edmundoa commented Aug 16, 2016

Loading

@hc4
Copy link
Author

@hc4 hc4 commented Aug 16, 2016

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

Loading

@hc4
Copy link
Author

@hc4 hc4 commented Aug 16, 2016

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

Loading

@edmundoa
Copy link
Member

@edmundoa edmundoa commented Aug 16, 2016

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.

Loading

@hc4
Copy link
Author

@hc4 hc4 commented Aug 16, 2016

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

Loading

@hc4
Copy link
Author

@hc4 hc4 commented Aug 16, 2016

plus/minus-methods not avaialble for DateTime:
image

Loading

@edmundoa
Copy link
Member

@edmundoa edmundoa commented Aug 16, 2016

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.

Loading

@kroepke
Copy link
Member

@kroepke kroepke commented Aug 18, 2016

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.

Loading

@kroepke kroepke changed the title Add possiblity to get current time and compare it to other datetime value Implement non-equality comparison of DateTime values Aug 18, 2016
@kroepke kroepke added the bug label Aug 18, 2016
@kroepke kroepke added this to the 1.1.0 milestone Aug 18, 2016
@kroepke
Copy link
Member

@kroepke kroepke commented Aug 18, 2016

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

Loading

edmundoa added a commit that referenced this issue Aug 18, 2016
Add support for comparison operators on DateTime objects.

Fixes #86
@kroepke kroepke closed this in #92 Aug 18, 2016
kroepke added a commit that referenced this issue Aug 18, 2016
Add support for comparison operators on DateTime objects.

Fixes #86
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants