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

LibreNMS/Alert/Transport/Elasticsearch - Send timestamp with timezone #9757

Merged
merged 2 commits into from Feb 13, 2019

Conversation

Projects
None yet
3 participants
@pobradovic08
Copy link
Contributor

commented Jan 29, 2019

Add timezone to timestamp field, otherwise ES will think it's UTC

DO NOT DELETE THIS TEXT

Please note

Please read this information carefully. You can run ./scripts/pre-commit.php to check your code before submitting.

Testers

If you would like to test this pull request then please run: ./scripts/github-apply <pr_id>, i.e ./scripts/github-apply 5926
After you are done testing, you can remove the changes with ./scripts/github-remove. If there are schema changes, you can ask on discord how to revert.

Send timestamp with timezone
Add timezone to timestamp field, otherwise ES will think it's UTC
@CLAassistant

This comment has been minimized.

Copy link

commented Jan 29, 2019

CLA assistant check
All committers have signed the CLA.

@pobradovic08 pobradovic08 changed the title Send timestamp with timezone LibreNMS/Alert/Transport/Elasticsearch - Send timestamp with timezone Jan 29, 2019

@murrant

This comment has been minimized.

Copy link
Member

commented Jan 31, 2019

Can we just send a unix_timestamp?
Aka: '@timestamp' => date(),

@pobradovic08

This comment has been minimized.

Copy link
Contributor Author

commented Jan 31, 2019

We could do:
'@timestamp' => time()*1000,

Apparently it's expecting microseconds since epoch and both time() and microtime(true) are iterpreted as Jan 18th 1970 by ES

@pobradovic08 pobradovic08 force-pushed the pobradovic08:patch-1 branch from 08411e8 to a39b614 Feb 1, 2019

@pobradovic08

This comment has been minimized.

Copy link
Contributor Author

commented Feb 1, 2019

Unfortunately if we send just a timestamp then elastics sets the type of the field to number by default (instead of date). This can be fixed by creating a template on ES side but I think it's easier for everyone to send a timestamp as a string that will automatically be recognized as a date by ES.

@murrant

This comment has been minimized.

Copy link
Member

commented Feb 7, 2019

@pobradovic08 Perhaps instead of sending a timezone (which can bring daylight savings headaches) Just send the UTC time. \Carbon\Carbon:now('UTC')->toISOString()

@murrant

This comment has been minimized.

Copy link
Member

commented Feb 13, 2019

Updated to use ISO 8601 format

@murrant murrant merged commit 67d81e6 into librenms:master Feb 13, 2019

6 checks passed

Inspection Summary
Details
Node: analysis
Details
Travis CI - Pull Request Build Passed
Details
WIP Ready for review
Details
codeclimate All good!
Details
license/cla Contributor License Agreement is signed.
Details

funzoneq added a commit to funzoneq/librenms that referenced this pull request Apr 30, 2019

LibreNMS/Alert/Transport/Elasticsearch - Send timestamp with timezone (
…librenms#9757)

* Send timestamp with timezone

Add timezone to timestamp field, otherwise ES will think it's UTC

* Update Elasticsearch.php

@lock lock bot locked as resolved and limited conversation to collaborators May 3, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.