Skip to content

Commit

Permalink
feat(observability-lib): can specify max data points on panels
Browse files Browse the repository at this point in the history
  • Loading branch information
Atrax1 committed Jan 6, 2025
1 parent db7919d commit ef3e9a1
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 @@ -89,20 +89,21 @@ func newTransform(options *TransformOptions) dashboard.DataTransformerConfig {
}

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 @@ -183,6 +184,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 @@ -259,6 +264,10 @@ func NewTimeSeriesPanel(options *TimeSeriesPanelOptions) *Panel {
Type(options.ScaleDistribution),
)

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

if options.Min != nil {
newPanel.Min(*options.Min)
}
Expand Down Expand Up @@ -326,6 +335,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 @@ -368,6 +381,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 @@ -414,6 +431,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 ef3e9a1

Please sign in to comment.