Last active
October 3, 2018 04:44
-
-
Save remasis/08130ead4b65fdeac59f2af5927b8474 to your computer and use it in GitHub Desktop.
Example Gravwell anko script for calculating the time difference between entries in nanoseconds.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example Gravwell anko script for calculating the time difference between entries in nanoseconds. | |
# Example usage to view the ms between entries might look like this: | |
# tag=syslog sort by time asc | anko timeDiff | eval setEnum("ms", toFloat(timeDiff)/1000000.0) | table ms | |
# Note: `sort by time` is required to ensure proper ordering. Gravwell is time-indexed but for sub-granular differences | |
# in time, order is not guaranteed. This is what enables distributed pipeline execution. | |
# Note: This script is uploaded as a resource called "timeDiff" in the above query example | |
# Further docs about Gravwell scripting can be found at https://dev.gravwell.io/docs/#!search/anko/anko.md | |
var lastTime = 0 | |
func Process() { | |
ns=1000000000*TIMESTAMP.Sec+TIMESTAMP.Nsec | |
if lastTime == 0 { | |
lastTime = ns | |
return false | |
} | |
diff = ns-lastTime | |
lastTime = ns | |
setEnum("timeDiff", diff) | |
return true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment