-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
646bb51
commit b9281b3
Showing
17 changed files
with
157 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,6 +103,7 @@ | |
"vitest", | ||
"vlookup", | ||
"vuepress", | ||
"xinsnake", | ||
"yesoreyeram", | ||
"youtube" | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { uql } from 'uql'; | ||
|
||
describe('uql', () => { | ||
it('nested array parsing', async () => { | ||
const data = `{ | ||
"totalCount": 3, | ||
"nextPageKey": "null", | ||
"resolution": "1h", | ||
"warnings": [ | ||
"The contains filter transformation is deprecated and will be removed in a future release." | ||
], | ||
"result": [ | ||
{ | ||
"metricId": "builtin:host.disk.avail", | ||
"dataPointCountRatio": "0.1211", | ||
"dimensionCountRatio": "0.0322", | ||
"data": [ | ||
{ | ||
"dimensions": [ | ||
"HOST-F1266E1D0AAC2C3C", | ||
"DISK-F1266E1D0AAC2C3F" | ||
], | ||
"timestamps": [ | ||
3151435100000, | ||
3151438700000, | ||
3151442300000 | ||
], | ||
"values": [ | ||
11.1, | ||
22.2, | ||
33.3 | ||
] | ||
}, | ||
{ | ||
"dimensions": [ | ||
"HOST-F1266E1D0AAC2C3C", | ||
"DISK-F1266E1D0AAC2C3D" | ||
], | ||
"timestamps": [ | ||
3151435100000, | ||
3151438700000, | ||
3151442300000 | ||
], | ||
"values": [ | ||
111.1, | ||
222.2, | ||
333.3 | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"metricId": "builtin:host.cpu.idle", | ||
"data": [ | ||
{ | ||
"dimensions": [ | ||
"HOST-F1266E1D0AAC2C3C" | ||
], | ||
"timestamps": [ | ||
3151435100000, | ||
3151438700000, | ||
3151442300000 | ||
], | ||
"values": [ | ||
1.1, | ||
2.2, | ||
3.3 | ||
] | ||
} | ||
] | ||
} | ||
] | ||
}`; | ||
expect( | ||
await uql( | ||
`parse-json | ||
| scope "result" | ||
| project-away "dataPointCountRatio", "dimensionCountRatio" | ||
| mv-expand "data" | ||
| project "dimensions"=array_to_map("data.dimensions",'host','disk'), "series"=array_from_entries('timestamp',"data.timestamps",'value',"data.values"), "metricId" | ||
| project "host"="dimensions.host", "disk"="dimensions.disk", "series", "metricId" | ||
| mv-expand "series" | ||
| project "timestamp"="series.timestamp", "value"="series.value", "host", "disk", "metricId" | ||
| extend "timestamp"=unixtime_milliseconds_todatetime("timestamp") | ||
| order by "timestamp" asc`, | ||
{ data } | ||
) | ||
).toStrictEqual([ | ||
{ timestamp: new Date('2069-11-11 22:38:20'), disk: 'DISK-F1266E1D0AAC2C3F', host: 'HOST-F1266E1D0AAC2C3C', value: 11.1, metricId: 'builtin:host.disk.avail' }, | ||
{ timestamp: new Date('2069-11-11 22:38:20'), disk: 'DISK-F1266E1D0AAC2C3D', host: 'HOST-F1266E1D0AAC2C3C', value: 111.1, metricId: 'builtin:host.disk.avail' }, | ||
{ timestamp: new Date('2069-11-11 22:38:20'), disk: undefined, host: 'HOST-F1266E1D0AAC2C3C', value: 1.1, metricId: 'builtin:host.cpu.idle' }, | ||
{ timestamp: new Date('2069-11-11 23:38:20'), disk: 'DISK-F1266E1D0AAC2C3F', host: 'HOST-F1266E1D0AAC2C3C', value: 22.2, metricId: 'builtin:host.disk.avail' }, | ||
{ timestamp: new Date('2069-11-11 23:38:20'), disk: 'DISK-F1266E1D0AAC2C3D', host: 'HOST-F1266E1D0AAC2C3C', value: 222.2, metricId: 'builtin:host.disk.avail' }, | ||
{ timestamp: new Date('2069-11-11 23:38:20'), disk: undefined, host: 'HOST-F1266E1D0AAC2C3C', value: 2.2, metricId: 'builtin:host.cpu.idle' }, | ||
{ timestamp: new Date('2069-11-12 00:38:20'), disk: 'DISK-F1266E1D0AAC2C3F', host: 'HOST-F1266E1D0AAC2C3C', value: 33.3, metricId: 'builtin:host.disk.avail' }, | ||
{ timestamp: new Date('2069-11-12 00:38:20'), disk: 'DISK-F1266E1D0AAC2C3D', host: 'HOST-F1266E1D0AAC2C3C', value: 333.3, metricId: 'builtin:host.disk.avail' }, | ||
{ timestamp: new Date('2069-11-12 00:38:20'), disk: undefined, host: 'HOST-F1266E1D0AAC2C3C', value: 3.3, metricId: 'builtin:host.cpu.idle' }, | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b9281b3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
grafana-infinity-datasource – ./
grafana-infinity-datasource.vercel.app
grafana-infinity-datasource-yesoreyeram.vercel.app
grafana-infinity-datasource-git-main-yesoreyeram.vercel.app