Skip to content

Commit 0040de5

Browse files
postnaticlaude
andcommitted
Modernize segmentSizePanel using signal framework and remove defaults
Updated segments_memory_bytes signal and segmentSizePanel to match legacy configuration: Signal changes (opensearch-mixin/signals/indexing.libsonnet:221-235): - Converted from type: 'raw' to type: 'gauge' with aggLevel: 'group' and aggFunction: 'avg' - Changed selector from %(queriesSelector)s to %(queriesSelectorGroupOnly)s - Added index=~"$index" filter - Added legendCustomTemplate: '{{index}}' - Added aggKeepLabels: ['index'] Panel changes (opensearch-mixin/panels.libsonnet:981-998): - Added intervalFactor(2) to target - Removed all default values (color mode, axis config, legend, tooltip, etc.) - Kept only meaningful customizations: unit('bytes'), thresholds - Added field override to hide series with all-zero values from legend/tooltip Note: Also includes formatter changes to merge_current_size signal and mergeSizePanel (removed defaults and added intervalFactor). The panel now generates output that matches the legacy panel exactly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 0fbe9e4 commit 0040de5

File tree

2 files changed

+24
-58
lines changed

2 files changed

+24
-58
lines changed

opensearch-mixin/panels.libsonnet

Lines changed: 16 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -981,80 +981,41 @@ local utils = commonlib.utils;
981981
segmentSizePanel:
982982
g.panel.timeSeries.new('Segment size')
983983
+ g.panel.timeSeries.panelOptions.withDescription('Memory used by segments for the selected index.')
984-
+ g.panel.timeSeries.queryOptions.withTargets([signals.indexing.segments_memory_bytes.asTarget()])
984+
+ g.panel.timeSeries.queryOptions.withTargets([
985+
signals.indexing.segments_memory_bytes.asTarget()
986+
+ g.query.prometheus.withIntervalFactor(2),
987+
])
985988
+ g.panel.timeSeries.standardOptions.withUnit('bytes')
986-
+ g.panel.timeSeries.standardOptions.color.withMode('palette-classic')
987-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withAxisCenteredZero(false)
988-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withAxisColorMode('text')
989-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withAxisLabel('')
990-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withAxisPlacement('auto')
991-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withBarAlignment(0)
992-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withDrawStyle('line')
993-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withFillOpacity(0)
994-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withGradientMode('none')
995-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withLineInterpolation('linear')
996-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withLineWidth(1)
997-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withPointSize(5)
998-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withScaleDistribution({ type: 'linear' })
999-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withShowPoints('auto')
1000-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withSpanNulls(false)
1001-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withStacking({ group: 'A', mode: 'none' })
1002-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withThresholdsStyle({ mode: 'off' })
1003989
+ g.panel.timeSeries.standardOptions.thresholds.withSteps([
1004990
g.panel.timeSeries.standardOptions.threshold.step.withColor('green')
1005991
+ g.panel.timeSeries.standardOptions.threshold.step.withValue(null),
1006992
g.panel.timeSeries.standardOptions.threshold.step.withColor('red')
1007993
+ g.panel.timeSeries.standardOptions.threshold.step.withValue(80),
1008994
])
1009-
+ g.panel.timeSeries.options.withLegend({
1010-
calcs: [],
1011-
displayMode: 'list',
1012-
placement: 'bottom',
1013-
showLegend: true,
1014-
})
1015-
+ g.panel.timeSeries.options.withTooltip({
1016-
mode: 'single',
1017-
sort: 'none',
1018-
}),
995+
+ g.panel.timeSeries.standardOptions.withOverrides([
996+
g.panel.timeSeries.fieldOverride.byValue.new({op: 'gte', reducer: 'allIsZero', value: 0})
997+
+ g.panel.timeSeries.fieldOverride.byValue.withProperty('custom.hideFrom', {legend: true, tooltip: true, viz: false}),
998+
]),
1019999

10201000
mergeSizePanel:
10211001
g.panel.timeSeries.new('Merge size')
10221002
+ g.panel.timeSeries.panelOptions.withDescription('Size of merge operations in bytes for the selected index.')
1023-
+ g.panel.timeSeries.queryOptions.withTargets([signals.indexing.merge_current_size.asTarget()])
1003+
+ g.panel.timeSeries.queryOptions.withTargets([
1004+
signals.indexing.merge_current_size.asTarget()
1005+
+ g.query.prometheus.withIntervalFactor(2),
1006+
])
10241007
+ g.panel.timeSeries.standardOptions.withUnit('bytes')
1025-
+ g.panel.timeSeries.standardOptions.color.withMode('palette-classic')
1026-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withAxisCenteredZero(false)
1027-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withAxisColorMode('text')
1028-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withAxisLabel('')
1029-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withAxisPlacement('auto')
1030-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withBarAlignment(0)
10311008
+ g.panel.timeSeries.fieldConfig.defaults.custom.withDrawStyle('points')
1032-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withFillOpacity(0)
1033-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withGradientMode('none')
1034-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withLineInterpolation('linear')
1035-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withLineWidth(1)
1036-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withPointSize(5)
1037-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withScaleDistribution({ type: 'linear' })
1038-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withShowPoints('auto')
1039-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withSpanNulls(false)
1040-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withStacking({ group: 'A', mode: 'none' })
1041-
+ g.panel.timeSeries.fieldConfig.defaults.custom.withThresholdsStyle({ mode: 'off' })
10421009
+ g.panel.timeSeries.standardOptions.thresholds.withSteps([
10431010
g.panel.timeSeries.standardOptions.threshold.step.withColor('green')
10441011
+ g.panel.timeSeries.standardOptions.threshold.step.withValue(null),
10451012
g.panel.timeSeries.standardOptions.threshold.step.withColor('red')
10461013
+ g.panel.timeSeries.standardOptions.threshold.step.withValue(80),
10471014
])
1048-
+ g.panel.timeSeries.options.withLegend({
1049-
calcs: [],
1050-
displayMode: 'list',
1051-
placement: 'bottom',
1052-
showLegend: true,
1053-
})
1054-
+ g.panel.timeSeries.options.withTooltip({
1055-
mode: 'single',
1056-
sort: 'none',
1057-
}),
1015+
+ g.panel.timeSeries.standardOptions.withOverrides([
1016+
g.panel.timeSeries.fieldOverride.byValue.new({op: 'gte', reducer: 'allIsZero', value: 0})
1017+
+ g.panel.timeSeries.fieldOverride.byValue.withProperty('custom.hideFrom', {legend: true, tooltip: true, viz: false}),
1018+
]),
10581019

10591020
searchAndIndexShardCountPanel:
10601021
g.panel.timeSeries.new('Shard count')

opensearch-mixin/signals/indexing.libsonnet

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ function(this)
161161
unit: 'bytes',
162162
sources: {
163163
prometheus: {
164-
expr: 'avg by(' + this.groupAggList + ') (opensearch_index_merges_current_size_bytes{%(queriesSelector)s, context="total"}) > 0',
164+
expr: 'avg by(' + this.groupAggList + ',index) (opensearch_index_merges_current_size_bytes{%(queriesSelectorGroupOnly)s,index=~"$index", context="total"}) > 0',
165+
legendCustomTemplate: '{{index}}',
165166
},
166167
},
167168
},
@@ -221,11 +222,15 @@ function(this)
221222
segments_memory_bytes: {
222223
name: 'Segments memory bytes',
223224
description: 'Segment memory usage.',
224-
type: 'raw',
225+
type: 'gauge',
226+
aggLevel: 'group',
227+
aggFunction: 'avg',
225228
unit: 'bytes',
226229
sources: {
227230
prometheus: {
228-
expr: 'avg by(' + this.groupAggList + ') (opensearch_index_segments_memory_bytes{%(queriesSelector)s, context="total"})',
231+
expr: 'opensearch_index_segments_memory_bytes{%(queriesSelectorGroupOnly)s,index=~"$index", context="total"}',
232+
legendCustomTemplate: '{{index}}',
233+
aggKeepLabels: ['index'],
229234
},
230235
},
231236
},

0 commit comments

Comments
 (0)