Skip to content

Commit

Permalink
Finish table panel
Browse files Browse the repository at this point in the history
Signed-off-by: Tom <[email protected]>
  • Loading branch information
critchtionary committed Oct 7, 2024
1 parent 9d57c11 commit 5cd5703
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 174 deletions.
1 change: 0 additions & 1 deletion docs/node-mixin/dashboards/use.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ local diskSpaceUtilisation =
),
} +
if $._config.showMultiCluster then {
// TODO - test thoroughly
'node-multicluster-rsrc-use.json':
dashboard.new(
'%sUSE Method / Multi-cluster' % $._config.dashboardNamePrefix,
Expand Down
286 changes: 113 additions & 173 deletions docs/node-mixin/lib/prom-mixin.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ local gaugeStep = gaugePanel.standardOptions.threshold.step;

local table = grafana.panel.table;
local tableStep = table.standardOptions.threshold.step;
local tableOverride = table.standardOptions.override;
local tableTransformation = table.queryOptions.transformation;

{

Expand Down Expand Up @@ -296,188 +298,126 @@ local tableStep = table.standardOptions.threshold.step;
]
)
+ table.queryOptions.withTargets([

]),
/* // TODO - here
.addTarget(prometheus.target(
|||
max by (mountpoint) (node_filesystem_size_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster", %(fsSelector)s, %(fsMountpointSelector)s})
||| % config,
legendFormat='',
instant=true,
format='table'
))
.addTarget(prometheus.target(
|||
max by (mountpoint) (node_filesystem_avail_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster", %(fsSelector)s, %(fsMountpointSelector)s})
||| % config,
legendFormat='',
instant=true,
format='table'
))
.addOverride(
matcher={
id: 'byName',
options: 'Mounted on',
},
properties=[
{
id: 'custom.width',
value: 260,
},
],
prometheus.new(
'$datasource',
|||
max by (mountpoint) (node_filesystem_size_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster", %(fsSelector)s, %(fsMountpointSelector)s})
||| % config
)
+ prometheus.withLegendFormat('')
+ prometheus.withInstant()
+ prometheus.withFormat('table'),
prometheus.new(
'$datasource',
|||
max by (mountpoint) (node_filesystem_avail_bytes{%(nodeExporterSelector)s, instance="$instance", %(clusterLabel)s="$cluster", %(fsSelector)s, %(fsMountpointSelector)s})
||| % config
)
+ prometheus.withLegendFormat('')
+ prometheus.withInstant()
+ prometheus.withFormat('table'),
])
+ table.standardOptions.withOverrides([
tableOverride.byName.new('Mounted on')
+ tableOverride.byName.withProperty('custom.width', 260),
tableOverride.byName.new('Size')
+ tableOverride.byName.withProperty('custom.width', 93),
tableOverride.byName.new('Used')
+ tableOverride.byName.withProperty('custom.width', 72),
tableOverride.byName.new('Available')
+ tableOverride.byName.withProperty('custom.width', 88),
tableOverride.byName.new('Used, %')
+ tableOverride.byName.withProperty('unit', 'percentunit')
+ tableOverride.byName.withPropertiesFromOptions(
table.fieldConfig.defaults.custom.withCellOptions(
{ type: 'gauge' },
)
.addOverride(
matcher={
id: 'byName',
options: 'Size',
},
properties=[
{
id: 'custom.width',
value: 93,
)
+ tableOverride.byName.withProperty('max', 1)
+ tableOverride.byName.withProperty('min', 0),
])
+ table.queryOptions.withTransformations([
tableTransformation.withId('groupBy')
+ tableTransformation.withOptions(
{
fields: {
'Value #A': {
aggregations: [
'lastNotNull',
],
operation: 'aggregate',
},
],
)
.addOverride(
matcher={
id: 'byName',
options: 'Used',
},
properties=[
{
id: 'custom.width',
value: 72,
'Value #B': {
aggregations: [
'lastNotNull',
],
operation: 'aggregate',
},
],
)
.addOverride(
matcher={
id: 'byName',
options: 'Available',
},
properties=[
{
id: 'custom.width',
value: 88,
mountpoint: {
aggregations: [],
operation: 'groupby',
},
],
)
.addOverride(
matcher={
id: 'byName',
options: 'Used, %',
},
properties=[
{
id: 'unit',
value: 'percentunit',
},
{
id: 'custom.displayMode',
value: 'gradient-gauge',
},
{
id: 'max',
value: 1,
},
{
id: 'min',
value: 0,
},
]
)
+ { span: 6 }
+ {
transformations: [
{
id: 'groupBy',
options: {
fields: {
'Value #A': {
aggregations: [
'lastNotNull',
],
operation: 'aggregate',
},
'Value #B': {
aggregations: [
'lastNotNull',
],
operation: 'aggregate',
},
mountpoint: {
aggregations: [],
operation: 'groupby',
},
},
},
},
{
id: 'merge',
options: {},
},
{
id: 'calculateField',
options: {
alias: 'Used',
binary: {
left: 'Value #A (lastNotNull)',
operator: '-',
reducer: 'sum',
right: 'Value #B (lastNotNull)',
},
mode: 'binary',
reduce: {
reducer: 'sum',
},
},
},
{
id: 'calculateField',
options: {
alias: 'Used, %',
binary: {
left: 'Used',
operator: '/',
reducer: 'sum',
right: 'Value #A (lastNotNull)',
},
mode: 'binary',
reduce: {
reducer: 'sum',
},
},
},
{
id: 'organize',
options: {
excludeByName: {},
indexByName: {},
renameByName: {
'Value #A (lastNotNull)': 'Size',
'Value #B (lastNotNull)': 'Available',
mountpoint: 'Mounted on',
},
},
},
}
),
tableTransformation.withId('merge'),
tableTransformation.withId('calculateField')
+ tableTransformation.withOptions(
{
alias: 'Used',
binary: {
left: 'Value #A (lastNotNull)',
operator: '-',
reducer: 'sum',
right: 'Value #B (lastNotNull)',
},
mode: 'binary',
reduce: {
reducer: 'sum',
},
}
),
tableTransformation.withId('calculateField')
+ tableTransformation.withOptions(
{
alias: 'Used, %',
binary: {
left: 'Used',
operator: '/',
reducer: 'sum',
right: 'Value #A (lastNotNull)',
},
mode: 'binary',
reduce: {
reducer: 'sum',
},
}
),
tableTransformation.withId('organize')
+ tableTransformation.withOptions(
{
excludeByName: {},
indexByName: {},
renameByName: {
'Value #A (lastNotNull)': 'Size',
'Value #B (lastNotNull)': 'Available',
mountpoint: 'Mounted on',
},
}
),
tableTransformation.withId('sortBy')
+ tableTransformation.withOptions(
{
fields: {},
sort: [
{
id: 'sortBy',
options: {
fields: {},
sort: [
{
field: 'Mounted on',
},
],
},
field: 'Mounted on',
},
],
}, */
}
),

]),

local networkReceived =
timeSeriesPanel.new('Network Received')
Expand Down

0 comments on commit 5cd5703

Please sign in to comment.