Hello.
Sorry for my strange English.
I'm trying to use pipeline aggregations (still deep in the manual) with a goal to get a line chart with a complex calculation for each day on the calendar.
In common, I'm looking a way to get (L)DAU / (L)WAU / (L)MAU charts (examples, SQL-syntax example with Google BigQuery). And then more complex charts (like ARPU, which need to divide one line daily measures to the another line measures) that used the data from WAU etc.
I wrote a query that can show the data for Daily Active Users (DAU) chart:
DAU chart data query
GET sessions-*/_search
{
"size": 0,
"aggs": {
"dau": {
"filter": {
"bool": {
"must": [
{...},
{
"range": {
"@timestamp": {
"lte": "now",
"gte": "now-30d/d"
}
}
}
]
}
},
"aggs": {
"interval_aggregation": {
"date_histogram": {
"field": "@timestamp",
"interval": "1d"
},
"aggs": {
"distinct_visitors": {
"cardinality": {
"field": "user_id"
}
}
}
}
}
}
}
}
DAU query response
"aggregations": {
"wau": {
"doc_count": 1991,
"interval_aggregation": {
"buckets": [
{
...
"distinct_visitors": {
"value": 90
}
},
{
...
"distinct_visitors": {
"value": 103
}
},
]
}
}
}
But for Weekly Active Users (WAU) this query is not enough. I can set interval as "7d" and it will return a good value, but I need to see this measure for every calendar day.
So, for today I can get one WAU value with this request:
WAU query just for today (on day start)
GET sessions-*/_search
{
"size": 0,
"aggs": {
"wau": {
"filter": {
"bool": {
"must": [
{...},
{
"range": {
"@timestamp": {
"lte": "now/d",
"gte": "now-7d/d"
}
}
}
]
}
},
"aggs": {
"distinct_visitors": {
"cardinality": {
"field": "user_id"
}
}
}
}
}
}
WAU one day query response
"aggregations": {
"wau": {
"doc_count": 3492,
"distinct_visitors": {
"value": 18
}
}
}
How I can get the WAU value for each calendar day?