GrafanaJsonDatasource icon indicating copy to clipboard operation
GrafanaJsonDatasource copied to clipboard

Add alerting support

Open pcolladosoto opened this issue 7 months ago • 4 comments
trafficstars

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.

pcolladosoto avatar Mar 31 '25 09:03 pcolladosoto

@coderabbitai full review

simPod avatar Apr 11 '25 07:04 simPod

:white_check_mark: Actions performed

Full review triggered.

coderabbitai[bot] avatar Apr 11 '25 07:04 coderabbitai[bot]

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 @coderabbitai in 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 @coderabbitai in 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 pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file 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.

coderabbitai[bot] avatar Apr 11 '25 07:04 coderabbitai[bot]

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.

github-actions[bot] avatar May 12 '25 02:05 github-actions[bot]

Hi @pcolladosoto , is there anything we can assist with to push this forward?

KrisztianKaszas avatar Aug 21 '25 07:08 KrisztianKaszas