GrafanaJsonDatasource
GrafanaJsonDatasource copied to clipboard
Add alerting support
Hi @simPod and @KrisztianKaszas! I'm opening up this PR to continue working on what was set forth in #630.
Sorry for the delay... things have a tendency to be pushed down in my inbox!
Let's see if we can push this through...
Summary by CodeRabbit
-
New Features
- Enabled alerting and backend processing for the datasource plugin.
- Added a new API route for table data retrieval.
-
Refactor
- Improved data query, health check, and settings handling for enhanced stability.
- Updated integration to use unique identifiers for more precise endpoint calls.
@coderabbitai full review
:white_check_mark: Actions performed
Full review triggered.
Walkthrough
The changes introduce new build scripts and module configuration along with a complete implementation of a Grafana datasource plugin. Updates include modifications in the ignore settings and metadata configuration. New files provide build targets via Mage and Make, while the module dependencies are set in go.mod. The plugin implementation now supports data queries, health checks, and resource management, with corresponding tests added. Additionally, the frontend data source has been refactored to use updated API endpoints and backend functionality.
Changes
| File(s) | Change Summary |
|---|---|
.gitignore |
Added a comment and a pattern (*.zip) to ignore packaged plugin files. |
Magefile.go, Makefile |
Introduced new build scripts: Magefile.go configures default build targets using Mage; Makefile defines targets (package, build, frontend, backend, clean) for building and packaging the project. |
go.mod |
Added a new module file for github.com/simPod/GrafanaJsonDatasource specifying Go version 1.23, including the Grafana Plugin SDK dependency and various indirect dependencies. |
pkg/main.go |
Added a new main entry point that initializes the plugin using datasource.Manage and handles error logging and process exit. |
pkg/models/settings.go |
Introduced settings management with PluginSettings and SecretPluginSettings structs, including functions to load and parse plugin settings. |
pkg/plugin/datasource.go,pkg/plugin/datasource_test.go |
Added a full implementation of the datasource plugin including methods for querying data, health checks, resource handling, and proper disposal. A test function for QueryData was also introduced to validate plugin behavior. |
src/DataSource.ts,src/MetricFindQuery.ts |
Refactored the frontend datasource: The class now extends DataSourceWithBackend with removed legacy query handling. API endpoints have been updated to use the datasource UID in the URL. |
src/plugin.json |
Updated metadata: Enabled alerting and backend support, added an executable ("jsonds_backend"), modified the author's name, and added new route configurations for resource handling. |
Sequence Diagram(s)
sequenceDiagram
participant Grafana
participant Main (pkg/main.go)
participant DS (pkg/plugin/datasource.go)
participant HTTP (External Service)
Grafana->>Main: Initialize Plugin
Main->>DS: Call datasource.Manage (NewDatasource)
DS->>HTTP: Send Query/Health Check Request
HTTP-->>DS: Return Response
DS-->>Main: Forward Data/Status
Main-->>Grafana: Deliver Response
Poem
I’m a bunny hopping through the code,
New builds and tests in a joyful mode.
Endpoints and settings, all neatly arranged,
With each little line, my world’s been changed.
Hopping with delight in this coding abode 🐇✨
Cheers to new paths in our techy road!
Nibble on changes, crisp and bold.
[!TIP]
⚡💬 Agentic Chat (Pro Plan, General Availability)
- We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai planto trigger planning for file edits and PR creation.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hi @pcolladosoto , is there anything we can assist with to push this forward?