Skip to content

Updating Go sdk to include group_by at dashboard level#979

Merged
yec-akamai merged 2 commits into
linode:mainfrom
mawasthy-lgtm:add-group-by-to-monitor-dashboard
Jun 2, 2026
Merged

Updating Go sdk to include group_by at dashboard level#979
yec-akamai merged 2 commits into
linode:mainfrom
mawasthy-lgtm:add-group-by-to-monitor-dashboard

Conversation

@mawasthy-lgtm
Copy link
Copy Markdown
Contributor

@mawasthy-lgtm mawasthy-lgtm commented May 27, 2026

Updating Go sdk to include group_by at dashboard level

✔️ How to Test
How do I run the relevant unit/integration tests?

Prerequisites
Go 1.19+ installed
Valid Linode API token with monitor permissions
Export LINODE_TOKEN environment variable for integration tests

Run all monitor alert definition unit tests:
UNIT TEST:
go test ./test/unit -run "..MonitorDashboard.." -v

Expected Output:

✅ TestListMonitorDashboards
✅ TestListMonitorDashboardsByID
✅ TestListMonitorDashboardsByServiceType

INTEGRATION TEST:
export LINODE_TOKEN="your-linode-api-token"
go test ./test/integration -run "TestMonitorDashboards_Get_smoke" -v

Test Coverage:

List Monitor Dashboards: Verifies listing all monitor dashboards returns correct data and structure.
List Monitor Dashboards By ID: Verifies fetching a single monitor dashboard by ID returns the expected dashboard.
List Monitor Dashboards By Service: Verifies listing dashboards filtered by service type returns the correct dashboards.

📷 Preview
If applicable, include a screenshot or code snippet of this change. Otherwise, please remove this section.

@mawasthy-lgtm mawasthy-lgtm marked this pull request as ready for review June 2, 2026 09:43
@mawasthy-lgtm mawasthy-lgtm requested a review from a team as a code owner June 2, 2026 09:43
Copilot AI review requested due to automatic review settings June 2, 2026 09:43
@mawasthy-lgtm mawasthy-lgtm requested a review from a team as a code owner June 2, 2026 09:43
@mawasthy-lgtm mawasthy-lgtm requested review from jriddle-linode and mawilk90 and removed request for a team June 2, 2026 09:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates monitor dashboard models and test fixtures to represent group_by at the dashboard level (instead of per-widget), and adjusts unit/integration tests accordingly.

Changes:

  • Added group_by to the MonitorDashboard model.
  • Updated unit test assertions to validate dashboard-level group_by.
  • Refreshed unit/integration fixtures to move group_by to dashboard level and adjust widget fields.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
monitor_dashboards.go Adds GroupBy field to MonitorDashboard JSON model.
test/unit/monitor_dashboards_test.go Updates assertions to check dashboard-level group_by.
test/unit/fixtures/monitor_dashboards.json Moves group_by to dashboard and removes it from widgets; adjusts widget fields.
test/unit/fixtures/monitor_dashboard_by_service_type.json Same fixture updates for service-type endpoint.
test/unit/fixtures/monitor_dashboard_by_id.json Same fixture updates for by-id endpoint.
test/integration/monitor_dashboards_test.go Loosens group_by validation to allow optional presence.
test/integration/fixtures/TestMonitorDashboards_Get.yaml Updates recorded responses: dashboard-level group_by, updated labels, and header changes.

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

Comment thread monitor_dashboards.go
if widget.GroupBy != nil {
require.NotEmpty(t, widget.GroupBy, "group_by should not be empty when present")
}
require.GreaterOrEqual(t, len(widget.GroupBy), 0, "group_by should be a slice (possibly empty)")
Comment on lines +30 to +31
assert.NotEmpty(t, clients[0].GroupBy, "Expected group_by to be present at dashboard level")
assert.Equal(t, []string{"entity_id"}, clients[0].GroupBy, "Expected dashboard group_by to match")
Comment on lines 77 to +80
"size": 6,
"chart_type": "area",
"y_label": "write_iops",
"aggregate_function": "sum",
"group_by": ["entity_id"],
"filters": [
{
"dimension_label": "pattern",
"operator": "in",
"value": "publicout,privateout"
}
]
"aggregate_function": "avg"
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.

^looks like group_by is not returned at widgets level anymore. Can you mark it as deprecated in the DashboardWidget?

Comment on lines 294 to +297
- DENY
- DENY
X-Oauth-Scopes:
- account:read_only databases:read_only domains:read_only events:read_only firewall:read_only
images:read_only ips:read_only linodes:read_only lke:read_only longview:read_only
monitor:read_only nodebalancers:read_only object_storage:read_only stackscripts:read_only
volumes:read_only
- '*'
@mawilk90 mawilk90 requested a review from yec-akamai June 2, 2026 11:01
@mawilk90 mawilk90 added the hotfix for hotfixes that do not have a corresponding Jira ticket label Jun 2, 2026
Copy link
Copy Markdown
Contributor

@yec-akamai yec-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yec-akamai yec-akamai merged commit fdd38e3 into linode:main Jun 2, 2026
12 of 13 checks passed
@zliang-akamai zliang-akamai added new-feature for new features in the changelog. community-contribution for contributions made by a non-DX author and removed hotfix for hotfixes that do not have a corresponding Jira ticket labels Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution for contributions made by a non-DX author new-feature for new features in the changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants