Dashboard builder

The Dashboard builder helps creating dashboards in the format expected by Perses.

Usage

package myDaC

import (
	dashboardBuilder "github.com/perses/perses/cue/dac-utils/dashboard"
)

dashboardBuilder & {} // input parameters expected

Parameters

ParameterTypeDescription
#namestringThe name of the dashboard.
#displayDisplayDisplay object to tune the display name and description.
#projectstringThe project to which the dashboard belongs.
#variables[…VariableSpec]An array of variables defined for the dashboard.
#panelGroupsmap[string]: { layout: Layout, panels: map[string]: Panel }A map where each key is a panel group name, and the value is an object containing layout and panels for that group.

Example

package myDaC

import (
	dashboardBuilder "github.com/perses/perses/cue/dac-utils/dashboard"
	panelGroupsBuilder "github.com/perses/perses/cue/dac-utils/panelgroups"
	panelBuilder "github.com/perses/perses/cue/dac-utils/prometheus/panel"
	varGroupBuilder "github.com/perses/perses/cue/dac-utils/variable/group"
	textVarBuilder "github.com/perses/perses/cue/dac-utils/variable/text"
	labelValuesVarBuilder "github.com/perses/perses/cue/dac-utils/prometheus/variable/labelvalues"
	timeseriesChart "github.com/perses/perses/cue/schemas/panels/time-series:model"
	promQuery "github.com/perses/perses/cue/schemas/queries/prometheus:model"
)

dashboardBuilder & {
	#name:    "ContainersMonitoring"
	#project: "MyProject"
	#variables: {varGroupBuilder & {
		#input: [
			textVarBuilder & {
				#name:     "prometheus"
				#value:    "platform"
				#constant: true
			},
			labelValuesVarBuilder & {
				#name: "stack"
				#display: name: "PaaS"
				#metric:         "thanos_build_info"
				#label:          "stack"
				#datasourceName: "promDemo"
			}
		]
	}}.variables
	#panelGroups: panelGroupsBuilder & {
		#input: [
			{
				#title: "Resource usage"
				#cols:  3
				#panels: [
					panelBuilder & {
						spec: {
							display: name: "Container CPU"
							plugin: timeseriesChart
							queries: [
								{
									kind: "TimeSeriesQuery"
									spec: plugin: promQuery & {
										spec: query: "sum by (container) (container_cpu_usage_seconds)"
									}
								},
							]
						}
					}
				]
			},
		]
	}
}

As you can see, other builders are used in conjunction with the dashboard builder to facilitate further the coding. Please refer to their respective documentation for more information about each.