Skip to content

Instantly share code, notes, and snippets.

@kylebrandt
Last active June 6, 2024 14:11
Show Gist options
  • Save kylebrandt/dce4068f6beddb54cfe58d6b85ad9c75 to your computer and use it in GitHub Desktop.
Save kylebrandt/dce4068f6beddb54cfe58d6b85ad9c75 to your computer and use it in GitHub Desktop.
ScopeDashboardBinding Summary and Examples

Scopes API Summary

We have created an alpha version of the API for scopes and scope/dashboard relationships. This is an OpenAPI and kubernetes style API.

Object Summary

There are two main objects (kinds):

  • Scope: Each Scope's spec includes an array of ScopeFilter and the string properties title and description.
    • ScopeFilter has key, operator (enum), and value
  • ScopeDashboardBinding: The spec contains Dashboard and Scope, where each is the unique identifier (name) to form the name.

Scope Dashboard relationship

To view dashboards that are available for a given scope, a list request for ScopeDashboardBindings is made using a field selector on the scope property of the bindings.

### Scope Dashboard Bindings (Find)
@baseURL = http://admin:admin@localhost:3000
### Binding slothAppDashboard to slothPictureFactory (Scope)
POST {{baseURL}}/apis/scope.grafana.app/v0alpha1/namespaces/default/scopedashboardbindings
Content-Type: application/json
Accept: application/json
{
"apiVersion": "scope.grafana.app/v0alpha1",
"kind": "ScopeDashboardBinding",
"metadata": {
"name": "slothAppDashboard.slothPictureFactory"
},
"spec": {
"dashboard": "slothAppDashboard",
"dashboardTitle": "Sloth App Dashboard",
"scope": "slothPictureFactory"
}
}
### Binding slothAppDashboard to slothPictureFactory (Scope)
POST {{baseURL}}/apis/scope.grafana.app/v0alpha1/namespaces/default/scopedashboardbindings
Content-Type: application/json
Accept: application/json
{
"apiVersion": "scope.grafana.app/v0alpha1",
"kind": "ScopeDashboardBinding",
"metadata": {
"name": "slothAppDashboard.slothVoteTracker"
},
"spec": {
"dashboard": "slothAppDashboard",
"dashboardTitle": "Sloth App Dashboard",
"scope": "slothVoteTracker"
}
}
### Binding slothClusterDashboard to slothClusterNorth (Scope)
POST {{baseURL}}/apis/scope.grafana.app/v0alpha1/namespaces/default/scopedashboardbindings
Content-Type: application/json
Accept: application/json
{
"apiVersion": "scope.grafana.app/v0alpha1",
"kind": "ScopeDashboardBinding",
"metadata": {
"name": "slothClusterDashboard.slothClusterNorth"
},
"spec": {
"dashboard": "slothClusterDashboard",
"dashboardTitle": "Sloth Cluster Dashboard",
"scope": "slothClusterNorth"
}
}
### Binding slothClusterDashboard to slothClusterSouth (Scope)
POST {{baseURL}}/apis/scope.grafana.app/v0alpha1/namespaces/default/scopedashboardbindings
Content-Type: application/json
Accept: application/json
{
"apiVersion": "scope.grafana.app/v0alpha1",
"kind": "ScopeDashboardBinding",
"metadata": {
"name": "slothClusterDashboard.slothClusterSouth"
},
"spec": {
"dashboard": "slothClusterDashboard",
"dashboardTitle": "Sloth Cluster Dashboard",
"scope": "slothClusterSouth"
}
}
### Find scope dashboard bindings for scopes slothVoteTracker and slothClusterNorth (note the literal `name` is required)
GET {{baseURL}}/apis/scope.grafana.app/v0alpha1/namespaces/default/find/scope_dashboard_bindings?scope=slothVoteTracker&scope=slothClusterNorth
Accept: application/json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment