mirror of https://github.com/grafana/grafana
Transformers: Support inner vs outer join (#53913)
parent
1766ea9fdf
commit
1d4e01f8ba
@ -0,0 +1,638 @@ |
||||
{ |
||||
"annotations": { |
||||
"list": [ |
||||
{ |
||||
"builtIn": 1, |
||||
"datasource": { |
||||
"type": "grafana", |
||||
"uid": "-- Grafana --" |
||||
}, |
||||
"enable": true, |
||||
"hide": true, |
||||
"iconColor": "rgba(0, 211, 255, 1)", |
||||
"name": "Annotations & Alerts", |
||||
"target": { |
||||
"limit": 100, |
||||
"matchAny": false, |
||||
"tags": [], |
||||
"type": "dashboard" |
||||
}, |
||||
"type": "dashboard" |
||||
} |
||||
] |
||||
}, |
||||
"editable": true, |
||||
"fiscalYearStartMonth": 0, |
||||
"graphTooltip": 0, |
||||
"id": 1351, |
||||
"links": [], |
||||
"liveNow": false, |
||||
"panels": [ |
||||
{ |
||||
"collapsed": false, |
||||
"gridPos": { |
||||
"h": 1, |
||||
"w": 24, |
||||
"x": 0, |
||||
"y": 0 |
||||
}, |
||||
"id": 9, |
||||
"panels": [], |
||||
"title": "Join by time", |
||||
"type": "row" |
||||
}, |
||||
{ |
||||
"datasource": { |
||||
"type": "testdata", |
||||
"uid": "PD8C576611E62080A" |
||||
}, |
||||
"fieldConfig": { |
||||
"defaults": { |
||||
"color": { |
||||
"mode": "palette-classic" |
||||
}, |
||||
"custom": { |
||||
"axisCenteredZero": false, |
||||
"axisColorMode": "text", |
||||
"axisLabel": "", |
||||
"axisPlacement": "auto", |
||||
"barAlignment": 0, |
||||
"drawStyle": "line", |
||||
"fillOpacity": 0, |
||||
"gradientMode": "none", |
||||
"hideFrom": { |
||||
"legend": false, |
||||
"tooltip": false, |
||||
"viz": false |
||||
}, |
||||
"lineInterpolation": "linear", |
||||
"lineWidth": 1, |
||||
"pointSize": 5, |
||||
"scaleDistribution": { |
||||
"type": "linear" |
||||
}, |
||||
"showPoints": "auto", |
||||
"spanNulls": false, |
||||
"stacking": { |
||||
"group": "A", |
||||
"mode": "none" |
||||
}, |
||||
"thresholdsStyle": { |
||||
"mode": "off" |
||||
} |
||||
}, |
||||
"mappings": [], |
||||
"thresholds": { |
||||
"mode": "absolute", |
||||
"steps": [ |
||||
{ |
||||
"color": "green", |
||||
"value": null |
||||
}, |
||||
{ |
||||
"color": "red", |
||||
"value": 80 |
||||
} |
||||
] |
||||
} |
||||
}, |
||||
"overrides": [] |
||||
}, |
||||
"gridPos": { |
||||
"h": 8, |
||||
"w": 12, |
||||
"x": 0, |
||||
"y": 1 |
||||
}, |
||||
"id": 11, |
||||
"options": { |
||||
"legend": { |
||||
"calcs": [], |
||||
"displayMode": "list", |
||||
"placement": "bottom", |
||||
"showLegend": true |
||||
}, |
||||
"tooltip": { |
||||
"mode": "single", |
||||
"sort": "none" |
||||
} |
||||
}, |
||||
"targets": [ |
||||
{ |
||||
"datasource": { |
||||
"type": "testdata", |
||||
"uid": "PD8C576611E62080A" |
||||
}, |
||||
"refId": "A", |
||||
"scenarioId": "random_walk", |
||||
"seriesCount": 4 |
||||
} |
||||
], |
||||
"title": "Timeseries data", |
||||
"type": "timeseries" |
||||
}, |
||||
{ |
||||
"datasource": { |
||||
"type": "datasource", |
||||
"uid": "-- Dashboard --" |
||||
}, |
||||
"fieldConfig": { |
||||
"defaults": { |
||||
"color": { |
||||
"mode": "thresholds" |
||||
}, |
||||
"custom": { |
||||
"align": "auto", |
||||
"displayMode": "auto", |
||||
"inspect": false |
||||
}, |
||||
"mappings": [], |
||||
"thresholds": { |
||||
"mode": "absolute", |
||||
"steps": [ |
||||
{ |
||||
"color": "green", |
||||
"value": null |
||||
}, |
||||
{ |
||||
"color": "red", |
||||
"value": 80 |
||||
} |
||||
] |
||||
} |
||||
}, |
||||
"overrides": [] |
||||
}, |
||||
"gridPos": { |
||||
"h": 8, |
||||
"w": 12, |
||||
"x": 12, |
||||
"y": 1 |
||||
}, |
||||
"id": 13, |
||||
"options": { |
||||
"footer": { |
||||
"fields": "", |
||||
"reducer": [ |
||||
"sum" |
||||
], |
||||
"show": false |
||||
}, |
||||
"showHeader": true |
||||
}, |
||||
"pluginVersion": "9.2.0-pre", |
||||
"targets": [ |
||||
{ |
||||
"datasource": { |
||||
"type": "datasource", |
||||
"uid": "-- Dashboard --" |
||||
}, |
||||
"panelId": 11, |
||||
"refId": "A" |
||||
} |
||||
], |
||||
"title": "Same data (as a table)", |
||||
"type": "table" |
||||
}, |
||||
{ |
||||
"datasource": { |
||||
"type": "datasource", |
||||
"uid": "-- Dashboard --" |
||||
}, |
||||
"fieldConfig": { |
||||
"defaults": { |
||||
"color": { |
||||
"mode": "thresholds" |
||||
}, |
||||
"custom": { |
||||
"align": "auto", |
||||
"displayMode": "auto", |
||||
"inspect": false |
||||
}, |
||||
"mappings": [], |
||||
"thresholds": { |
||||
"mode": "absolute", |
||||
"steps": [ |
||||
{ |
||||
"color": "green", |
||||
"value": null |
||||
}, |
||||
{ |
||||
"color": "red", |
||||
"value": 80 |
||||
} |
||||
] |
||||
} |
||||
}, |
||||
"overrides": [] |
||||
}, |
||||
"gridPos": { |
||||
"h": 5, |
||||
"w": 24, |
||||
"x": 0, |
||||
"y": 9 |
||||
}, |
||||
"id": 16, |
||||
"options": { |
||||
"footer": { |
||||
"fields": "", |
||||
"reducer": [ |
||||
"sum" |
||||
], |
||||
"show": false |
||||
}, |
||||
"showHeader": true |
||||
}, |
||||
"pluginVersion": "9.2.0-pre", |
||||
"targets": [ |
||||
{ |
||||
"datasource": { |
||||
"type": "datasource", |
||||
"uid": "-- Dashboard --" |
||||
}, |
||||
"panelId": 11, |
||||
"refId": "A" |
||||
} |
||||
], |
||||
"title": "OUTER join on time (default)", |
||||
"transformations": [ |
||||
{ |
||||
"id": "joinByField", |
||||
"options": {} |
||||
} |
||||
], |
||||
"type": "table" |
||||
}, |
||||
{ |
||||
"collapsed": false, |
||||
"gridPos": { |
||||
"h": 1, |
||||
"w": 24, |
||||
"x": 0, |
||||
"y": 14 |
||||
}, |
||||
"id": 5, |
||||
"panels": [], |
||||
"title": "Join by string field", |
||||
"type": "row" |
||||
}, |
||||
{ |
||||
"datasource": { |
||||
"type": "testdata", |
||||
"uid": "PD8C576611E62080A" |
||||
}, |
||||
"fieldConfig": { |
||||
"defaults": { |
||||
"color": { |
||||
"mode": "thresholds" |
||||
}, |
||||
"custom": { |
||||
"align": "auto", |
||||
"displayMode": "auto", |
||||
"inspect": false |
||||
}, |
||||
"mappings": [], |
||||
"thresholds": { |
||||
"mode": "absolute", |
||||
"steps": [ |
||||
{ |
||||
"color": "green", |
||||
"value": null |
||||
}, |
||||
{ |
||||
"color": "red", |
||||
"value": 80 |
||||
} |
||||
] |
||||
} |
||||
}, |
||||
"overrides": [] |
||||
}, |
||||
"gridPos": { |
||||
"h": 8, |
||||
"w": 12, |
||||
"x": 0, |
||||
"y": 15 |
||||
}, |
||||
"id": 2, |
||||
"options": { |
||||
"footer": { |
||||
"fields": "", |
||||
"reducer": [ |
||||
"sum" |
||||
], |
||||
"show": false |
||||
}, |
||||
"frameIndex": 0, |
||||
"showHeader": true |
||||
}, |
||||
"pluginVersion": "9.2.0-pre", |
||||
"targets": [ |
||||
{ |
||||
"csvContent": "OrderID,CustomerID,Time\n100,A,10000\n101,B,20000\n102,C,30000", |
||||
"datasource": { |
||||
"type": "testdata", |
||||
"uid": "PD8C576611E62080A" |
||||
}, |
||||
"refId": "Orders", |
||||
"scenarioId": "csv_content" |
||||
}, |
||||
{ |
||||
"csvContent": "CustomerID,Name,Country\nA,Customer A,USA\nB,Customer B,Germany\nC,Customer C,Spain\nD,Customer D,Canada", |
||||
"datasource": { |
||||
"type": "testdata", |
||||
"uid": "PD8C576611E62080A" |
||||
}, |
||||
"hide": false, |
||||
"refId": "Customers", |
||||
"scenarioId": "csv_content" |
||||
} |
||||
], |
||||
"title": "Orders", |
||||
"transformations": [], |
||||
"type": "table" |
||||
}, |
||||
{ |
||||
"datasource": { |
||||
"type": "datasource", |
||||
"uid": "-- Dashboard --" |
||||
}, |
||||
"fieldConfig": { |
||||
"defaults": { |
||||
"color": { |
||||
"mode": "thresholds" |
||||
}, |
||||
"custom": { |
||||
"align": "auto", |
||||
"displayMode": "auto", |
||||
"inspect": false |
||||
}, |
||||
"mappings": [], |
||||
"thresholds": { |
||||
"mode": "absolute", |
||||
"steps": [ |
||||
{ |
||||
"color": "green", |
||||
"value": null |
||||
}, |
||||
{ |
||||
"color": "red", |
||||
"value": 80 |
||||
} |
||||
] |
||||
} |
||||
}, |
||||
"overrides": [] |
||||
}, |
||||
"gridPos": { |
||||
"h": 8, |
||||
"w": 12, |
||||
"x": 12, |
||||
"y": 15 |
||||
}, |
||||
"id": 3, |
||||
"options": { |
||||
"footer": { |
||||
"fields": "", |
||||
"reducer": [ |
||||
"sum" |
||||
], |
||||
"show": false |
||||
}, |
||||
"frameIndex": 1, |
||||
"showHeader": true |
||||
}, |
||||
"pluginVersion": "9.2.0-pre", |
||||
"targets": [ |
||||
{ |
||||
"datasource": { |
||||
"type": "datasource", |
||||
"uid": "-- Dashboard --" |
||||
}, |
||||
"panelId": 2, |
||||
"refId": "A" |
||||
} |
||||
], |
||||
"title": "Customers", |
||||
"transformations": [], |
||||
"type": "table" |
||||
}, |
||||
{ |
||||
"datasource": { |
||||
"type": "datasource", |
||||
"uid": "-- Dashboard --" |
||||
}, |
||||
"fieldConfig": { |
||||
"defaults": { |
||||
"color": { |
||||
"mode": "thresholds" |
||||
}, |
||||
"custom": { |
||||
"align": "auto", |
||||
"displayMode": "auto", |
||||
"inspect": false |
||||
}, |
||||
"mappings": [], |
||||
"thresholds": { |
||||
"mode": "absolute", |
||||
"steps": [ |
||||
{ |
||||
"color": "green", |
||||
"value": null |
||||
}, |
||||
{ |
||||
"color": "red", |
||||
"value": 80 |
||||
} |
||||
] |
||||
} |
||||
}, |
||||
"overrides": [ |
||||
{ |
||||
"matcher": { |
||||
"id": "byName", |
||||
"options": "CustomerID" |
||||
}, |
||||
"properties": [ |
||||
{ |
||||
"id": "custom.width", |
||||
"value": 101 |
||||
} |
||||
] |
||||
}, |
||||
{ |
||||
"matcher": { |
||||
"id": "byName", |
||||
"options": "OrderID" |
||||
}, |
||||
"properties": [ |
||||
{ |
||||
"id": "custom.width", |
||||
"value": 89 |
||||
} |
||||
] |
||||
} |
||||
] |
||||
}, |
||||
"gridPos": { |
||||
"h": 8, |
||||
"w": 12, |
||||
"x": 0, |
||||
"y": 23 |
||||
}, |
||||
"id": 6, |
||||
"options": { |
||||
"footer": { |
||||
"fields": "", |
||||
"reducer": [ |
||||
"sum" |
||||
], |
||||
"show": false |
||||
}, |
||||
"frameIndex": 0, |
||||
"showHeader": true, |
||||
"sortBy": [] |
||||
}, |
||||
"pluginVersion": "9.2.0-pre", |
||||
"targets": [ |
||||
{ |
||||
"datasource": { |
||||
"type": "datasource", |
||||
"uid": "-- Dashboard --" |
||||
}, |
||||
"panelId": 2, |
||||
"refId": "A" |
||||
} |
||||
], |
||||
"title": "OUTER join on CustomerID (keeps missing values)", |
||||
"transformations": [ |
||||
{ |
||||
"id": "joinByField", |
||||
"options": { |
||||
"byField": "CustomerID", |
||||
"mode": "outer" |
||||
} |
||||
} |
||||
], |
||||
"type": "table" |
||||
}, |
||||
{ |
||||
"datasource": { |
||||
"type": "datasource", |
||||
"uid": "-- Dashboard --" |
||||
}, |
||||
"fieldConfig": { |
||||
"defaults": { |
||||
"color": { |
||||
"mode": "thresholds" |
||||
}, |
||||
"custom": { |
||||
"align": "auto", |
||||
"displayMode": "auto", |
||||
"inspect": false |
||||
}, |
||||
"mappings": [], |
||||
"thresholds": { |
||||
"mode": "absolute", |
||||
"steps": [ |
||||
{ |
||||
"color": "green", |
||||
"value": null |
||||
}, |
||||
{ |
||||
"color": "red", |
||||
"value": 80 |
||||
} |
||||
] |
||||
} |
||||
}, |
||||
"overrides": [ |
||||
{ |
||||
"matcher": { |
||||
"id": "byName", |
||||
"options": "CustomerID" |
||||
}, |
||||
"properties": [ |
||||
{ |
||||
"id": "custom.width", |
||||
"value": 101 |
||||
} |
||||
] |
||||
}, |
||||
{ |
||||
"matcher": { |
||||
"id": "byName", |
||||
"options": "OrderID" |
||||
}, |
||||
"properties": [ |
||||
{ |
||||
"id": "custom.width", |
||||
"value": 89 |
||||
} |
||||
] |
||||
} |
||||
] |
||||
}, |
||||
"gridPos": { |
||||
"h": 8, |
||||
"w": 12, |
||||
"x": 12, |
||||
"y": 23 |
||||
}, |
||||
"id": 7, |
||||
"options": { |
||||
"footer": { |
||||
"fields": "", |
||||
"reducer": [ |
||||
"sum" |
||||
], |
||||
"show": false |
||||
}, |
||||
"frameIndex": 0, |
||||
"showHeader": true, |
||||
"sortBy": [] |
||||
}, |
||||
"pluginVersion": "9.2.0-pre", |
||||
"targets": [ |
||||
{ |
||||
"datasource": { |
||||
"type": "datasource", |
||||
"uid": "-- Dashboard --" |
||||
}, |
||||
"panelId": 2, |
||||
"refId": "A" |
||||
} |
||||
], |
||||
"title": "INNER join on CustomerID ", |
||||
"transformations": [ |
||||
{ |
||||
"id": "joinByField", |
||||
"options": { |
||||
"byField": "CustomerID", |
||||
"mode": "inner" |
||||
} |
||||
} |
||||
], |
||||
"type": "table" |
||||
} |
||||
], |
||||
"schemaVersion": 37, |
||||
"style": "dark", |
||||
"tags": [ |
||||
"gdev", |
||||
"transform" |
||||
], |
||||
"templating": { |
||||
"list": [] |
||||
}, |
||||
"time": { |
||||
"from": "now-6h", |
||||
"to": "now" |
||||
}, |
||||
"timepicker": {}, |
||||
"timezone": "", |
||||
"title": "Join by field", |
||||
"uid": "gw0K4rmVz", |
||||
"version": 6, |
||||
"weekStart": "" |
||||
} |
@ -0,0 +1,358 @@ |
||||
{ |
||||
"annotations": { |
||||
"list": [ |
||||
{ |
||||
"builtIn": 1, |
||||
"datasource": { |
||||
"type": "grafana", |
||||
"uid": "-- Grafana --" |
||||
}, |
||||
"enable": true, |
||||
"hide": true, |
||||
"iconColor": "rgba(0, 211, 255, 1)", |
||||
"name": "Annotations & Alerts", |
||||
"target": { |
||||
"limit": 100, |
||||
"matchAny": false, |
||||
"tags": [], |
||||
"type": "dashboard" |
||||
}, |
||||
"type": "dashboard" |
||||
} |
||||
] |
||||
}, |
||||
"editable": true, |
||||
"fiscalYearStartMonth": 0, |
||||
"graphTooltip": 0, |
||||
"id": 1342, |
||||
"links": [], |
||||
"liveNow": false, |
||||
"panels": [ |
||||
{ |
||||
"datasource": { |
||||
"type": "testdata", |
||||
"uid": "PD8C576611E62080A" |
||||
}, |
||||
"fieldConfig": { |
||||
"defaults": { |
||||
"color": { |
||||
"mode": "thresholds" |
||||
}, |
||||
"mappings": [], |
||||
"thresholds": { |
||||
"mode": "absolute", |
||||
"steps": [ |
||||
{ |
||||
"color": "green", |
||||
"value": null |
||||
}, |
||||
{ |
||||
"color": "red", |
||||
"value": 80 |
||||
} |
||||
] |
||||
} |
||||
}, |
||||
"overrides": [] |
||||
}, |
||||
"gridPos": { |
||||
"h": 10, |
||||
"w": 12, |
||||
"x": 0, |
||||
"y": 0 |
||||
}, |
||||
"id": 2, |
||||
"maxDataPoints": 1, |
||||
"options": { |
||||
"colorMode": "none", |
||||
"graphMode": "none", |
||||
"justifyMode": "auto", |
||||
"orientation": "auto", |
||||
"reduceOptions": { |
||||
"calcs": [ |
||||
"lastNotNull" |
||||
], |
||||
"fields": "", |
||||
"values": false |
||||
}, |
||||
"textMode": "auto" |
||||
}, |
||||
"pluginVersion": "9.2.0-pre", |
||||
"targets": [ |
||||
{ |
||||
"datasource": { |
||||
"type": "testdata", |
||||
"uid": "PD8C576611E62080A" |
||||
}, |
||||
"labels": "site=A,measure=speed,state=CA", |
||||
"refId": "A", |
||||
"scenarioId": "random_walk" |
||||
}, |
||||
{ |
||||
"datasource": { |
||||
"type": "testdata", |
||||
"uid": "PD8C576611E62080A" |
||||
}, |
||||
"hide": false, |
||||
"labels": "site=B,measure=speed,state=OR", |
||||
"refId": "B", |
||||
"scenarioId": "random_walk" |
||||
}, |
||||
{ |
||||
"datasource": { |
||||
"type": "testdata", |
||||
"uid": "PD8C576611E62080A" |
||||
}, |
||||
"hide": false, |
||||
"labels": "site=B,measure=temp", |
||||
"refId": "C", |
||||
"scenarioId": "random_walk" |
||||
}, |
||||
{ |
||||
"datasource": { |
||||
"type": "testdata", |
||||
"uid": "PD8C576611E62080A" |
||||
}, |
||||
"hide": false, |
||||
"labels": "site=A,measure=temp", |
||||
"refId": "D", |
||||
"scenarioId": "random_walk" |
||||
} |
||||
], |
||||
"title": "Labeled values", |
||||
"type": "stat" |
||||
}, |
||||
{ |
||||
"datasource": { |
||||
"type": "datasource", |
||||
"uid": "-- Dashboard --" |
||||
}, |
||||
"fieldConfig": { |
||||
"defaults": { |
||||
"color": { |
||||
"mode": "thresholds" |
||||
}, |
||||
"custom": { |
||||
"align": "auto", |
||||
"displayMode": "auto", |
||||
"inspect": false |
||||
}, |
||||
"mappings": [], |
||||
"thresholds": { |
||||
"mode": "absolute", |
||||
"steps": [ |
||||
{ |
||||
"color": "green", |
||||
"value": null |
||||
}, |
||||
{ |
||||
"color": "red", |
||||
"value": 80 |
||||
} |
||||
] |
||||
} |
||||
}, |
||||
"overrides": [] |
||||
}, |
||||
"gridPos": { |
||||
"h": 10, |
||||
"w": 12, |
||||
"x": 12, |
||||
"y": 0 |
||||
}, |
||||
"id": 5, |
||||
"maxDataPoints": 1, |
||||
"options": { |
||||
"footer": { |
||||
"fields": "", |
||||
"reducer": [ |
||||
"sum" |
||||
], |
||||
"show": false |
||||
}, |
||||
"frameIndex": 2, |
||||
"showHeader": true |
||||
}, |
||||
"pluginVersion": "9.2.0-pre", |
||||
"targets": [ |
||||
{ |
||||
"datasource": { |
||||
"type": "datasource", |
||||
"uid": "-- Dashboard --" |
||||
}, |
||||
"panelId": 2, |
||||
"refId": "A" |
||||
} |
||||
], |
||||
"title": "Same values... in a table", |
||||
"transformations": [], |
||||
"type": "table" |
||||
}, |
||||
{ |
||||
"datasource": { |
||||
"type": "datasource", |
||||
"uid": "-- Dashboard --" |
||||
}, |
||||
"fieldConfig": { |
||||
"defaults": { |
||||
"color": { |
||||
"mode": "thresholds" |
||||
}, |
||||
"custom": { |
||||
"align": "auto", |
||||
"displayMode": "auto", |
||||
"inspect": false |
||||
}, |
||||
"mappings": [], |
||||
"thresholds": { |
||||
"mode": "absolute", |
||||
"steps": [ |
||||
{ |
||||
"color": "green", |
||||
"value": null |
||||
}, |
||||
{ |
||||
"color": "red", |
||||
"value": 80 |
||||
} |
||||
] |
||||
} |
||||
}, |
||||
"overrides": [] |
||||
}, |
||||
"gridPos": { |
||||
"h": 8, |
||||
"w": 12, |
||||
"x": 0, |
||||
"y": 10 |
||||
}, |
||||
"id": 4, |
||||
"maxDataPoints": 1, |
||||
"options": { |
||||
"footer": { |
||||
"fields": "", |
||||
"reducer": [ |
||||
"sum" |
||||
], |
||||
"show": false |
||||
}, |
||||
"showHeader": true |
||||
}, |
||||
"pluginVersion": "9.2.0-pre", |
||||
"targets": [ |
||||
{ |
||||
"datasource": { |
||||
"type": "datasource", |
||||
"uid": "-- Dashboard --" |
||||
}, |
||||
"panelId": 2, |
||||
"refId": "A" |
||||
} |
||||
], |
||||
"title": "Join by site", |
||||
"transformations": [ |
||||
{ |
||||
"id": "joinByLabels", |
||||
"options": { |
||||
"join": [ |
||||
"site" |
||||
], |
||||
"value": "measure" |
||||
} |
||||
} |
||||
], |
||||
"type": "table" |
||||
}, |
||||
{ |
||||
"datasource": { |
||||
"type": "datasource", |
||||
"uid": "-- Dashboard --" |
||||
}, |
||||
"fieldConfig": { |
||||
"defaults": { |
||||
"color": { |
||||
"mode": "thresholds" |
||||
}, |
||||
"custom": { |
||||
"align": "auto", |
||||
"displayMode": "auto", |
||||
"inspect": false |
||||
}, |
||||
"mappings": [], |
||||
"thresholds": { |
||||
"mode": "absolute", |
||||
"steps": [ |
||||
{ |
||||
"color": "green", |
||||
"value": null |
||||
}, |
||||
{ |
||||
"color": "red", |
||||
"value": 80 |
||||
} |
||||
] |
||||
} |
||||
}, |
||||
"overrides": [] |
||||
}, |
||||
"gridPos": { |
||||
"h": 8, |
||||
"w": 12, |
||||
"x": 12, |
||||
"y": 10 |
||||
}, |
||||
"id": 6, |
||||
"maxDataPoints": 1, |
||||
"options": { |
||||
"footer": { |
||||
"fields": "", |
||||
"reducer": [ |
||||
"sum" |
||||
], |
||||
"show": false |
||||
}, |
||||
"showHeader": true |
||||
}, |
||||
"pluginVersion": "9.2.0-pre", |
||||
"targets": [ |
||||
{ |
||||
"datasource": { |
||||
"type": "datasource", |
||||
"uid": "-- Dashboard --" |
||||
}, |
||||
"panelId": 2, |
||||
"refId": "A" |
||||
} |
||||
], |
||||
"title": "Join on all labels", |
||||
"transformations": [ |
||||
{ |
||||
"id": "joinByLabels", |
||||
"options": { |
||||
"value": "measure" |
||||
} |
||||
} |
||||
], |
||||
"type": "table" |
||||
} |
||||
], |
||||
"schemaVersion": 37, |
||||
"style": "dark", |
||||
"tags": [ |
||||
"gdev", |
||||
"transform" |
||||
], |
||||
"templating": { |
||||
"list": [] |
||||
}, |
||||
"time": { |
||||
"from": "now-6h", |
||||
"to": "now" |
||||
}, |
||||
"timepicker": {}, |
||||
"timezone": "", |
||||
"title": "Join by labels", |
||||
"uid": "FVl-9CR4z", |
||||
"version": 10, |
||||
"weekStart": "" |
||||
} |
@ -0,0 +1,72 @@ |
||||
import React, { useCallback } from 'react'; |
||||
|
||||
import { |
||||
DataTransformerID, |
||||
SelectableValue, |
||||
standardTransformers, |
||||
TransformerRegistryItem, |
||||
TransformerUIProps, |
||||
} from '@grafana/data'; |
||||
import { JoinByFieldOptions, JoinMode } from '@grafana/data/src/transformations/transformers/joinByField'; |
||||
import { Select, InlineFieldRow, InlineField } from '@grafana/ui'; |
||||
|
||||
import { useAllFieldNamesFromDataFrames } from '../utils'; |
||||
|
||||
const modes = [ |
||||
{ value: JoinMode.outer, label: 'OUTER', description: 'Keep all rows from any table with a value' }, |
||||
{ value: JoinMode.inner, label: 'INNER', description: 'Drop rows that do not match a value in all tables' }, |
||||
]; |
||||
|
||||
export function SeriesToFieldsTransformerEditor({ input, options, onChange }: TransformerUIProps<JoinByFieldOptions>) { |
||||
const fieldNames = useAllFieldNamesFromDataFrames(input).map((item: string) => ({ label: item, value: item })); |
||||
|
||||
const onSelectField = useCallback( |
||||
(value: SelectableValue<string>) => { |
||||
onChange({ |
||||
...options, |
||||
byField: value?.value, |
||||
}); |
||||
}, |
||||
[onChange, options] |
||||
); |
||||
|
||||
const onSetMode = useCallback( |
||||
(value: SelectableValue<JoinMode>) => { |
||||
onChange({ |
||||
...options, |
||||
mode: value?.value, |
||||
}); |
||||
}, |
||||
[onChange, options] |
||||
); |
||||
|
||||
return ( |
||||
<> |
||||
<InlineFieldRow> |
||||
<InlineField label="Mode" labelWidth={8} grow> |
||||
<Select options={modes} value={options.mode ?? JoinMode.outer} onChange={onSetMode} /> |
||||
</InlineField> |
||||
</InlineFieldRow> |
||||
<InlineFieldRow> |
||||
<InlineField label="Field" labelWidth={8} grow> |
||||
<Select |
||||
options={fieldNames} |
||||
value={options.byField} |
||||
onChange={onSelectField} |
||||
placeholder="time" |
||||
isClearable |
||||
/> |
||||
</InlineField> |
||||
</InlineFieldRow> |
||||
</> |
||||
); |
||||
} |
||||
|
||||
export const joinByFieldTransformerRegistryItem: TransformerRegistryItem<JoinByFieldOptions> = { |
||||
id: DataTransformerID.joinByField, |
||||
aliasIds: [DataTransformerID.seriesToColumns], |
||||
editor: SeriesToFieldsTransformerEditor, |
||||
transformation: standardTransformers.joinByFieldTransformer, |
||||
name: standardTransformers.joinByFieldTransformer.name, |
||||
description: standardTransformers.joinByFieldTransformer.description, |
||||
}; |
@ -1,49 +0,0 @@ |
||||
import React, { useCallback } from 'react'; |
||||
|
||||
import { |
||||
DataTransformerID, |
||||
SelectableValue, |
||||
standardTransformers, |
||||
TransformerRegistryItem, |
||||
TransformerUIProps, |
||||
} from '@grafana/data'; |
||||
import { SeriesToColumnsOptions } from '@grafana/data/src/transformations/transformers/seriesToColumns'; |
||||
import { Select } from '@grafana/ui'; |
||||
|
||||
import { useAllFieldNamesFromDataFrames } from '../utils'; |
||||
|
||||
export const SeriesToFieldsTransformerEditor: React.FC<TransformerUIProps<SeriesToColumnsOptions>> = ({ |
||||
input, |
||||
options, |
||||
onChange, |
||||
}) => { |
||||
const fieldNames = useAllFieldNamesFromDataFrames(input).map((item: string) => ({ label: item, value: item })); |
||||
|
||||
const onSelectField = useCallback( |
||||
(value: SelectableValue<string>) => { |
||||
onChange({ |
||||
...options, |
||||
byField: value?.value, |
||||
}); |
||||
}, |
||||
[onChange, options] |
||||
); |
||||
|
||||
return ( |
||||
<div className="gf-form-inline"> |
||||
<div className="gf-form gf-form--grow"> |
||||
<div className="gf-form-label width-8">Field name</div> |
||||
<Select options={fieldNames} value={options.byField} onChange={onSelectField} isClearable /> |
||||
</div> |
||||
</div> |
||||
); |
||||
}; |
||||
|
||||
export const seriesToFieldsTransformerRegistryItem: TransformerRegistryItem<SeriesToColumnsOptions> = { |
||||
id: DataTransformerID.seriesToColumns, |
||||
editor: SeriesToFieldsTransformerEditor, |
||||
transformation: standardTransformers.seriesToColumnsTransformer, |
||||
name: 'Outer join', |
||||
description: |
||||
'Joins many time series/tables by a field. This can be used to outer join multiple time series on the _time_ field to show many time series in one table.', |
||||
}; |
Loading…
Reference in new issue