I want to convert the following sql into Elasticsearch dsl query:
SELECT count(winlog.event_id) AS 'Event_Count' FROM winlogbeat-7.1.1-2019.09.09 WHERE ['winlog.event_id']='7040' AND ['winlog.provider_name']='Service Control Manager' group by host.name, winlog.provider_name
I tried above sql in Kibana and it is working and giving the right output and i want to get the same output using Elasticsearch dsl as it has more options.
It returned two hosts computer1 , computer2 and all the rest is under a specific host.
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 21,
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
},
"aggregations" : {
"host.name" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "computer1",
"doc_count" : 19,
"winlog.provider_name" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "Service Control Manager",
"doc_count" : 19,
"'Event_Count'" : {
"value" : 19
}
}
]
}
},
{
"key" : "computer2",
"doc_count" : 2,
"winlog.provider_name" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "Service Control Manager",
"doc_count" : 2,
"'Event_Count'" : {
"value" : 2
}
}
]
}
}
]
}
}
}