Skip to content

Feature/grafana irm plugin(#9065) - #9160

Open
Thundercloud12 wants to merge 9 commits into
apache:mainfrom
Thundercloud12:feature/grafana-irm-plugin
Open

Thundercloud12 wants to merge 9 commits into
apache:mainfrom
Thundercloud12:feature/grafana-irm-plugin

Conversation

@Thundercloud12

Copy link
Copy Markdown
Contributor

Summary

This PR introduces a new Grafana IRM (Incident Response & Management) plugin to Apache DevLake, enabling ingestion of Grafana Cloud Incident data into DevLake's standardized domain layer (issues, issue_labels, issue_assignees, boards, and board_issues) for tracking incident metrics and correlating with DORA metrics (Change Failure Rate and MTTR).

Key Components

  1. Backend Plugin (backend/plugins/grafana_irm)

    • Data Layer:

      • Raw layer: _raw_grafana_irm_incidents
      • Tool layer: _tool_grafana_irm_incidents, _tool_grafana_irm_incident_labels, _tool_grafana_irm_incident_assignments, and scopes/connections.
      • Domain layer: maps incidents to domain Issue (type = INCIDENT), IssueLabel, IssueAssignee, and domain Board / BoardIssue.
    • Collection Pattern:

      • Incremental incident collection utilizing helper.NewFinalizableApiCollector.
      • Handles both date-range query collection (IncidentsService.QueryIncidents) and active/unfinished incident refreshes in a single subtask.
    • API & Scope Management:

      • Full CRUD for connections, credential validation via service account tokens, scope APIs, and single-scope remote API picker (remote_api.go).
      • Resilient error handling for connection testing, including DNS errors, invalid URLs, HTTP 401/403/404 responses, and network timeouts with friendly error messages.
    • Database Migration:

      • Initial schema migration (20260918_add_init_tables.go) registered in register.go.
      • Registered in plugins/table_info_test.go and schema validation tests.
  2. Config UI Integration (config-ui)

    • Registered grafana_irm in the Config UI plugin registry.
    • Added a connection form supporting Grafana Cloud stack endpoint, Service Account tokens, proxy, and rate limits.
    • Bundled the official Grafana SVG icon and linked official Grafana IRM documentation.
  3. Dashboards (grafana/dashboards)

    • Added a dedicated Grafana IRM dashboard JSON (grafana-irm.json, plus MySQL and PostgreSQL variants) displaying incident trends, MTTR, severity breakdown, and active incident tracking.
  4. Testing

    • E2E dataflow tests (incident_test.go) with CSV fixtures verifying raw → tool → domain conversion.
    • Unit tests covering query generation, extraction, remote scopes, and connection test error cases (connection_api_test.go).

Screenshots

Screencast.from.2026-09-21.22-29-00.mp4

Other Information

  • Auth Model: Authenticates using Grafana Cloud Service Account tokens (Authorization: Bearer <token>).
  • Endpoint Format: Accepts standard Grafana Cloud stack base URLs (e.g., https://<stack>.grafana.net/).
  • Follows existing incident plugin conventions (pagerduty, incidentio, opsgenie).

Thundercloud12 and others added 8 commits September 20, 2026 10:16
…ent TestConnection

- Seed 2 more real (non-drill) incidents on the dev stack with a real role
  assignment and multi-label data, closing gaps the original 2-incident
  fixture never exercised (assignment mapping, per-scope label exclusion).
- Add a second e2e scenario proving label-based scope filtering end-to-end.
- Update the extractor unit test to use real captured incident data instead
  of a drill incident's.
- Implement TestConnection/TestExistingConnection via a cheap
  IncidentsService.QueryIncidents call, verified live against the real API.
…filtering

The originating feature request only asks for org-wide DORA correlation and
never mentions per-team scoping. The label-based per-scope filtering added
earlier this session was real and tested, but solved a problem nobody asked
for, and config-ui has no generic manual-scope-entry component to build a UI
for it on top of. Revert GrafanaIrmScopeConfig/GrafanaIrmOptions/the
collector/converter to a single connection-wide scope with no filtering, same
shape as incidentio/pagerduty. All incident labels are still collected and
stored unconditionally, just no longer used to gate conversion.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Backend: add remote_api.go returning the one synthetic scope every
connection has (config-ui's data-scope picker has no manual-entry flow to
fall back to, so this feeds the standard remote-picker UI a single 'All
Incidents' entry instead), wired into impl.go's routes. Frontend: add config-ui/src/plugins/register/grafana_irm (connection form,
icon, registration) mirroring incidentio's shape, using the Grafana logo
already vendored under grafana/img/. No custom scope-config UI is needed
since GrafanaIrmScopeConfig carries no extra fields (Option A). Verified
with tsc, eslint, and a production vite build - all clean.
…piCollector subtask

The two-subtask design (CollectIncidents + RefreshOpenIncidents) caused three
real bugs found via live pipeline testing: a panic, "Re-transform Data"
silently deleting resolved incidents, and a genuine full sync also losing
data because both subtasks independently wiped the raw table with no
coordination between them.

pagerduty solves the identical "list new/changed, then refresh still-open"
need with DevLake's own FinalizableApiCollector as a single subtask, which
prevents these bugs by construction (the framework never builds the
"refresh" half on a full sync, and there's only one subtask name for
Re-transform Data's filter to strip). Migrated CollectIncidents to that
pattern; all existing collector logic (query building, change-detection via
a request-scoped header) preserved, just re-wired. Live-verified against a
real server: full sync restores all incidents correctly, incremental sync
has no regression, and Re-transform Data no longer drops resolved incidents.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…board mapping

- Add dedicated Grafana dashboards for MySQL and PostgreSQL dialects
- Populate domain ticket.Board in ConvertIncidents to enable board filtering and joins
- Update config-ui brand icon with official Grafana flame SVG
- Add plugin documentation in backend/plugins/grafana_irm/README.md
- Fix struct alignment formatting in models/incident.go
@Thundercloud12 Thundercloud12 changed the title Feature/grafana irm plugin Feature/grafana irm plugin(#9065) Sep 22, 2026
@Thundercloud12

Copy link
Copy Markdown
Contributor Author

@klesh please have a look at this feature, it is a very big one majorly I followed incidentio in its structure n all,was raised in one of the issues, I have attached video of the said feature, thank you!

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.

1 participant