Skip to content

[FEATURE] Add GreptimeDB datasource Plugin#629

Open
sunchanglong wants to merge 21 commits into
perses:mainfrom
GreptimeTeam:main
Open

[FEATURE] Add GreptimeDB datasource Plugin#629
sunchanglong wants to merge 21 commits into
perses:mainfrom
GreptimeTeam:main

Conversation

@sunchanglong
Copy link
Copy Markdown

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

Pasted Graphic 7 Pasted Graphic 8 Pasted Graphic 9 Pasted Graphic 10

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.

@sunchanglong sunchanglong requested review from a team, AntoineThebaud and Nexucis as code owners April 15, 2026 02:45
@sunchanglong sunchanglong requested review from jgbernalp and removed request for a team April 15, 2026 02:45
@sunchanglong
Copy link
Copy Markdown
Author

The CI workflow failure seems unrelated to the changes in this PR.
Could you please try rerunning the job?

Comment thread greptimedb/src/queries/greptimedb-log-query/greptimedb-log-query-types.test.ts Outdated
@sunchanglong
Copy link
Copy Markdown
Author

Added GreptimeDBResponseData to refine the unknown types. This ensures better type safety and clarifies the expected data structure from GreptimeDB.

@sunchanglong
Copy link
Copy Markdown
Author

sunchanglong commented May 13, 2026

Hi team, @jgbernalp we have addressed most review issues could you please check again.
We're using the Perses GreptimeDB plugin in our project: dashboard

Comment thread greptimedb/sdk/go/query/time-series/time-series.go
Comment thread greptimedb/src/queries/greptimedb-trace-query/get-greptimedb-trace-data.ts Outdated
Comment thread greptimedb/src/queries/greptimedb-trace-query/get-greptimedb-trace-data.ts Outdated
Comment thread greptimedb/src/queries/greptimedb-trace-query/get-greptimedb-trace-data.ts Outdated
Comment thread greptimedb/go.mod Outdated
Comment thread greptimedb/go.mod Outdated
Comment thread greptimedb/src/queries/greptimedb-log-query/greptimedb-log-query-types.test.ts Outdated
Comment thread greptimedb/src/queries/greptimedb-query-data-model.ts
Comment thread greptimedb/src/queries/greptimedb-trace-query/get-greptimedb-trace-data.ts Outdated
Comment thread greptimedb/src/queries/greptimedb-log-query/GreptimeDBLogQueryEditor.tsx Outdated
@sunchanglong
Copy link
Copy Markdown
Author

the CI error was caused by perses-dev peerDependencies upgration, should be fixed

@jgbernalp
Copy link
Copy Markdown
Contributor

jgbernalp commented May 19, 2026

Code review

Found 1 issue:

  1. Missing Trace Explorer plugin registration and export. The GreptimeDBTraceExplorer component is fully implemented in src/explore/ but is never exported from src/index.ts and not registered in package.json under perses.plugins with kind: "Explore". Without these, the explorer is inaccessible to users. Compare with the Tempo plugin which exports explore at src/index.ts:16 and registers it at package.json:79-86.

greptimedb/src/index.ts is missing export * from './explore';:
https://github.com/perses/plugins/blob/21a1d260f3884018719a27554fdaaeeb87f9e140/greptimedb/src/index.ts#L13-L17

greptimedb/package.json is missing an Explore plugin entry (compare with Tempo's registration):

"perses": {
"moduleName": "GreptimeDB",
"schemasPath": "schemas",
"plugins": [
{
"kind": "Datasource",
"spec": {
"display": {
"name": "GreptimeDB Datasource"
},
"name": "GreptimeDBDatasource"
}
},
{
"kind": "TimeSeriesQuery",
"spec": {
"display": {
"name": "GreptimeDB Time Series Query"
},
"name": "GreptimeDBTimeSeriesQuery"
}
},
{
"kind": "LogQuery",
"spec": {
"display": {
"name": "GreptimeDB Log Query"
},
"name": "GreptimeDBLogQuery"
}
},
{
"kind": "TraceQuery",
"spec": {
"display": {
"name": "GreptimeDB Trace Query"
},
"name": "GreptimeDBTraceQuery"
}
}
]
}

The component exists but is dead code without proper wiring:

// Copyright The Perses Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//

Reference: Tempo plugin's correct pattern:

export { getPluginModule } from './getPluginModule';
export * from './components';
export * from './explore';
export * from './model';
export * from './plugins';

{
"kind": "Explore",
"spec": {
"display": {
"name": "Tempo Traces Explorer"
},
"name": "TempoExplorer"
}
}
]

🤖 Generated with Claude Code

@sunchanglong
Copy link
Copy Markdown
Author

Code review

Found 1 issue:

  1. Missing Trace Explorer plugin registration and export. The GreptimeDBTraceExplorer component is fully implemented in src/explore/ but is never exported from src/index.ts and not registered in package.json under perses.plugins with kind: "Explore". Without these, the explorer is inaccessible to users. Compare with the Tempo plugin which exports explore at src/index.ts:16 and registers it at package.json:79-86.

greptimedb/src/index.ts is missing export * from './explore';: https://github.com/perses/plugins/blob/21a1d260f3884018719a27554fdaaeeb87f9e140/greptimedb/src/index.ts#L13-L17

greptimedb/package.json is missing an Explore plugin entry (compare with Tempo's registration):

"perses": {
"moduleName": "GreptimeDB",
"schemasPath": "schemas",
"plugins": [
{
"kind": "Datasource",
"spec": {
"display": {
"name": "GreptimeDB Datasource"
},
"name": "GreptimeDBDatasource"
}
},
{
"kind": "TimeSeriesQuery",
"spec": {
"display": {
"name": "GreptimeDB Time Series Query"
},
"name": "GreptimeDBTimeSeriesQuery"
}
},
{
"kind": "LogQuery",
"spec": {
"display": {
"name": "GreptimeDB Log Query"
},
"name": "GreptimeDBLogQuery"
}
},
{
"kind": "TraceQuery",
"spec": {
"display": {
"name": "GreptimeDB Trace Query"
},
"name": "GreptimeDBTraceQuery"
}
}
]
}

The component exists but is dead code without proper wiring:

// Copyright The Perses Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//

Reference: Tempo plugin's correct pattern:

export { getPluginModule } from './getPluginModule';
export * from './components';
export * from './explore';
export * from './model';
export * from './plugins';

{
"kind": "Explore",
"spec": {
"display": {
"name": "Tempo Traces Explorer"
},
"name": "TempoExplorer"
}
}
]

🤖 Generated with Claude Code

yes, it is a knowned issue.
To keep this PR clean and avoid delaying the review, we've left Trace Explorer out for now, especially since we don't have an immediate need for it. We plan to follow up and open another PR for it in a future release, unless you prefer having it included now.

@jgbernalp
Copy link
Copy Markdown
Contributor

@sunchanglong in that case, please remove the dead code and create an GitHub issue for later implementation

@sunchanglong
Copy link
Copy Markdown
Author

the dead code has been removed.
#660 the issue has been recorded here

Comment thread greptimedb/go.mod
@@ -0,0 +1,32 @@
module github.com/perses/plugins/greptimedb

go 1.25.7
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
go 1.25.7
go 1.26.0

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the version was updated for previous review suggestion. the go version changed frequently.

#kind: "GreptimeDBDatasource"

kind: #kind
spec: {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

headers is missing from the spec. When using the proxy headers are included but this datasource uses them directly. Is there any reason to use them directly instead of using the Perses secrets via the proxy configuration? Plain credential storage should be avoided.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems we don't have tests for this schema

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we don't have tests for this schema

};

try {
const response = await fetch(url.toString(), init);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fetch should be imported from @perses-dev/core

try {
const response = await fetch(url.toString(), init);
if (!response.ok) {
const errorText = await response.text();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check the content type as errors might come formatted in JSON and they will be hard to read from the UI if we just assume they are text, e.g.: https://github.com/perses/plugins/blob/main/loki/src/model/loki-client.ts#L88

if (normalized.includes('second')) return String(BigInt(Math.trunc(raw)) * 1_000_000_000n);

if (raw > 1_000_000_000_000_000) return String(BigInt(Math.trunc(raw)));
if (raw > 1_000_000_000_000) return String(BigInt(Math.trunc(raw)) * 1_000_000n);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If dataType is undefined, I think we are missing the microsecond check here and they will fall into nanoseconds giving wrong timestamp results. Maybe this is right but the test needs to cover this case as well to make it clear?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants