[FEATURE] Add GreptimeDB datasource Plugin#629
Conversation
Signed-off-by: sun <sunchang_long@163.com>
|
The CI workflow failure seems unrelated to the changes in this PR. |
Signed-off-by: sun <sunchang_long@163.com>
Signed-off-by: sun <sunchang_long@163.com>
Signed-off-by: sun <sunchang_long@163.com>
Fixgeneration
|
Added |
|
Hi team, @jgbernalp we have addressed most review issues could you please check again. |
There was a problem hiding this comment.
Is there any reason why we don't have here a trace query sdk related files? Is this out of scope?
There was a problem hiding this comment.
Thanks for catching this.This SDK is simply not used in our work at the moment.
Added trace query Go SDK support, aligned with the existing time-series and log builders.
| if (raw !== undefined) { | ||
| const normalized = (dataType ?? '').toLowerCase(); | ||
| if (normalized.includes('nanosecond')) return String(Math.trunc(raw)); | ||
| if (normalized.includes('microsecond')) return String(Math.trunc(raw * 1000)); |
There was a problem hiding this comment.
Could this be a resolution loss when multiplying, when large raw values are multiplied the MAX_INTEGER might be exceeded, maybe safer to use BigInt arithmetic:
| if (normalized.includes('microsecond')) return String(Math.trunc(raw * 1000)); | |
| if (normalized.includes('microsecond')) return String(BigInt(Math.trunc(raw)) * 1000n); |
There was a problem hiding this comment.
Thanks for the code,Agreed, now uses BigInt for unit scaling.
| const endTimeUnixNano = | ||
| (endIndex !== undefined ? toNanoString(row[endIndex], columns[endIndex]?.data_type) : undefined) ?? | ||
| (durationIndex !== undefined | ||
| ? String(parseInt(startTimeUnixNano, 10) + parseInt(toNanoString(row[durationIndex]) ?? '0', 10)) |
There was a problem hiding this comment.
same here, nano seconds can be very large.
| import { GreptimeDBLogQuerySpec } from './greptimedb-log-query-types'; | ||
| import { LogQueryPlugin } from './log-query-plugin-interface'; | ||
|
|
||
| function buildLogs(records: GreptimeDBRecords | undefined): LogData { |
There was a problem hiding this comment.
It seems tests for this function are not present. It seems important to assert the data mapping is correct and avoids regressions in the future. WDYT?
There was a problem hiding this comment.
Added coverage in greptimedb-log-query-types.test.ts
| return dataType.toLowerCase(); | ||
| } | ||
|
|
||
| export function toTimestampMs(value: unknown, dataType: string | undefined): number | null { |
There was a problem hiding this comment.
It seems this function is used extensively but has no tests.
There was a problem hiding this comment.
Added unit test in greptimedb-query-data-model.test.ts
| .sort((a, b) => b.startTimeUnixMs - a.startTimeUnixMs); | ||
| } | ||
|
|
||
| function toNanoString(value: unknown, dataType?: string): string | undefined { |
There was a problem hiding this comment.
it seems this function is used extensively but has no tests
There was a problem hiding this comment.
sure, Added test in get-greptimedb-trace-data.test.ts
| const examplesStyle = { | ||
| fontSize: '11px', | ||
| color: '#777', | ||
| backgroundColor: '#f5f5f5', |
There was a problem hiding this comment.
hardcoded colors wont work on dark mode, theme colors should be used here.
There was a problem hiding this comment.
replaced the hardcoded color with theme style
Signed-off-by: sun <sunchang_long@163.com>
Signed-off-by: sun <sunchang_long@163.com>
Signed-off-by: sun <sunchang_long@163.com>
Signed-off-by: sun <sunchang_long@163.com>
Signed-off-by: sun <sunchang_long@163.com>
Signed-off-by: sun <sunchang_long@163.com>
Signed-off-by: sun <sunchang_long@163.com>
Signed-off-by: sun <sunchang_long@163.com>
Signed-off-by: sun <sunchang_long@163.com>
Signed-off-by: sun <sunchang_long@163.com>
Signed-off-by: sun <sunchang_long@163.com>
chore: plugin version
|
the CI error was caused by perses-dev peerDependencies upgration, should be fixed |
Description
This pull request adds a new GreptimeDB plugin to the plugins repository so Perses can query and visualize metrics & logs data from GreptimeDB.
The implementation covers the main GreptimeDB query workflows used in Perses dashboards:
querying time series data from GreptimeDB based on panel time range
converting GreptimeDB responses into the data format expected by Perses panels, so charts and related visual components can consume results without additional handling
A few points worth calling out for review:
GreptimeDB response data is normalized and mapped into Perses-compatible series/frames, including timestamps, values, and label dimensions
plugin schemas, SDK integration helpers, datasource configuration, query editor support, and tests are included in the same change
only files required for the GreptimeDB plugin and workspace/plugin registration were touched
This change is intended to address GreptimeDB datasource support discussed in the linked issue and related follow-up conversations.
Screenshots
Checklist
[<catalog_entry>] <commit message>naming convention using one of thefollowing
catalog_entryvalues:FEATURE,ENHANCEMENT,BUGFIX,BREAKINGCHANGE,DOC,IGNORE.UI Changes