Panel Group Builder#
Constructor#
import "github.com/perses/perses/go-sdk/panel-group"
var options []panelgroup.Option
panelgroup.New("My Panel Group Title", options...)
Need to provide a title and a list of options.
Default options#
- Title(): with the title provided in the constructor.
- PanelWidth(): 12
- PanelHeight(): 6
- Collapsed(): true
Available options#
Title#
Define the panel group title.
PanelWidth#
Define the panel width. The value must be between 1 and 24.
PanelsPerLine#
Helper for defining panel width instead of PanelWidth. The value must be between 1 and 24.
PanelHeight#
Define the panel height. The value must be between 1 and 24.
Collapsed#
Define if the panel group is collapsed or not when the dashboard is loaded. Collapsed panel group are lazy loaded when they are opened.
AddPanel#
import "github.com/perses/perses/go-sdk/panel-group"
import "github.com/perses/perses/go-sdk/panel"
var panelOptions []panel.Option
panelgroup.AddPanel("MySuperPanelName", panelOptions...)
Add a panel to the group, the panel will be placed depending on the ordering of in the group. More info about the panel can be found here.
Example#
package main
import (
"github.com/perses/perses/go-sdk/dashboard"
"github.com/perses/perses/go-sdk/panel"
panelgroup "github.com/perses/perses/go-sdk/panel-group"
timeseries "github.com/perses/perses/go-sdk/panel/time-series"
"github.com/perses/perses/go-sdk/prometheus/query"
)
func main() {
dashboard.New("Example Dashboard",
dashboard.AddPanelGroup("Resource usage",
panelgroup.Collapsed(false),
panelgroup.PanelsPerLine(1),
panelgroup.AddPanel("Container memory",
timeseries.Chart(),
panel.AddQuery(
query.PromQL("max by (container) (container_memory_rss{stack=\"$stack\",prometheus=\"$prometheus\",prometheus_namespace=\"$prometheus_namespace\",namespace=\"$namespace\",pod=\"$pod\",container=\"$container\"})"),
),
),
),
)
}