How to calculate the timestamp difference between two actions?

I recommend restructuring the data sent to Elasticsearch so that each document looks something like this:

{
  "session_id": 123456,
  "login_time": "May 20th 2018, 15:41:32.111",
  "logout_time": "May 21th 2018, 10:39:01.761",
}

Then, you can add a Scripted field in Kibana to calculate the difference between login_time and logout_time.

You can read more about modeling data for Elasticsearch here.

4 Likes