{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"title": "StreamGraph: Traffic Flow by Method",
"view": {
"continuousWidth": 1000,
"continuousHeight": 450
},
"data": {
"url": {
"%context%": true,
"%timefield%": "@timestamp",
"index": "logs-*",
"body": {
"size": 0,
"aggs": {
"time": {
"date_histogram": {
"field": "@timestamp",
"fixed_interval": "1m",
"min_doc_count": 0
},
"aggs": {
"methods": {
"terms": {
"field": "method",
"size": 20
}
}
}
}
}
}
},
"format": { "property": "aggregations.time.buckets" }
},
"transform": [
{ "flatten": ["methods.buckets"] },
{ "calculate": "datum['methods.buckets'].key", "as": "method" },
{ "calculate": "datum['methods.buckets'].doc_count", "as": "count" },
{ "calculate": "toDate(datum.key_as_string)", "as": "timestamp" },
{ "filter": "isValid(datum.method) && isValid(datum.count)" }
],
"mark": {
"type": "area",
"interpolate": "monotone"
},
"encoding": {
"x": {
"field": "timestamp",
"type": "temporal",
"title": "Time"
},
"y": {
"field": "count",
"type": "quantitative",
"stack": "center",
"title": "Traffic volume"
},
"color": {
"field": "method",
"type": "nominal",
"title": "Method",
"scale": { "scheme": "category20" }
},
"tooltip": [
{ "field": "timestamp", "title": "Time" },
{ "field": "method", "title": "Method" },
{ "field": "count", "title": "Count" }
]
}
}