Skip to content

Commit

Permalink
feat(observability-lib): can specify max data points on panels (#981)
Browse files Browse the repository at this point in the history
  • Loading branch information
Atrax1 authored Jan 10, 2025
1 parent 149f084 commit 9b2f9ef
Showing 1 changed file with 35 additions and 14 deletions.
49 changes: 35 additions & 14 deletions observability-lib/grafana/panels.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,21 @@ func newToolTip(options *ToolTipOptions) *common.VizTooltipOptionsBuilder {
}

type PanelOptions struct {
Datasource string
Title string
Description string
Span uint32
Height uint32
Decimals float64
Unit string
NoValue string
Min *float64
Max *float64
Query []Query
Threshold *ThresholdOptions
Transform *TransformOptions
ColorScheme dashboard.FieldColorModeId
Datasource string
Title string
Description string
Span uint32
Height uint32
Decimals float64
Unit string
NoValue string
Min *float64
Max *float64
MaxDataPoints *float64
Query []Query
Threshold *ThresholdOptions
Transform *TransformOptions
ColorScheme dashboard.FieldColorModeId
}

type Panel struct {
Expand Down Expand Up @@ -214,6 +215,10 @@ func NewStatPanel(options *StatPanelOptions) *Panel {
Mappings(options.Mappings).
ReduceOptions(common.NewReduceDataOptionsBuilder().Calcs([]string{"last"}))

if options.MaxDataPoints != nil {
newPanel.MaxDataPoints(*options.MaxDataPoints)
}

if options.Min != nil {
newPanel.Min(*options.Min)
}
Expand Down Expand Up @@ -296,6 +301,10 @@ func NewTimeSeriesPanel(options *TimeSeriesPanelOptions) *Panel {
).
Tooltip(newToolTip(options.ToolTipOptions))

if options.MaxDataPoints != nil {
newPanel.MaxDataPoints(*options.MaxDataPoints)
}

if options.Min != nil {
newPanel.Min(*options.Min)
}
Expand Down Expand Up @@ -363,6 +372,10 @@ func NewGaugePanel(options *GaugePanelOptions) *Panel {
Calcs([]string{"lastNotNull"}).Values(false),
)

if options.MaxDataPoints != nil {
newPanel.MaxDataPoints(*options.MaxDataPoints)
}

if options.Min != nil {
newPanel.Min(*options.Min)
}
Expand Down Expand Up @@ -405,6 +418,10 @@ func NewTablePanel(options *TablePanelOptions) *Panel {
Unit(options.Unit).
NoValue(options.NoValue)

if options.MaxDataPoints != nil {
newPanel.MaxDataPoints(*options.MaxDataPoints)
}

if options.Min != nil {
newPanel.Min(*options.Min)
}
Expand Down Expand Up @@ -451,6 +468,10 @@ func NewLogPanel(options *LogPanelOptions) *Panel {
NoValue(options.NoValue).
PrettifyLogMessage(options.PrettifyJSON)

if options.MaxDataPoints != nil {
newPanel.MaxDataPoints(*options.MaxDataPoints)
}

if options.Min != nil {
newPanel.Min(*options.Min)
}
Expand Down

0 comments on commit 9b2f9ef

Please sign in to comment.