Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cb-util
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christoph Alt
cb-util
Commits
2d5ee54b
Commit
2d5ee54b
authored
10 months ago
by
Christoph Alt
Browse files
Options
Downloads
Patches
Plain Diff
removed more occurances of lower cased list
parent
17a6c3b6
No related branches found
No related tags found
1 merge request
!11
Adding Dashboards for Percolation and for the roofline dashboard
Pipeline
#68841
passed
10 months ago
Stage: test
Stage: deploy
Stage: trigger
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dashboards/panels.py
+185
-115
185 additions, 115 deletions
dashboards/panels.py
with
185 additions
and
115 deletions
dashboards/panels.py
+
185
−
115
View file @
2d5ee54b
from
dataclasses
import
dataclass
,
field
from
dataclasses
import
dataclass
,
field
# from collections import namedtuple
# from collections import namedtuple
from
dashboards.influx_queries
import
Query
from
dashboards.influx_queries
import
Query
from
grafanalib.core
import
TimeSeries
,
Text
,
Stat
,
Template
,
Repeat
,
Threshold
,
Table
,
BarChart
,
PieChartv2
from
grafanalib.core
import
(
TimeSeries
,
Text
,
Stat
,
Template
,
Repeat
,
Threshold
,
Table
,
BarChart
,
PieChartv2
,
)
from
dashboards.dashboard_base
import
get_influx_target
from
dashboards.dashboard_base
import
get_influx_target
from
dashboards.legends
import
Units
from
dashboards.legends
import
Units
from
numbers
import
Number
from
numbers
import
Number
from
typing
import
List
# PanelInfos = namedtuple("PanelInfos", ("name", "unit"))
# PanelInfos = namedtuple("PanelInfos", ("name", "unit"))
...
@@ -20,30 +32,49 @@ def is_regex(name):
...
@@ -20,30 +32,49 @@ def is_regex(name):
return
name
[
0
]
==
"
/
"
and
name
[
-
1
]
==
"
/
"
return
name
[
0
]
==
"
/
"
and
name
[
-
1
]
==
"
/
"
def
get_time_series_panel
(
panel_infos
:
PanelInfos
,
def
get_time_series_panel
(
data_source
:
str
,
panel_infos
:
PanelInfos
,
query_list
:
list
[
Query
],
data_source
:
str
,
*
,
query_list
:
List
[
Query
],
overrides
=
None
,
*
,
pointSize
:
int
=
9
,
overrides
=
None
,
**
kwargs
):
pointSize
:
int
=
9
,
**
kwargs
,
):
targets
=
[
get_influx_target
(
str
(
query
))
for
query
in
query_list
]
targets
=
[
get_influx_target
(
str
(
query
))
for
query
in
query_list
]
new_kwargs
=
{
**
kwargs
}
new_kwargs
=
{
**
kwargs
}
if
panel_infos
.
absthreshold
is
not
None
:
if
panel_infos
.
absthreshold
is
not
None
:
if
'
thresholdsStyleMode
'
not
in
new_kwargs
:
if
"
thresholdsStyleMode
"
not
in
new_kwargs
:
new_kwargs
.
update
({
new_kwargs
.
update
(
'
thresholdType
'
:
'
absolute
'
,
{
'
thresholds
'
:
[
Threshold
(
'
green
'
,
0
,
0.0
),
"
thresholdType
"
:
"
absolute
"
,
Threshold
(
'
red
'
,
index
=
1
,
value
=
float
(
panel_infos
.
absthreshold
),
op
=
'
lt
'
)],
"
thresholds
"
:
[
'
thresholdsStyleMode
'
:
'
line
'
Threshold
(
"
green
"
,
0
,
0.0
),
})
Threshold
(
"
red
"
,
index
=
1
,
value
=
float
(
panel_infos
.
absthreshold
),
op
=
"
lt
"
,
),
],
"
thresholdsStyleMode
"
:
"
line
"
,
}
)
else
:
else
:
new_kwargs
.
update
({
new_kwargs
.
update
(
'
thresholdType
'
:
'
absolute
'
,
{
'
thresholds
'
:
[
Threshold
(
'
green
'
,
0
,
0.0
),
"
thresholdType
"
:
"
absolute
"
,
Threshold
(
'
red
'
,
index
=
1
,
value
=
float
(
panel_infos
.
absthreshold
),
op
=
'
lt
'
)]
"
thresholds
"
:
[
})
Threshold
(
"
green
"
,
0
,
0.0
),
Threshold
(
"
red
"
,
index
=
1
,
value
=
float
(
panel_infos
.
absthreshold
),
op
=
"
lt
"
,
),
],
}
)
return
TimeSeries
(
return
TimeSeries
(
title
=
panel_infos
.
name
,
title
=
panel_infos
.
name
,
...
@@ -53,71 +84,85 @@ def get_time_series_panel(panel_infos: PanelInfos,
...
@@ -53,71 +84,85 @@ def get_time_series_panel(panel_infos: PanelInfos,
pointSize
=
pointSize
,
pointSize
=
pointSize
,
overrides
=
overrides
,
overrides
=
overrides
,
**
new_kwargs
,
**
new_kwargs
,
)
)
def
get_text_panel
(
content
:
str
,
*
,
mode
=
'
markdown
'
,
**
kwargs
)
->
Text
:
def
get_text_panel
(
content
:
str
,
*
,
mode
=
"
markdown
"
,
**
kwargs
)
->
Text
:
return
Text
(
return
Text
(
content
=
content
,
mode
=
mode
,
**
kwargs
)
content
=
content
,
mode
=
mode
,
**
kwargs
)
def
get_stat_panel
(
title
:
str
,
def
get_stat_panel
(
dataSource
:
str
,
title
:
str
,
stat_query
:
Query
,
dataSource
:
str
,
repeat
:
Template
=
None
,
stat_query
:
Query
,
alias
:
str
=
""
,
repeat
:
Template
=
None
,
*
,
alias
:
str
=
""
,
maxPerRow
=
0
,
*
,
**
kwargs
):
maxPerRow
=
0
,
**
kwargs
,
):
new_kwargs
=
{
new_kwargs
=
{
'
alignment
'
:
'
center
'
,
"
alignment
"
:
"
center
"
,
'
colorMode
'
:
'
value
'
,
"
colorMode
"
:
"
value
"
,
'
graphMode
'
:
'
area
'
,
"
graphMode
"
:
"
area
"
,
'
reduceCalc
'
:
'
last
'
,
"
reduceCalc
"
:
"
last
"
,
'
orientation
'
:
'
auto
'
,
"
orientation
"
:
"
auto
"
,
'
transparent
'
:
True
,
"
transparent
"
:
True
,
}
}
new_kwargs
.
update
(
kwargs
)
new_kwargs
.
update
(
kwargs
)
if
repeat
:
if
repeat
:
rep_args
=
[
'
h
'
,
repeat
.
name
]
rep_args
=
[
"
h
"
,
repeat
.
name
]
if
maxPerRow
:
if
maxPerRow
:
rep_args
.
append
(
maxPerRow
)
rep_args
.
append
(
maxPerRow
)
new_kwargs
.
setdefault
(
'
repeat
'
,
Repeat
(
*
rep_args
))
new_kwargs
.
setdefault
(
"
repeat
"
,
Repeat
(
*
rep_args
))
return
Stat
(
return
Stat
(
title
=
title
,
title
=
title
,
dataSource
=
dataSource
,
dataSource
=
dataSource
,
targets
=
[
get_influx_target
(
str
(
stat_query
),
alias
=
alias
)],
targets
=
[
get_influx_target
(
str
(
stat_query
),
alias
=
alias
)],
thresholdType
=
'
percentage
'
,
thresholdType
=
"
percentage
"
,
thresholds
=
[
Threshold
(
'
green
'
,
0
,
0.0
),
Threshold
(
'
yellow
'
,
1
,
50.0
),
Threshold
(
'
red
'
,
2
,
80.0
)],
thresholds
=
[
**
new_kwargs
,
Threshold
(
"
green
"
,
0
,
0.0
),
Threshold
(
"
yellow
"
,
1
,
50.0
),
Threshold
(
"
red
"
,
2
,
80.0
),
],
**
new_kwargs
,
)
)
def
get_table_panel
(
panel_infos
:
PanelInfos
,
def
get_table_panel
(
data_source
:
str
,
panel_infos
:
PanelInfos
,
query_list
:
list
[
Query
],
data_source
:
str
,
*
,
query_list
:
List
[
Query
],
result_format_list
:
list
[
str
]
=
None
,
*
,
alias_list
:
list
[
str
]
=
None
,
result_format_list
:
List
[
str
]
=
None
,
transformations
=
[],
alias_list
:
List
[
str
]
=
None
,
overrides
=
None
,
transformations
=
[],
**
kwargs
):
overrides
=
None
,
**
kwargs
,
):
if
not
alias_list
:
if
not
alias_list
:
alias_list
=
[
''
]
*
len
(
query_list
)
alias_list
=
[
""
]
*
len
(
query_list
)
if
not
result_format_list
:
if
not
result_format_list
:
result_format_list
=
[
'
table
'
]
*
len
(
query_list
)
result_format_list
=
[
"
table
"
]
*
len
(
query_list
)
targets
=
[
get_influx_target
(
str
(
query
),
result_format
=
result_format
,
alias
=
alias
)
for
query
,
result_format
,
alias
in
zip
(
query_list
,
result_format_list
,
alias_list
)]
targets
=
[
get_influx_target
(
str
(
query
),
result_format
=
result_format
,
alias
=
alias
)
for
query
,
result_format
,
alias
in
zip
(
query_list
,
result_format_list
,
alias_list
)
]
new_kwargs
=
{
**
kwargs
}
new_kwargs
=
{
**
kwargs
}
if
panel_infos
.
absthreshold
is
not
None
:
if
panel_infos
.
absthreshold
is
not
None
:
new_kwargs
.
update
({
'
thresholdType
'
:
'
absolute
'
,
new_kwargs
.
update
(
'
thresholds
'
:
[
Threshold
(
'
green
'
,
0
,
0.0
),
{
Threshold
(
'
red
'
,
index
=
1
,
value
=
float
(
panel_infos
.
absthreshold
),
op
=
'
lt
'
),
],
"
thresholdType
"
:
"
absolute
"
,
}
"
thresholds
"
:
[
)
Threshold
(
"
green
"
,
0
,
0.0
),
Threshold
(
"
red
"
,
index
=
1
,
value
=
float
(
panel_infos
.
absthreshold
),
op
=
"
lt
"
),
],
}
)
return
Table
(
return
Table
(
title
=
panel_infos
.
name
,
title
=
panel_infos
.
name
,
...
@@ -127,80 +172,106 @@ def get_table_panel(panel_infos: PanelInfos,
...
@@ -127,80 +172,106 @@ def get_table_panel(panel_infos: PanelInfos,
unit
=
panel_infos
.
unit
,
unit
=
panel_infos
.
unit
,
overrides
=
overrides
,
overrides
=
overrides
,
**
new_kwargs
,
**
new_kwargs
,
)
)
def
get_bar_chart_panel
(
panel_infos
:
PanelInfos
,
def
get_bar_chart_panel
(
data_source
:
str
,
panel_infos
:
PanelInfos
,
query_list
:
list
[
Query
],
data_source
:
str
,
*
,
query_list
:
List
[
Query
],
result_format_list
:
list
[
str
]
=
None
,
*
,
alias_list
:
list
[
str
]
=
None
,
result_format_list
:
List
[
str
]
=
None
,
transformations
=
[],
alias_list
:
List
[
str
]
=
None
,
overrides
=
None
,
transformations
=
[],
**
kwargs
):
overrides
=
None
,
**
kwargs
,
):
if
not
alias_list
:
if
not
alias_list
:
alias_list
=
[
''
]
*
len
(
query_list
)
alias_list
=
[
""
]
*
len
(
query_list
)
if
not
result_format_list
:
if
not
result_format_list
:
result_format_list
=
[
'
table
'
]
*
len
(
query_list
)
result_format_list
=
[
"
table
"
]
*
len
(
query_list
)
targets
=
[
get_influx_target
(
str
(
query
),
result_format
=
result_format
,
alias
=
alias
)
for
query
,
result_format
,
alias
in
zip
(
query_list
,
result_format_list
,
alias_list
)]
targets
=
[
get_influx_target
(
str
(
query
),
result_format
=
result_format
,
alias
=
alias
)
for
query
,
result_format
,
alias
in
zip
(
query_list
,
result_format_list
,
alias_list
)
]
new_kwargs
=
{
**
kwargs
}
new_kwargs
=
{
**
kwargs
}
if
panel_infos
.
absthreshold
is
not
None
:
if
panel_infos
.
absthreshold
is
not
None
:
new_kwargs
.
update
({
'
thresholdType
'
:
'
absolute
'
,
new_kwargs
.
update
(
'
thresholds
'
:
[
Threshold
(
'
green
'
,
0
,
0.0
),
{
Threshold
(
'
red
'
,
index
=
1
,
value
=
float
(
panel_infos
.
absthreshold
),
op
=
'
lt
'
),
],
"
thresholdType
"
:
"
absolute
"
,
}
"
thresholds
"
:
[
)
Threshold
(
"
green
"
,
0
,
0.0
),
extraJson
=
{
"
fieldConfig
"
:
{
Threshold
(
"
defaults
"
:
{
"
red
"
,
index
=
1
,
value
=
float
(
panel_infos
.
absthreshold
),
op
=
"
lt
"
"
fieldMinMax
"
:
True
,
),
"
max
"
:
1
,
],
"
unit
"
:
panel_infos
.
unit
}
)
extraJson
=
{
"
fieldConfig
"
:
{
"
defaults
"
:
{
"
fieldMinMax
"
:
True
,
"
max
"
:
1
,
"
unit
"
:
panel_infos
.
unit
}
}
}
}
}
}
return
BarChart
(
return
BarChart
(
title
=
panel_infos
.
name
,
title
=
panel_infos
.
name
,
dataSource
=
data_source
,
dataSource
=
data_source
,
targets
=
targets
,
targets
=
targets
,
transformations
=
transformations
,
transformations
=
transformations
,
xTickLabelRotation
=-
45
,
xTickLabelRotation
=-
45
,
extraJson
=
extraJson
,
extraJson
=
extraJson
,
**
new_kwargs
,
**
new_kwargs
,
)
)
def
get_pie_chart_panel
(
panel_infos
:
PanelInfos
,
def
get_pie_chart_panel
(
data_source
:
str
,
panel_infos
:
PanelInfos
,
query_list
:
list
[
Query
],
data_source
:
str
,
*
,
query_list
:
List
[
Query
],
result_format_list
:
list
[
str
]
=
None
,
*
,
alias_list
:
list
[
str
]
=
None
,
result_format_list
:
List
[
str
]
=
None
,
transformations
=
[],
alias_list
:
List
[
str
]
=
None
,
overrides
=
[],
transformations
=
[],
**
kwargs
):
overrides
=
[],
**
kwargs
,
):
targets
=
[
get_influx_target
(
str
(
query
))
for
query
in
query_list
]
targets
=
[
get_influx_target
(
str
(
query
))
for
query
in
query_list
]
new_kwargs
=
{
**
kwargs
}
new_kwargs
=
{
**
kwargs
}
if
panel_infos
.
absthreshold
is
not
None
:
if
panel_infos
.
absthreshold
is
not
None
:
if
'
thresholdsStyleMode
'
not
in
new_kwargs
:
if
"
thresholdsStyleMode
"
not
in
new_kwargs
:
new_kwargs
.
update
({
new_kwargs
.
update
(
'
thresholdType
'
:
'
absolute
'
,
{
'
thresholds
'
:
[
Threshold
(
'
green
'
,
0
,
0.0
),
"
thresholdType
"
:
"
absolute
"
,
Threshold
(
'
red
'
,
index
=
1
,
value
=
float
(
panel_infos
.
absthreshold
),
op
=
'
lt
'
)],
"
thresholds
"
:
[
'
thresholdsStyleMode
'
:
'
line
'
Threshold
(
"
green
"
,
0
,
0.0
),
})
Threshold
(
"
red
"
,
index
=
1
,
value
=
float
(
panel_infos
.
absthreshold
),
op
=
"
lt
"
,
),
],
"
thresholdsStyleMode
"
:
"
line
"
,
}
)
else
:
else
:
new_kwargs
.
update
({
new_kwargs
.
update
(
'
thresholdType
'
:
'
absolute
'
,
{
'
thresholds
'
:
[
Threshold
(
'
green
'
,
0
,
0.0
),
"
thresholdType
"
:
"
absolute
"
,
Threshold
(
'
red
'
,
index
=
1
,
value
=
float
(
panel_infos
.
absthreshold
),
op
=
'
lt
'
)]
"
thresholds
"
:
[
})
Threshold
(
"
green
"
,
0
,
0.0
),
Threshold
(
"
red
"
,
index
=
1
,
value
=
float
(
panel_infos
.
absthreshold
),
op
=
"
lt
"
,
),
],
}
)
return
PieChartv2
(
return
PieChartv2
(
title
=
panel_infos
.
name
,
title
=
panel_infos
.
name
,
dataSource
=
data_source
,
dataSource
=
data_source
,
...
@@ -209,5 +280,4 @@ def get_pie_chart_panel(panel_infos: PanelInfos,
...
@@ -209,5 +280,4 @@ def get_pie_chart_panel(panel_infos: PanelInfos,
unit
=
panel_infos
.
unit
,
unit
=
panel_infos
.
unit
,
overrides
=
overrides
,
overrides
=
overrides
,
**
new_kwargs
,
**
new_kwargs
,
)
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment