Skip to content

API to fetch panels for a dashboard#2218

Merged
ilija42 merged 17 commits into
mainfrom
feature/grafana-get-panels
Jul 10, 2026
Merged

API to fetch panels for a dashboard#2218
ilija42 merged 17 commits into
mainfrom
feature/grafana-get-panels

Conversation

@dhaidashenko

@dhaidashenko dhaidashenko commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Depends on #2217

@dhaidashenko dhaidashenko requested a review from a team as a code owner July 2, 2026 18:59
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

✅ API Diff Results - github.com/smartcontractkit/chainlink-common/observability-lib

✅ Compatible Changes (2)

api (1)
  • DashboardPanel — ➕ Added
api.(*Client) (1)
  • GetDashboardPanelsByUID — ➕ Added

📄 View full apidiff report

Base automatically changed from obs-fix to main July 3, 2026 10:49
@ilija42 ilija42 enabled auto-merge July 10, 2026 16:55
Copilot AI review requested due to automatic review settings July 10, 2026 16:57

Copilot AI left a comment

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.

Pull request overview

Adds a Grafana API client method for retrieving all panels for a dashboard (including nested row panels) by dashboard UID, returning a flattened list of panel metadata.

Changes:

  • Introduce GetDashboardPanelsByUID plus supporting response/types and a recursive panel-flattening helper.
  • Add unit tests covering the happy-path (nested panels) and 404-not-found behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
observability-lib/api/dashboard.go Adds panel types + GetDashboardPanelsByUID that fetches dashboard JSON and flattens nested panels.
observability-lib/api/dashboard_test.go Adds tests for panel fetching/flattening and not-found handling using an httptest server.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +16 to +39
expectedResponse := getDashboardByUIDResponse{
Dashboard: struct {
ID uint `json:"id"`
UID string `json:"uid"`
Title string `json:"title"`
Panels []dashboardPanelJSON `json:"panels"`
}{
ID: 10,
UID: dashboardUID,
Title: "Test Dashboard",
Panels: []dashboardPanelJSON{
{ID: 1, Title: "Uptime", Type: "stat"},
{
ID: 2,
Title: "Resource Usage",
Type: "row",
Panels: []dashboardPanelJSON{
{ID: 3, Title: "CPU Usage", Type: "timeseries"},
{ID: 4, Title: "Memory Usage", Type: "stat"},
},
},
},
},
}
@ilija42 ilija42 added this pull request to the merge queue Jul 10, 2026
Merged via the queue into main with commit d224f9e Jul 10, 2026
34 checks passed
@ilija42 ilija42 deleted the feature/grafana-get-panels branch July 10, 2026 17:17
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.

5 participants