-
Notifications
You must be signed in to change notification settings - Fork 40
[FEATURE] Add SQL Datasource Plugin with Explorer Support #542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Pascal Zimmermann <pascal.zimmermann@theiotstudio.com>
e0cd822 to
82e7d52
Compare
|
Related to: perses/perses#2930 |
| kind: #kind | ||
| spec: { | ||
| proxy: { | ||
| kind: "sqlproxy" |
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.
A big thanks for this huge work to cover a gap in the Perses plugin !
I have quickly looked at the code and actually this can be simplified as the definition of the sql proxy is already defined here: https://github.com/perses/shared/blob/main/cue/common/proxy/sql.cue
So it should give something like that:
kind: #kind
spec: {
proxy: commonProxy.#SQLProxy
}
rickardsjp
left a comment
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.
Thanks for the contribution. Please add the sql plugin to the top level (monorepo root) package.json workspaces list. Otherwise, it will not be included in e.g. the build and lint commands. Once you include it, please take a look at the linter issues, too.
| export default { | ||
| displayName: 'sql', | ||
| preset: 'ts-jest', | ||
| testEnvironment: 'jsdom', | ||
| setupFilesAfterEnv: ['<rootDir>/src/setup-tests.ts'], | ||
| moduleNameMapper: { | ||
| '\\.(css|less|scss|sass)$': 'identity-obj-proxy', | ||
| '^echarts$': '<rootDir>/__mocks__/echarts.ts', | ||
| '^zrender$': '<rootDir>/__mocks__/zrender.ts', | ||
| }, | ||
| transform: { | ||
| '^.+\\.tsx?$': ['ts-jest', { | ||
| tsconfig: { | ||
| jsx: 'react', | ||
| esModuleInterop: true, | ||
| }, | ||
| }], | ||
| }, | ||
| testMatch: [ | ||
| '**/__tests__/**/*.ts?(x)', | ||
| '**/?(*.)+(spec|test).ts?(x)', | ||
| ], | ||
| collectCoverageFrom: [ | ||
| 'src/**/*.{ts,tsx}', | ||
| '!src/**/*.d.ts', | ||
| '!src/**/index.ts', | ||
| '!src/setup-tests.ts', | ||
| ], | ||
| }; |
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.
Please use the shared jest config from ../jest.shared.ts like the other plugins.
Description
This PR introduces a comprehensive SQL datasource plugin for Perses, enabling users to query and visualize data from PostgreSQL, MySQL, and MariaDB databases. The plugin includes a full-featured Explorer mode similar to the Prometheus plugin, providing both table and graph views for SQL query results.
Key Features
SQL Datasource Plugin
SQL Time Series Query Plugin
$__timeFilter(column)- Generates time range filter$__timeFrom- Query start time$__timeTo- Query end time$__interval- Auto-calculated interval$__interval_ms- Interval in millisecondsSQL Explorer Plugin (New)
Architecture
The plugin follows Perses plugin architecture best practices:
Frontend (TypeScript/React)
Backend Integration
sslmode=disablefor development environmentsTesting
Unit Tests (12 tests, all passing)
replace-sql-builtin-variables.test.ts)sql-client.test.ts)SQLDatasource.test.tsx)Test Data
Documentation
Screenshots
SQL Datasource Configuration
SQL Explorer - Table View
SQL Plugin View
Dashboard with SQL Panel
Checklist
[FEATURE] <commit message>naming convention.UI Changes
Additional Notes
What's Included
✅ Production-ready features:
Future Enhancements (Not Blocking)
Testing Instructions
Start test databases:
cd plugins/sql make db-upRun unit tests:
npm testBuild the plugin:
Manual testing:
Database Compatibility
Migration Notes
This is a new plugin and does not require migration from existing configurations.
Related issues
Add PostgreSQL plugin support
Related PRs
Adapt the proxy output
Handle the MariaDB support for the backend proxy