Making a graph, based on the last entry of each group

Dear,

Each line in my database is giving me information about a tunnel, one of the column is calling tunnel_status and has values "up" and "down" another column has the name "tunnel number" with values "tunnel 1",... "tunnel 8". What I want to do now is to create a graph which gives me the latest value of each tunnel. Preferable is an histogram.

Kind regards,
Amon

Hey @Amon, if you'd like to see the latest tunnel_status for each of the trains, we can't create a Histogram of this because tunnel_status is a string. We can however use the data table visualization to get you this information.

Using Dev Tools, we can create some sample data to play around with:

POST amon/_doc
{
  "@timestamp": "2020-02-01T00:00:00.000Z",
  "tunnel_status": "up",
  "tunnel_number": "tunnel 1"
}

POST amon/_doc
{
  "@timestamp": "2020-02-02T00:00:00.000Z",
  "tunnel_status": "down",
  "tunnel_number": "tunnel 1"
}

POST amon/_doc
{
  "@timestamp": "2020-02-01T00:00:00.000Z",
  "tunnel_status": "down",
  "tunnel_number": "tunnel 2"
}

POST amon/_doc
{
  "@timestamp": "2020-02-02T00:00:00.000Z",
  "tunnel_status": "up",
  "tunnel_number": "tunnel 2"
}

POST amon/_doc
{
  "@timestamp": "2020-02-01T00:00:00.000Z",
  "tunnel_status": "up",
  "tunnel_number": "tunnel 3"
}

POST amon/_doc
{
  "@timestamp": "2020-02-02T00:00:00.000Z",
  "tunnel_status": "down",
  "tunnel_number": "tunnel 3"
}

POST amon/_doc
{
  "@timestamp": "2020-02-01T00:00:00.000Z",
  "tunnel_status": "down",
  "tunnel_number": "tunnel 4"
}

POST amon/_doc
{
  "@timestamp": "2020-02-02T00:00:00.000Z",
  "tunnel_status": "up",
  "tunnel_number": "tunnel 4"
}

POST amon/_doc
{
  "@timestamp": "2020-02-01T00:00:00.000Z",
  "tunnel_status": "up",
  "tunnel_number": "tunnel 5"
}

POST amon/_doc
{
  "@timestamp": "2020-02-02T00:00:00.000Z",
  "tunnel_status": "down",
  "tunnel_number": "tunnel 5"
}

POST amon/_doc
{
  "@timestamp": "2020-02-01T00:00:00.000Z",
  "tunnel_status": "down",
  "tunnel_number": "tunnel 6"
}

POST amon/_doc
{
  "@timestamp": "2020-02-02T00:00:00.000Z",
  "tunnel_status": "up",
  "tunnel_number": "tunnel 6"
}

POST amon/_doc
{
  "@timestamp": "2020-02-01T00:00:00.000Z",
  "tunnel_status": "up",
  "tunnel_number": "tunnel 7"
}

POST amon/_doc
{
  "@timestamp": "2020-02-02T00:00:00.000Z",
  "tunnel_status": "down",
  "tunnel_number": "tunnel 7"
}

POST amon/_doc
{
  "@timestamp": "2020-02-01T00:00:00.000Z",
  "tunnel_status": "down",
  "tunnel_number": "tunnel 8"
}

POST amon/_doc
{
  "@timestamp": "2020-02-02T00:00:00.000Z",
  "tunnel_status": "up",
  "tunnel_number": "tunnel 8"
}

Using the following Data Table configuration, we are able to get the information you're looking for:

2 Likes

Dear Brandon,

Thank you very much for your quick response. This is exactly where I was looking for!

Have a great day!

Kind regards,
Amon

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.