I'm a newbie to Vega. Appreciate it if you can help me to build a visualizer on the aggregated results that I have as follows.
For every release
, I'd like to show the sum of duration per workflow
(e.g., A, B, and C) based on the latest id
.
Sample dataset:
release,id,workflow,sid,duration
1.0,1,A,x1,1
1.0,1,A,x2,6
1.0,2,A,x1,2
1.0,2,A,x2,3
1.0,1,B,y1,1
1.0,1,B,y2,2
1.0,2,B,y1,8
1.0,2,B,y2,3
1.0,3,B,y1,4
1.0,3,B,y2,2
1.1,1,A,x1,1
1.1,1,A,x2,6
1.1,2,A,x1,2
1.1,2,A,x2,4
1.2,1,C,y1,3
1.2,1,C,y2,2
1.2,2,C,y1,8
1.2,2,C,y2,3
1.2,4,C,y1,9
1.2,4,C,y2,7
Query:
GET discuss-duration/_search
{
"size": 0,
"aggs": {
"workflow": {
"terms": {
"field": "workflow"
},
"aggs": {
"ids": {
"terms": {
"field": "id",
"order": { "max_id": "desc" },
"size": 1
},
"aggs": {
"max_id": {
"max": {
"field": "id"
}
},
"sum_duration": {
"sum": {
"field": "duration"
}
}
}
}
}
}
}
}
Results:
# Results
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 10,
"relation": "eq"
},
"max_score": null,
"hits": []
},
"aggregations": {
"workflow": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "B",
"doc_count": 6,
"ids": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 4,
"buckets": [
{
"key": 3,
"doc_count": 2,
"sum_duration": {
"value": 6
},
"max_id": {
"value": 3
}
}
]
}
},
{
"key": "A",
"doc_count": 4,
"ids": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 2,
"buckets": [
{
"key": 2,
"doc_count": 2,
"sum_duration": {
"value": 5
},
"max_id": {
"value": 2
}
}
]
}
}
]
}
}
}