I am trying to create a report of devices that have not sent logs in 24 hours. I have a query that gets the data I need, but I can't figure out how to turn this into a saved search or visualization in Kibana. Any suggestions?
GET filebeat-*/_search
{
"size": 0,
"query": {
"range": {
"@timestamp": {
"gte": "now-30d"
}
}
},
"aggs": {
"byDevice": {
"terms": {
"field": "agent.hostname",
"size": 10
},
"aggs": {
"maxTS": {
"max": {
"field": "@timestamp"
}
},
"maxMinDiff": {
"bucket_script": {
"buckets_path": {
"maxTS": "maxTS"
},
"script": "((new Date()).getTime() -params.maxTS)/1000"
}
},
"device_bucket_filter": {
"bucket_selector": {
"buckets_path": {
"maxMinDiff": "maxMinDiff"
},
"script": "params.maxMinDiff > (24*60*60)"
}
}
}
}
}
}