Hi Hendrik,
Sorry for not being clear in my Initial request, assume the metricbeat
index has the following documents:
{"_source": {"@timestamp":"2020-03-02T04:05:10.000Z", "host":{"hostname":"metricbeat-1"}, mem_percent:"70" }}
{"_source": {"@timestamp":"2020-03-02T04:10:10.000Z", "host":{"hostname":"metricbeat-1"}, mem_percent:"90" }}
{"_source": {"@timestamp":"2020-03-02T04:15:10.000Z", "host":{"hostname":"metricbeat-1"}, mem_percent:"80" }}
{"_source": {"@timestamp":"2020-03-02T04:25:10.000Z", "host":{"hostname":"metricbeat-1"}, mem_percent:"50" }}
{"_source": {"@timestamp":"2020-03-02T04:05:20.000Z", "host":{"hostname":"metricbeat-2"}, mem_percent:"60" }}
{"_source": {"@timestamp":"2020-03-02T04:10:20.000Z", "host":{"hostname":"metricbeat-2"}, mem_percent:"70" }}
{"_source": {"@timestamp":"2020-03-02T04:20:20.000Z", "host":{"hostname":"metricbeat-2"}, mem_percent:"80" }}
{"_source": {"@timestamp":"2020-03-02T04:25:20.000Z", "host":{"hostname":"metricbeat-2"}, mem_percent:"90" }}
{"_source": {"@timestamp":"2020-03-02T04:05:30.000Z", "host":{"hostname":"metricbeat-3"}, mem_percent:"40" }}
{"_source": {"@timestamp":"2020-03-02T04:20:30.000Z", "host":{"hostname":"metricbeat-3"}, mem_percent:"80" }}
{"_source": {"@timestamp":"2020-03-02T04:25:30.000Z", "host":{"hostname":"metricbeat-3"}, mem_percent:"70" }}
{"_source": {"@timestamp":"2020-03-02T04:30:30.000Z", "host":{"hostname":"metricbeat-3"}, mem_percent:"90" }}
What I am trying to achieve is a Kibana Data Table
that tells me that tells me:
# Systems with high ram:
- metricbeat-2
- metricbeat-3
Because the latest doc foe each hostname has mem_percent
> 80
I tried using a scripted metric based on what you had shared but I can't seem to filter by hostname
.
The best I am able to get is the latest global value, in this case my table would only have metricbeat-3
as the doc for metricbeat-2
is older than it.
I can get what I want using this search query
GET metricbeat/_search
{
"aggs": {
"instances": {
"terms": {
"field": "hostname",
"size": 1000,
"order": {
"_key": "desc"
}
},
"aggs": {
"latest_mem": {
"top_hits": {
"_source": [
"mem_percent",
],
"size": 1,
"sort": [
{
"@timestamp": {
"order": "desc"
}
}
]
}
}
}
}
},
"size": 0
}
However I do not know how to use it in kibana to create a Data Table
visualization.
I mention transforms specifically because I am using them to get the latest timestamp
from each hostname
and save those in a dedicated index which only has the latest values.
I use that index to build a similar Data Table
for when the last @timestamp
is > 10 min away from now
, but I am open to other ways of doing this.
Any suggestions on how to make the scripted query return a document per hostname
would be appreciated too.
Thanks for your help.
Reshad