Skip to content

Instantly share code, notes, and snippets.

@aaiezza
Last active November 8, 2022 21:54
Show Gist options
  • Save aaiezza/1771f73e511b7b6ad949dabcd9ba5917 to your computer and use it in GitHub Desktop.
Save aaiezza/1771f73e511b7b6ad949dabcd9ba5917 to your computer and use it in GitHub Desktop.
Loggly Event Delta Calculation

How to use this

Pre-requisites

  • Install R
  • run install.packages('parsedate') in your r shell

Use the script

  1. Get your Loggly results for some event and export the results as a csv.
  2. Run the r script with the file as input and out will pop the average time taken between the events occurring and their standard deviations.
timestampDiffs <- function(filename) {
data <- read.csv(filename)
event_times <- data[,1]
library(parsedate)
event_times_parsed <- parse_iso_8601(substr(event_times, 0, 23))
event_sec_diffs <- diff(rev(event_times_parsed), 1)
event_sec_diffs
}
# Example
event_sec_diffs <- timestampDiffs('loggly_grid_2022-11-08 17_26_48.902484.csv')
mean(event_sec_diffs)
# Time difference of 142.9542 secs
sd(event_sec_diffs)
# 190.6124
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment