Filter on string field in last N documents then get min value

Hi All,
I have index docs in format:

{
myCategory: "A"
myValue"10"
}
{
myCategory: "B"
myValue"20"
}
{
myCategory: "A"
myValue"14"
}
...

Was looking for a way to do the following metric visualization --> get the minimum myValue from the latest 3 documents which has myCategory value as "A". And if that minimum value is >10 display metric in red font.

Any suggestions.
Thanks

@rcodestuff,

You can create the metric visualization with a filter which queries for the most recent entries:

{
  "query": {
    "match": {
      "myCategory.keyword": "A"
    }
  },
  "sort": [
    {
      "@timestamp": {
        "order": "desc"
      }
    }
  ],
  "size": 3
}

Once the filter is in place, then you can specify that you want the "Min" metric for "myValue":

Finally, in the options tab, you can specify a color range, so that the value turns red when < 10:

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