I have an index of SendGrid event data:
"_source": {
"externalId": "9283cc1d-b003-xxxx-a5af-84fcf31c4181",
"email": "[email protected]",
"timestamp": 1616515214,
"event": "processed",
"uid": null,
"id": null,
"sendgridEventId": null,
"smtpId": null,
"sgMessageId": null,
"sgEventId": null,
"sendgridEvent": null,
"type": null,
"category": [],
"reason": null,
"status": null,
"url": null,
"useragent": null,
"ip": null,
"response": null,
"tls": null,
"attempt": null,
"sendAt": null,
"asmGroupId": null
}
Now I like to aggregate all of these events for a given day using the timestamp
attribute.
GET /sendgridevententity/_search
{
"query":
{
"match_all": {}
},
"aggs": {
"amount_per_day": {
"date_histogram": {
"field": "timestamp",
"calendar_interval": "1d"
}
}
}
}
Unfortunately, this just yields all the single events as they all have a different timestamp and the aggregation does not group them by day.
How can I convert the timestamps to date
and then run the aggregation?