Elasticsearch: Adds cumulative sum aggregation support (#24820)

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
This commit is contained in:
Kevin Retzke 2020-06-01 17:55:15 -04:00 committed by GitHub
parent b2745c3e23
commit 51d1261a4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 2142 additions and 159 deletions

View File

@ -28,7 +28,7 @@
"editable": true, "editable": true,
"gnetId": null, "gnetId": null,
"graphTooltip": 0, "graphTooltip": 0,
"iteration": 1554310942895, "iteration": 1591027568655,
"links": [ "links": [
{ {
"asDropdown": true, "asDropdown": true,
@ -47,7 +47,14 @@
"datasource": "gdev-elasticsearch-v2-metrics", "datasource": "gdev-elasticsearch-v2-metrics",
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1, "fill": 1,
"fillGradient": 0,
"grid": {}, "grid": {},
"gridPos": { "gridPos": {
"h": 7, "h": 7,
@ -55,6 +62,7 @@
"x": 0, "x": 0,
"y": 0 "y": 0
}, },
"hiddenSeries": false,
"id": 1, "id": 1,
"legend": { "legend": {
"alignAsTable": true, "alignAsTable": true,
@ -71,6 +79,9 @@
"linewidth": 2, "linewidth": 2,
"links": [], "links": [],
"nullPointMode": "connected", "nullPointMode": "connected",
"options": {
"dataLinks": []
},
"percentage": false, "percentage": false,
"pointradius": 5, "pointradius": 5,
"points": false, "points": false,
@ -170,7 +181,14 @@
"datasource": "gdev-elasticsearch-v2-metrics", "datasource": "gdev-elasticsearch-v2-metrics",
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1, "fill": 1,
"fillGradient": 0,
"grid": {}, "grid": {},
"gridPos": { "gridPos": {
"h": 6, "h": 6,
@ -178,6 +196,7 @@
"x": 0, "x": 0,
"y": 7 "y": 7
}, },
"hiddenSeries": false,
"id": 2, "id": 2,
"legend": { "legend": {
"alignAsTable": true, "alignAsTable": true,
@ -194,6 +213,9 @@
"linewidth": 2, "linewidth": 2,
"links": [], "links": [],
"nullPointMode": "connected", "nullPointMode": "connected",
"options": {
"dataLinks": []
},
"percentage": false, "percentage": false,
"pointradius": 5, "pointradius": 5,
"points": false, "points": false,
@ -292,7 +314,14 @@
"datasource": "gdev-elasticsearch-v2-metrics", "datasource": "gdev-elasticsearch-v2-metrics",
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1, "fill": 1,
"fillGradient": 0,
"grid": {}, "grid": {},
"gridPos": { "gridPos": {
"h": 6, "h": 6,
@ -300,6 +329,7 @@
"x": 12, "x": 12,
"y": 7 "y": 7
}, },
"hiddenSeries": false,
"id": 3, "id": 3,
"legend": { "legend": {
"alignAsTable": true, "alignAsTable": true,
@ -316,6 +346,9 @@
"linewidth": 2, "linewidth": 2,
"links": [], "links": [],
"nullPointMode": "connected", "nullPointMode": "connected",
"options": {
"dataLinks": []
},
"percentage": false, "percentage": false,
"pointradius": 5, "pointradius": 5,
"points": false, "points": false,
@ -427,6 +460,12 @@
"datasource": "gdev-elasticsearch-v2-metrics", "datasource": "gdev-elasticsearch-v2-metrics",
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fontSize": "100%", "fontSize": "100%",
"gridPos": { "gridPos": {
"h": 7, "h": 7,
@ -445,11 +484,13 @@
}, },
"styles": [ "styles": [
{ {
"align": "auto",
"dateFormat": "YYYY-MM-DD HH:mm:ss", "dateFormat": "YYYY-MM-DD HH:mm:ss",
"pattern": "@timestamp", "pattern": "@timestamp",
"type": "date" "type": "date"
}, },
{ {
"align": "auto",
"colorMode": null, "colorMode": null,
"colors": ["rgba(245, 54, 54, 0.9)", "rgba(237, 129, 40, 0.89)", "rgba(50, 172, 45, 0.97)"], "colors": ["rgba(245, 54, 54, 0.9)", "rgba(237, 129, 40, 0.89)", "rgba(50, 172, 45, 0.97)"],
"dateFormat": "YYYY-MM-DD HH:mm:ss", "dateFormat": "YYYY-MM-DD HH:mm:ss",
@ -505,7 +546,7 @@
], ],
"title": "ES Metrics", "title": "ES Metrics",
"transform": "table", "transform": "table",
"type": "table" "type": "table-old"
}, },
{ {
"columns": [ "columns": [
@ -529,6 +570,12 @@
"datasource": "gdev-elasticsearch-v2-logs", "datasource": "gdev-elasticsearch-v2-logs",
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fontSize": "100%", "fontSize": "100%",
"gridPos": { "gridPos": {
"h": 7, "h": 7,
@ -547,6 +594,7 @@
}, },
"styles": [ "styles": [
{ {
"align": "auto",
"dateFormat": "YYYY-MM-DD HH:mm:ss", "dateFormat": "YYYY-MM-DD HH:mm:ss",
"pattern": "@timestamp", "pattern": "@timestamp",
"type": "date" "type": "date"
@ -574,7 +622,7 @@
], ],
"title": "ES Log query", "title": "ES Log query",
"transform": "json", "transform": "json",
"type": "table" "type": "table-old"
}, },
{ {
"circleMaxSize": 30, "circleMaxSize": 30,
@ -584,6 +632,12 @@
"decimals": 0, "decimals": 0,
"esGeoPoint": "@location", "esGeoPoint": "@location",
"esMetric": "Average", "esMetric": "Average",
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"gridPos": { "gridPos": {
"h": 12, "h": 12,
"w": 24, "w": 24,
@ -645,7 +699,7 @@
"valueName": "total" "valueName": "total"
} }
], ],
"schemaVersion": 18, "schemaVersion": 25,
"style": "dark", "style": "dark",
"tags": ["elasticsearch", "gdev", "datasource-test"], "tags": ["elasticsearch", "gdev", "datasource-test"],
"templating": { "templating": {
@ -678,5 +732,5 @@
"timezone": "browser", "timezone": "browser",
"title": "Datasource tests - Elasticsearch v2", "title": "Datasource tests - Elasticsearch v2",
"uid": "RlqLq2fiz", "uid": "RlqLq2fiz",
"version": 5 "version": 1
} }

View File

@ -28,7 +28,7 @@
"editable": true, "editable": true,
"gnetId": null, "gnetId": null,
"graphTooltip": 0, "graphTooltip": 0,
"iteration": 1554310560048, "iteration": 1591027589702,
"links": [ "links": [
{ {
"asDropdown": true, "asDropdown": true,
@ -47,7 +47,14 @@
"datasource": "gdev-elasticsearch-v5-metrics", "datasource": "gdev-elasticsearch-v5-metrics",
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1, "fill": 1,
"fillGradient": 0,
"grid": {}, "grid": {},
"gridPos": { "gridPos": {
"h": 7, "h": 7,
@ -55,6 +62,7 @@
"x": 0, "x": 0,
"y": 0 "y": 0
}, },
"hiddenSeries": false,
"id": 1, "id": 1,
"legend": { "legend": {
"alignAsTable": true, "alignAsTable": true,
@ -71,6 +79,9 @@
"linewidth": 2, "linewidth": 2,
"links": [], "links": [],
"nullPointMode": "connected", "nullPointMode": "connected",
"options": {
"dataLinks": []
},
"percentage": false, "percentage": false,
"pointradius": 5, "pointradius": 5,
"points": false, "points": false,
@ -170,7 +181,14 @@
"datasource": "gdev-elasticsearch-v5-metrics", "datasource": "gdev-elasticsearch-v5-metrics",
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1, "fill": 1,
"fillGradient": 0,
"grid": {}, "grid": {},
"gridPos": { "gridPos": {
"h": 6, "h": 6,
@ -178,6 +196,7 @@
"x": 0, "x": 0,
"y": 7 "y": 7
}, },
"hiddenSeries": false,
"id": 2, "id": 2,
"legend": { "legend": {
"alignAsTable": true, "alignAsTable": true,
@ -194,6 +213,9 @@
"linewidth": 2, "linewidth": 2,
"links": [], "links": [],
"nullPointMode": "connected", "nullPointMode": "connected",
"options": {
"dataLinks": []
},
"percentage": false, "percentage": false,
"pointradius": 5, "pointradius": 5,
"points": false, "points": false,
@ -292,7 +314,14 @@
"datasource": "gdev-elasticsearch-v5-metrics", "datasource": "gdev-elasticsearch-v5-metrics",
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1, "fill": 1,
"fillGradient": 0,
"grid": {}, "grid": {},
"gridPos": { "gridPos": {
"h": 6, "h": 6,
@ -300,6 +329,7 @@
"x": 12, "x": 12,
"y": 7 "y": 7
}, },
"hiddenSeries": false,
"id": 3, "id": 3,
"legend": { "legend": {
"alignAsTable": true, "alignAsTable": true,
@ -316,6 +346,9 @@
"linewidth": 2, "linewidth": 2,
"links": [], "links": [],
"nullPointMode": "connected", "nullPointMode": "connected",
"options": {
"dataLinks": []
},
"percentage": false, "percentage": false,
"pointradius": 5, "pointradius": 5,
"points": false, "points": false,
@ -427,6 +460,12 @@
"datasource": "gdev-elasticsearch-v5-metrics", "datasource": "gdev-elasticsearch-v5-metrics",
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fontSize": "100%", "fontSize": "100%",
"gridPos": { "gridPos": {
"h": 7, "h": 7,
@ -445,11 +484,13 @@
}, },
"styles": [ "styles": [
{ {
"align": "auto",
"dateFormat": "YYYY-MM-DD HH:mm:ss", "dateFormat": "YYYY-MM-DD HH:mm:ss",
"pattern": "@timestamp", "pattern": "@timestamp",
"type": "date" "type": "date"
}, },
{ {
"align": "auto",
"colorMode": null, "colorMode": null,
"colors": ["rgba(245, 54, 54, 0.9)", "rgba(237, 129, 40, 0.89)", "rgba(50, 172, 45, 0.97)"], "colors": ["rgba(245, 54, 54, 0.9)", "rgba(237, 129, 40, 0.89)", "rgba(50, 172, 45, 0.97)"],
"dateFormat": "YYYY-MM-DD HH:mm:ss", "dateFormat": "YYYY-MM-DD HH:mm:ss",
@ -505,7 +546,7 @@
], ],
"title": "ES Metrics", "title": "ES Metrics",
"transform": "table", "transform": "table",
"type": "table" "type": "table-old"
}, },
{ {
"columns": [ "columns": [
@ -529,6 +570,12 @@
"datasource": "gdev-elasticsearch-v5-logs", "datasource": "gdev-elasticsearch-v5-logs",
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fontSize": "100%", "fontSize": "100%",
"gridPos": { "gridPos": {
"h": 7, "h": 7,
@ -547,6 +594,7 @@
}, },
"styles": [ "styles": [
{ {
"align": "auto",
"dateFormat": "YYYY-MM-DD HH:mm:ss", "dateFormat": "YYYY-MM-DD HH:mm:ss",
"pattern": "@timestamp", "pattern": "@timestamp",
"type": "date" "type": "date"
@ -574,7 +622,7 @@
], ],
"title": "ES Log query", "title": "ES Log query",
"transform": "json", "transform": "json",
"type": "table" "type": "table-old"
}, },
{ {
"circleMaxSize": 30, "circleMaxSize": 30,
@ -585,6 +633,12 @@
"esGeoPoint": "@location", "esGeoPoint": "@location",
"esLocationName": "", "esLocationName": "",
"esMetric": "Average", "esMetric": "Average",
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"gridPos": { "gridPos": {
"h": 12, "h": 12,
"w": 24, "w": 24,
@ -646,7 +700,7 @@
"valueName": "total" "valueName": "total"
} }
], ],
"schemaVersion": 18, "schemaVersion": 25,
"style": "dark", "style": "dark",
"tags": ["elasticsearch", "gdev", "datasource-test"], "tags": ["elasticsearch", "gdev", "datasource-test"],
"templating": { "templating": {
@ -679,5 +733,5 @@
"timezone": "browser", "timezone": "browser",
"title": "Datasource tests - Elasticsearch v5", "title": "Datasource tests - Elasticsearch v5",
"uid": "8HjT32Bmz", "uid": "8HjT32Bmz",
"version": 5 "version": 1
} }

View File

@ -28,7 +28,7 @@
"editable": true, "editable": true,
"gnetId": null, "gnetId": null,
"graphTooltip": 0, "graphTooltip": 0,
"iteration": 1554310839317, "iteration": 1591027529668,
"links": [ "links": [
{ {
"asDropdown": true, "asDropdown": true,
@ -47,7 +47,14 @@
"datasource": "gdev-elasticsearch-v6-metrics", "datasource": "gdev-elasticsearch-v6-metrics",
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1, "fill": 1,
"fillGradient": 0,
"grid": {}, "grid": {},
"gridPos": { "gridPos": {
"h": 7, "h": 7,
@ -55,6 +62,7 @@
"x": 0, "x": 0,
"y": 0 "y": 0
}, },
"hiddenSeries": false,
"id": 1, "id": 1,
"legend": { "legend": {
"alignAsTable": true, "alignAsTable": true,
@ -71,6 +79,9 @@
"linewidth": 2, "linewidth": 2,
"links": [], "links": [],
"nullPointMode": "connected", "nullPointMode": "connected",
"options": {
"dataLinks": []
},
"percentage": false, "percentage": false,
"pointradius": 5, "pointradius": 5,
"points": false, "points": false,
@ -170,7 +181,14 @@
"datasource": "gdev-elasticsearch-v6-metrics", "datasource": "gdev-elasticsearch-v6-metrics",
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1, "fill": 1,
"fillGradient": 0,
"grid": {}, "grid": {},
"gridPos": { "gridPos": {
"h": 6, "h": 6,
@ -178,6 +196,7 @@
"x": 0, "x": 0,
"y": 7 "y": 7
}, },
"hiddenSeries": false,
"id": 2, "id": 2,
"legend": { "legend": {
"alignAsTable": true, "alignAsTable": true,
@ -194,6 +213,9 @@
"linewidth": 2, "linewidth": 2,
"links": [], "links": [],
"nullPointMode": "connected", "nullPointMode": "connected",
"options": {
"dataLinks": []
},
"percentage": false, "percentage": false,
"pointradius": 5, "pointradius": 5,
"points": false, "points": false,
@ -292,7 +314,14 @@
"datasource": "gdev-elasticsearch-v6-metrics", "datasource": "gdev-elasticsearch-v6-metrics",
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1, "fill": 1,
"fillGradient": 0,
"grid": {}, "grid": {},
"gridPos": { "gridPos": {
"h": 6, "h": 6,
@ -300,6 +329,7 @@
"x": 12, "x": 12,
"y": 7 "y": 7
}, },
"hiddenSeries": false,
"id": 3, "id": 3,
"legend": { "legend": {
"alignAsTable": true, "alignAsTable": true,
@ -316,6 +346,9 @@
"linewidth": 2, "linewidth": 2,
"links": [], "links": [],
"nullPointMode": "connected", "nullPointMode": "connected",
"options": {
"dataLinks": []
},
"percentage": false, "percentage": false,
"pointradius": 5, "pointradius": 5,
"points": false, "points": false,
@ -427,6 +460,12 @@
"datasource": "gdev-elasticsearch-v6-metrics", "datasource": "gdev-elasticsearch-v6-metrics",
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fontSize": "100%", "fontSize": "100%",
"gridPos": { "gridPos": {
"h": 7, "h": 7,
@ -445,11 +484,13 @@
}, },
"styles": [ "styles": [
{ {
"align": "auto",
"dateFormat": "YYYY-MM-DD HH:mm:ss", "dateFormat": "YYYY-MM-DD HH:mm:ss",
"pattern": "@timestamp", "pattern": "@timestamp",
"type": "date" "type": "date"
}, },
{ {
"align": "auto",
"colorMode": null, "colorMode": null,
"colors": ["rgba(245, 54, 54, 0.9)", "rgba(237, 129, 40, 0.89)", "rgba(50, 172, 45, 0.97)"], "colors": ["rgba(245, 54, 54, 0.9)", "rgba(237, 129, 40, 0.89)", "rgba(50, 172, 45, 0.97)"],
"dateFormat": "YYYY-MM-DD HH:mm:ss", "dateFormat": "YYYY-MM-DD HH:mm:ss",
@ -505,7 +546,7 @@
], ],
"title": "ES Metrics", "title": "ES Metrics",
"transform": "table", "transform": "table",
"type": "table" "type": "table-old"
}, },
{ {
"columns": [ "columns": [
@ -529,6 +570,12 @@
"datasource": "gdev-elasticsearch-v6-logs", "datasource": "gdev-elasticsearch-v6-logs",
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fontSize": "100%", "fontSize": "100%",
"gridPos": { "gridPos": {
"h": 7, "h": 7,
@ -547,6 +594,7 @@
}, },
"styles": [ "styles": [
{ {
"align": "auto",
"dateFormat": "YYYY-MM-DD HH:mm:ss", "dateFormat": "YYYY-MM-DD HH:mm:ss",
"pattern": "@timestamp", "pattern": "@timestamp",
"type": "date" "type": "date"
@ -574,7 +622,7 @@
], ],
"title": "ES Log query", "title": "ES Log query",
"transform": "json", "transform": "json",
"type": "table" "type": "table-old"
}, },
{ {
"circleMaxSize": 30, "circleMaxSize": 30,
@ -584,6 +632,12 @@
"decimals": 0, "decimals": 0,
"esGeoPoint": "@location", "esGeoPoint": "@location",
"esMetric": "Average", "esMetric": "Average",
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"gridPos": { "gridPos": {
"h": 12, "h": 12,
"w": 24, "w": 24,
@ -645,7 +699,8 @@
"valueName": "total" "valueName": "total"
} }
], ],
"schemaVersion": 18, "refresh": false,
"schemaVersion": 25,
"style": "dark", "style": "dark",
"tags": ["elasticsearch", "gdev", "datasource-test"], "tags": ["elasticsearch", "gdev", "datasource-test"],
"templating": { "templating": {
@ -662,7 +717,7 @@
] ]
}, },
"time": { "time": {
"from": "now-30m", "from": "now-1h",
"to": "now" "to": "now"
}, },
"timepicker": { "timepicker": {
@ -678,5 +733,5 @@
"timezone": "browser", "timezone": "browser",
"title": "Datasource tests - Elasticsearch v6", "title": "Datasource tests - Elasticsearch v6",
"uid": "NF8Pq2Biz", "uid": "NF8Pq2Biz",
"version": 5 "version": 1
} }

View File

@ -15,7 +15,7 @@
"editable": true, "editable": true,
"gnetId": null, "gnetId": null,
"graphTooltip": 0, "graphTooltip": 0,
"iteration": 1554902936982, "iteration": 1591027621672,
"links": [ "links": [
{ {
"asDropdown": true, "asDropdown": true,
@ -34,13 +34,21 @@
"dashLength": 10, "dashLength": 10,
"dashes": false, "dashes": false,
"datasource": "gdev-elasticsearch-v6-filebeat", "datasource": "gdev-elasticsearch-v6-filebeat",
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1, "fill": 1,
"fillGradient": 0,
"gridPos": { "gridPos": {
"h": 5, "h": 5,
"w": 24, "w": 24,
"x": 0, "x": 0,
"y": 0 "y": 0
}, },
"hiddenSeries": false,
"id": 4, "id": 4,
"legend": { "legend": {
"avg": false, "avg": false,
@ -54,6 +62,9 @@
"lines": false, "lines": false,
"linewidth": 1, "linewidth": 1,
"nullPointMode": "null", "nullPointMode": "null",
"options": {
"dataLinks": []
},
"percentage": false, "percentage": false,
"pointradius": 2, "pointradius": 2,
"points": false, "points": false,
@ -142,22 +153,13 @@
} }
}, },
{ {
"columns": [
{
"text": "@timestamp",
"value": "@timestamp"
},
{
"text": "fields.level",
"value": "fields.level"
},
{
"text": "message",
"value": "message"
}
],
"datasource": "gdev-elasticsearch-v6-filebeat", "datasource": "gdev-elasticsearch-v6-filebeat",
"fontSize": "100%", "fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"gridPos": { "gridPos": {
"h": 22, "h": 22,
"w": 24, "w": 24,
@ -166,58 +168,35 @@
}, },
"id": 2, "id": 2,
"links": [], "links": [],
"pageSize": null, "options": {
"scroll": true, "showLabels": false,
"showHeader": true, "showTime": true,
"sort": { "sortOrder": "Descending",
"col": 0, "wrapLogMessage": true
"desc": true
}, },
"styles": [
{
"alias": "Time",
"dateFormat": "YYYY-MM-DD HH:mm:ss",
"pattern": "@timestamp",
"type": "date"
},
{
"alias": "Level",
"colorMode": null,
"colors": ["rgba(245, 54, 54, 0.9)", "rgba(237, 129, 40, 0.89)", "rgba(50, 172, 45, 0.97)"],
"dateFormat": "YYYY-MM-DD HH:mm:ss",
"decimals": 2,
"mappingType": 1,
"pattern": "fields.level",
"thresholds": [""],
"type": "string",
"unit": "short",
"valueMaps": []
},
{
"alias": "Message",
"colorMode": null,
"colors": ["rgba(245, 54, 54, 0.9)", "rgba(237, 129, 40, 0.89)", "rgba(50, 172, 45, 0.97)"],
"decimals": 2,
"pattern": "message",
"preserveFormat": false,
"sanitize": false,
"thresholds": [],
"type": "string",
"unit": "short"
}
],
"targets": [ "targets": [
{ {
"bucketAggs": [], "bucketAggs": [
{
"$$hashKey": "object:394",
"field": "@timestamp",
"id": "2",
"settings": {
"interval": "auto",
"min_doc_count": 0,
"trimEdges": 0
},
"type": "date_histogram"
}
],
"metrics": [ "metrics": [
{ {
"$$hashKey": "object:359",
"field": "select field", "field": "select field",
"id": "1", "id": "1",
"meta": {}, "meta": {},
"settings": { "settings": {},
"size": 500 "type": "logs"
},
"type": "raw_document"
} }
], ],
"query": "fields.app:grafana", "query": "fields.app:grafana",
@ -228,11 +207,10 @@
"timeFrom": null, "timeFrom": null,
"timeShift": null, "timeShift": null,
"title": "Panel Title", "title": "Panel Title",
"transform": "json", "type": "logs"
"type": "table"
} }
], ],
"schemaVersion": 18, "schemaVersion": 25,
"style": "dark", "style": "dark",
"tags": ["gdev", "elasticsearch", "datasource-test"], "tags": ["gdev", "elasticsearch", "datasource-test"],
"templating": { "templating": {
@ -249,7 +227,7 @@
] ]
}, },
"time": { "time": {
"from": "now-1h", "from": "now-30m",
"to": "now" "to": "now"
}, },
"timepicker": { "timepicker": {
@ -259,5 +237,5 @@
"timezone": "", "timezone": "",
"title": "Datasource tests - Elasticsearch v6 Filebeat", "title": "Datasource tests - Elasticsearch v6 Filebeat",
"uid": "06tPt4gZz", "uid": "06tPt4gZz",
"version": 8 "version": 1
} }

View File

@ -28,8 +28,7 @@
"editable": true, "editable": true,
"gnetId": null, "gnetId": null,
"graphTooltip": 0, "graphTooltip": 0,
"id": 2342, "iteration": 1591027717495,
"iteration": 1555593977614,
"links": [ "links": [
{ {
"asDropdown": true, "asDropdown": true,
@ -48,7 +47,14 @@
"datasource": "gdev-elasticsearch-v7-metrics", "datasource": "gdev-elasticsearch-v7-metrics",
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1, "fill": 1,
"fillGradient": 0,
"grid": {}, "grid": {},
"gridPos": { "gridPos": {
"h": 7, "h": 7,
@ -56,6 +62,7 @@
"x": 0, "x": 0,
"y": 0 "y": 0
}, },
"hiddenSeries": false,
"id": 1, "id": 1,
"legend": { "legend": {
"alignAsTable": true, "alignAsTable": true,
@ -72,6 +79,9 @@
"linewidth": 2, "linewidth": 2,
"links": [], "links": [],
"nullPointMode": "connected", "nullPointMode": "connected",
"options": {
"dataLinks": []
},
"percentage": false, "percentage": false,
"pointradius": 5, "pointradius": 5,
"points": false, "points": false,
@ -171,7 +181,14 @@
"datasource": "gdev-elasticsearch-v7-metrics", "datasource": "gdev-elasticsearch-v7-metrics",
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1, "fill": 1,
"fillGradient": 0,
"grid": {}, "grid": {},
"gridPos": { "gridPos": {
"h": 6, "h": 6,
@ -179,6 +196,7 @@
"x": 0, "x": 0,
"y": 7 "y": 7
}, },
"hiddenSeries": false,
"id": 2, "id": 2,
"legend": { "legend": {
"alignAsTable": true, "alignAsTable": true,
@ -195,6 +213,9 @@
"linewidth": 2, "linewidth": 2,
"links": [], "links": [],
"nullPointMode": "connected", "nullPointMode": "connected",
"options": {
"dataLinks": []
},
"percentage": false, "percentage": false,
"pointradius": 5, "pointradius": 5,
"points": false, "points": false,
@ -293,7 +314,14 @@
"datasource": "gdev-elasticsearch-v7-metrics", "datasource": "gdev-elasticsearch-v7-metrics",
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1, "fill": 1,
"fillGradient": 0,
"grid": {}, "grid": {},
"gridPos": { "gridPos": {
"h": 6, "h": 6,
@ -301,6 +329,7 @@
"x": 12, "x": 12,
"y": 7 "y": 7
}, },
"hiddenSeries": false,
"id": 3, "id": 3,
"legend": { "legend": {
"alignAsTable": true, "alignAsTable": true,
@ -317,6 +346,9 @@
"linewidth": 2, "linewidth": 2,
"links": [], "links": [],
"nullPointMode": "connected", "nullPointMode": "connected",
"options": {
"dataLinks": []
},
"percentage": false, "percentage": false,
"pointradius": 5, "pointradius": 5,
"points": false, "points": false,
@ -428,6 +460,12 @@
"datasource": "gdev-elasticsearch-v7-metrics", "datasource": "gdev-elasticsearch-v7-metrics",
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fontSize": "100%", "fontSize": "100%",
"gridPos": { "gridPos": {
"h": 7, "h": 7,
@ -446,11 +484,13 @@
}, },
"styles": [ "styles": [
{ {
"align": "auto",
"dateFormat": "YYYY-MM-DD HH:mm:ss", "dateFormat": "YYYY-MM-DD HH:mm:ss",
"pattern": "@timestamp", "pattern": "@timestamp",
"type": "date" "type": "date"
}, },
{ {
"align": "auto",
"colorMode": null, "colorMode": null,
"colors": ["rgba(245, 54, 54, 0.9)", "rgba(237, 129, 40, 0.89)", "rgba(50, 172, 45, 0.97)"], "colors": ["rgba(245, 54, 54, 0.9)", "rgba(237, 129, 40, 0.89)", "rgba(50, 172, 45, 0.97)"],
"dateFormat": "YYYY-MM-DD HH:mm:ss", "dateFormat": "YYYY-MM-DD HH:mm:ss",
@ -506,7 +546,7 @@
], ],
"title": "ES Metrics", "title": "ES Metrics",
"transform": "table", "transform": "table",
"type": "table" "type": "table-old"
}, },
{ {
"columns": [ "columns": [
@ -530,6 +570,12 @@
"datasource": "gdev-elasticsearch-v7-logs", "datasource": "gdev-elasticsearch-v7-logs",
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fontSize": "100%", "fontSize": "100%",
"gridPos": { "gridPos": {
"h": 7, "h": 7,
@ -548,6 +594,7 @@
}, },
"styles": [ "styles": [
{ {
"align": "auto",
"dateFormat": "YYYY-MM-DD HH:mm:ss", "dateFormat": "YYYY-MM-DD HH:mm:ss",
"pattern": "@timestamp", "pattern": "@timestamp",
"type": "date" "type": "date"
@ -575,7 +622,7 @@
], ],
"title": "ES Log query", "title": "ES Log query",
"transform": "json", "transform": "json",
"type": "table" "type": "table-old"
}, },
{ {
"circleMaxSize": 30, "circleMaxSize": 30,
@ -585,6 +632,12 @@
"decimals": 0, "decimals": 0,
"esGeoPoint": "@location", "esGeoPoint": "@location",
"esMetric": "Average", "esMetric": "Average",
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"gridPos": { "gridPos": {
"h": 12, "h": 12,
"w": 24, "w": 24,
@ -646,7 +699,7 @@
"valueName": "total" "valueName": "total"
} }
], ],
"schemaVersion": 18, "schemaVersion": 25,
"style": "dark", "style": "dark",
"tags": ["elasticsearch", "gdev", "datasource-test"], "tags": ["elasticsearch", "gdev", "datasource-test"],
"templating": { "templating": {

View File

@ -15,8 +15,7 @@
"editable": true, "editable": true,
"gnetId": null, "gnetId": null,
"graphTooltip": 0, "graphTooltip": 0,
"id": 2341, "iteration": 1591027736516,
"iteration": 1555591591930,
"links": [ "links": [
{ {
"asDropdown": true, "asDropdown": true,
@ -35,13 +34,21 @@
"dashLength": 10, "dashLength": 10,
"dashes": false, "dashes": false,
"datasource": "gdev-elasticsearch-v7-filebeat", "datasource": "gdev-elasticsearch-v7-filebeat",
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1, "fill": 1,
"fillGradient": 0,
"gridPos": { "gridPos": {
"h": 5, "h": 5,
"w": 24, "w": 24,
"x": 0, "x": 0,
"y": 0 "y": 0
}, },
"hiddenSeries": false,
"id": 4, "id": 4,
"legend": { "legend": {
"avg": false, "avg": false,
@ -55,6 +62,9 @@
"lines": false, "lines": false,
"linewidth": 1, "linewidth": 1,
"nullPointMode": "null", "nullPointMode": "null",
"options": {
"dataLinks": []
},
"percentage": false, "percentage": false,
"pointradius": 2, "pointradius": 2,
"points": false, "points": false,
@ -143,22 +153,13 @@
} }
}, },
{ {
"columns": [
{
"text": "@timestamp",
"value": "@timestamp"
},
{
"text": "fields.level",
"value": "fields.level"
},
{
"text": "message",
"value": "message"
}
],
"datasource": "gdev-elasticsearch-v7-filebeat", "datasource": "gdev-elasticsearch-v7-filebeat",
"fontSize": "100%", "fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"gridPos": { "gridPos": {
"h": 22, "h": 22,
"w": 24, "w": 24,
@ -167,58 +168,35 @@
}, },
"id": 2, "id": 2,
"links": [], "links": [],
"pageSize": null, "options": {
"scroll": true, "showLabels": false,
"showHeader": true, "showTime": true,
"sort": { "sortOrder": "Descending",
"col": 0, "wrapLogMessage": true
"desc": true
}, },
"styles": [
{
"alias": "Time",
"dateFormat": "YYYY-MM-DD HH:mm:ss",
"pattern": "@timestamp",
"type": "date"
},
{
"alias": "Level",
"colorMode": null,
"colors": ["rgba(245, 54, 54, 0.9)", "rgba(237, 129, 40, 0.89)", "rgba(50, 172, 45, 0.97)"],
"dateFormat": "YYYY-MM-DD HH:mm:ss",
"decimals": 2,
"mappingType": 1,
"pattern": "fields.level",
"thresholds": [""],
"type": "string",
"unit": "short",
"valueMaps": []
},
{
"alias": "Message",
"colorMode": null,
"colors": ["rgba(245, 54, 54, 0.9)", "rgba(237, 129, 40, 0.89)", "rgba(50, 172, 45, 0.97)"],
"decimals": 2,
"pattern": "message",
"preserveFormat": false,
"sanitize": false,
"thresholds": [],
"type": "string",
"unit": "short"
}
],
"targets": [ "targets": [
{ {
"bucketAggs": [], "bucketAggs": [
{
"$$hashKey": "object:522",
"field": "@timestamp",
"id": "2",
"settings": {
"interval": "auto",
"min_doc_count": 0,
"trimEdges": 0
},
"type": "date_histogram"
}
],
"metrics": [ "metrics": [
{ {
"$$hashKey": "object:484",
"field": "select field", "field": "select field",
"id": "1", "id": "1",
"meta": {}, "meta": {},
"settings": { "settings": {},
"size": 500 "type": "logs"
},
"type": "raw_document"
} }
], ],
"query": "fields.app:grafana", "query": "fields.app:grafana",
@ -229,11 +207,10 @@
"timeFrom": null, "timeFrom": null,
"timeShift": null, "timeShift": null,
"title": "Panel Title", "title": "Panel Title",
"transform": "json", "type": "logs"
"type": "table"
} }
], ],
"schemaVersion": 18, "schemaVersion": 25,
"style": "dark", "style": "dark",
"tags": ["elasticsearch", "gdev", "datasource-test"], "tags": ["elasticsearch", "gdev", "datasource-test"],
"templating": { "templating": {

View File

@ -45,6 +45,7 @@ var metricAggType = map[string]string{
"percentiles": "Percentiles", "percentiles": "Percentiles",
"cardinality": "Unique Count", "cardinality": "Unique Count",
"moving_avg": "Moving Average", "moving_avg": "Moving Average",
"cumulative_sum": "Cumulative Sum",
"derivative": "Derivative", "derivative": "Derivative",
"bucket_script": "Bucket Script", "bucket_script": "Bucket Script",
"raw_document": "Raw Document", "raw_document": "Raw Document",
@ -62,9 +63,10 @@ var extendedStats = map[string]string{
} }
var pipelineAggType = map[string]string{ var pipelineAggType = map[string]string{
"moving_avg": "moving_avg", "moving_avg": "moving_avg",
"derivative": "derivative", "cumulative_sum": "cumulative_sum",
"bucket_script": "bucket_script", "derivative": "derivative",
"bucket_script": "bucket_script",
} }
var pipelineAggWithMultipleBucketPathsType = map[string]string{ var pipelineAggWithMultipleBucketPathsType = map[string]string{

View File

@ -486,6 +486,112 @@ func TestExecuteTimeSeriesQuery(t *testing.T) {
So(plAgg.BucketPath, ShouldEqual, "3") So(plAgg.BucketPath, ShouldEqual, "3")
}) })
Convey("With cumulative sum", func() {
c := newFakeClient(5)
_, err := executeTsdbQuery(c, `{
"timeField": "@timestamp",
"bucketAggs": [
{ "type": "date_histogram", "field": "@timestamp", "id": "4" }
],
"metrics": [
{ "id": "3", "type": "sum", "field": "@value" },
{
"id": "2",
"type": "cumulative_sum",
"field": "3",
"pipelineAgg": "3"
}
]
}`, from, to, 15*time.Second)
So(err, ShouldBeNil)
sr := c.multisearchRequests[0].Requests[0]
firstLevel := sr.Aggs[0]
So(firstLevel.Key, ShouldEqual, "4")
So(firstLevel.Aggregation.Type, ShouldEqual, "date_histogram")
So(firstLevel.Aggregation.Aggs, ShouldHaveLength, 2)
sumAgg := firstLevel.Aggregation.Aggs[0]
So(sumAgg.Key, ShouldEqual, "3")
So(sumAgg.Aggregation.Type, ShouldEqual, "sum")
mAgg := sumAgg.Aggregation.Aggregation.(*es.MetricAggregation)
So(mAgg.Field, ShouldEqual, "@value")
cumulativeSumAgg := firstLevel.Aggregation.Aggs[1]
So(cumulativeSumAgg.Key, ShouldEqual, "2")
So(cumulativeSumAgg.Aggregation.Type, ShouldEqual, "cumulative_sum")
pl := cumulativeSumAgg.Aggregation.Aggregation.(*es.PipelineAggregation)
So(pl.BucketPath, ShouldEqual, "3")
})
Convey("With cumulative sum doc count", func() {
c := newFakeClient(5)
_, err := executeTsdbQuery(c, `{
"timeField": "@timestamp",
"bucketAggs": [
{ "type": "date_histogram", "field": "@timestamp", "id": "4" }
],
"metrics": [
{ "id": "3", "type": "count", "field": "select field" },
{
"id": "2",
"type": "cumulative_sum",
"field": "3",
"pipelineAgg": "3"
}
]
}`, from, to, 15*time.Second)
So(err, ShouldBeNil)
sr := c.multisearchRequests[0].Requests[0]
firstLevel := sr.Aggs[0]
So(firstLevel.Key, ShouldEqual, "4")
So(firstLevel.Aggregation.Type, ShouldEqual, "date_histogram")
So(firstLevel.Aggregation.Aggs, ShouldHaveLength, 1)
cumulativeSumAgg := firstLevel.Aggregation.Aggs[0]
So(cumulativeSumAgg.Key, ShouldEqual, "2")
So(cumulativeSumAgg.Aggregation.Type, ShouldEqual, "cumulative_sum")
pl := cumulativeSumAgg.Aggregation.Aggregation.(*es.PipelineAggregation)
So(pl.BucketPath, ShouldEqual, "_count")
})
Convey("With broken cumulative sum", func() {
c := newFakeClient(5)
_, err := executeTsdbQuery(c, `{
"timeField": "@timestamp",
"bucketAggs": [
{ "type": "date_histogram", "field": "@timestamp", "id": "5" }
],
"metrics": [
{ "id": "3", "type": "sum", "field": "@value" },
{
"id": "2",
"type": "cumulative_sum",
"pipelineAgg": "3"
},
{
"id": "4",
"type": "cumulative_sum",
"pipelineAgg": "Metric to apply cumulative sum"
}
]
}`, from, to, 15*time.Second)
So(err, ShouldBeNil)
sr := c.multisearchRequests[0].Requests[0]
firstLevel := sr.Aggs[0]
So(firstLevel.Key, ShouldEqual, "5")
So(firstLevel.Aggregation.Type, ShouldEqual, "date_histogram")
So(firstLevel.Aggregation.Aggs, ShouldHaveLength, 2)
cumulativeSumAgg := firstLevel.Aggregation.Aggs[1]
So(cumulativeSumAgg.Key, ShouldEqual, "2")
plAgg := cumulativeSumAgg.Aggregation.Aggregation.(*es.PipelineAggregation)
So(plAgg.BucketPath, ShouldEqual, "3")
})
Convey("With derivative", func() { Convey("With derivative", func() {
c := newFakeClient(5) c := newFakeClient(5)
_, err := executeTsdbQuery(c, `{ _, err := executeTsdbQuery(c, `{

View File

@ -64,6 +64,11 @@
<div class="gf-form offset-width-7" ng-if="agg.type === 'derivative'"> <div class="gf-form offset-width-7" ng-if="agg.type === 'derivative'">
<label class="gf-form-label width-10">Unit</label> <label class="gf-form-label width-10">Unit</label>
<input type="text" class="gf-form-input max-width-12" ng-model="agg.settings.unit" ng-blur="onChangeInternal()" spellcheck='false'> <input type="text" class="gf-form-input max-width-12" ng-model="agg.settings.unit" ng-blur="onChangeInternal()" spellcheck='false'>
</div>
<div class="gf-form offset-width-7" ng-if="agg.type === 'cumulative_sum'">
<label class="gf-form-label width-10">Format</label>
<input type="text" class="gf-form-input max-width-12" ng-model="agg.settings.format" ng-blur="onChangeInternal()" spellcheck='false'>
</div> </div>
<div ng-if="agg.type === 'moving_avg'"> <div ng-if="agg.type === 'moving_avg'">

View File

@ -64,6 +64,13 @@ export const metricAggTypes = [
isPipelineAgg: true, isPipelineAgg: true,
minVersion: 2, minVersion: 2,
}, },
{
text: 'Cumulative Sum',
value: 'cumulative_sum',
requiresField: false,
isPipelineAgg: true,
minVersion: 2,
},
{ {
text: 'Bucket Script', text: 'Bucket Script',
value: 'bucket_script', value: 'bucket_script',
@ -143,6 +150,7 @@ export const pipelineOptions: any = {
{ text: 'minimize', default: false }, { text: 'minimize', default: false },
], ],
derivative: [{ text: 'unit', default: undefined }], derivative: [{ text: 'unit', default: undefined }],
cumulative_sum: [{ text: 'format', default: undefined }],
bucket_script: [], bucket_script: [],
}; };

View File

@ -104,13 +104,13 @@ describe('ElasticQueryDef', () => {
describe('using esversion 2', () => { describe('using esversion 2', () => {
test('should get pipeline aggs', () => { test('should get pipeline aggs', () => {
expect(queryDef.getMetricAggTypes(2).length).toBe(13); expect(queryDef.getMetricAggTypes(2).length).toBe(14);
}); });
}); });
describe('using esversion 5', () => { describe('using esversion 5', () => {
test('should get pipeline aggs', () => { test('should get pipeline aggs', () => {
expect(queryDef.getMetricAggTypes(5).length).toBe(13); expect(queryDef.getMetricAggTypes(5).length).toBe(14);
}); });
}); });
}); });