Greetings!
I'm trying to look at changes to the "host" field produced by metricbeat. I'd like to run a process every day to see if this "host" field for some specific system changed. A typical metricbeat record that contains the desired host field looks something like this:
{
"_index": "metricbeat-7.3.1-2019.09.10-000001",
"_type": "_doc",
...
},
...
},
"host": {
"name": "(servername)",
"containerized": false,
"hostname": "(hostname)",
"architecture": "x86_64",
"os": {
"kernel": "3.10.0-954.10.1.dl7.x86_64",
"codename": "Core",
"platform": "centos",
"version": "7 (Core)",
"family": "redhat",
"name": "CentOS Linux"
},
"id": "211d31bcdb1fdfdereffer5664fsdfhjjs"
},
...
}
}
So far I have tried to:
-
Grab all of the records for a day and compare these host fields as dictionaries. The problem with doing this is that metricbeat generates several thousand records that each have to be searched. It's really inefficient to do that when we have very large indexes and the code depends on processing data that's temporally ordered. See: Get oldest / newest document in *beat
-
I tried to write an aggregation to grab the entire host object then bin the data into "servername" bins. I couldn't get this to work either. See: https://stackoverflow.com/questions/59461511/aggregation-of-host-json-object-out-of-metricbeat-on-elasticsearch
-
I've installed Elastalert and have been trying to get it to alert on host changes. It hasn't worked so far. The examples provided with the Elastalert package work for really simple stuff but that's all I can get it to do.
When I run the query, I'd like to see something like this as output:
"stat_date": 2020-01-16 09:58,
"host_configurations":
{
server_id: "server1",
"host": {
"os.name": "Linux xxx",
"kernel.version": u893,
....
},
{
server_id: "server1",
"host": {
"os.name": "Linux xxx",
"kernel.version": u895,
....
},
...
This would tell me that sometime that day the kernel.version changed from u893 to u895. Or I could see if someone added RAM or more disk space. That's it. From there the rest of the code is easy. I don't care what time it happened or how many times. I just need to know that sometime that day there was a host configuration change.
This seems like it should be a 'relatively' simple thing to do but I can't get anything to work. I'd appreciate any suggestions anyone has. Thank you!