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
c9327288
Commit
c9327288
authored
1 year ago
by
Christoph Alt
Browse files
Options
Downloads
Patches
Plain Diff
added thresholds for panels
parent
25a3bedc
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dashboards/panels.py
+26
-6
26 additions, 6 deletions
dashboards/panels.py
with
26 additions
and
6 deletions
dashboards/panels.py
+
26
−
6
View file @
c9327288
from
collections
import
namedtuple
from
dataclasses
import
dataclass
,
field
# from collections import namedtuple
from
dashboards.influx_queries
import
Query
from
grafanalib.core
import
TimeSeries
,
Text
,
Stat
,
Template
,
Repeat
,
Threshold
from
dashboards.dashboard_base
import
get_influx_target
from
dashboards.legends
import
Units
from
numbers
import
Number
PanelInfos
=
namedtuple
(
"
PanelInfos
"
,
(
"
name
"
,
"
unit
"
))
#
PanelInfos = namedtuple("PanelInfos", ("name", "unit"))
def
get_time_series_panel
(
field
:
PanelInfos
,
@dataclass
class
PanelInfos
:
name
:
str
unit
:
Units
absthreshold
:
Number
=
field
(
default
=
None
)
def
get_time_series_panel
(
panel_infos
:
PanelInfos
,
data_source
:
str
,
measurment_name
:
str
,
*
,
...
...
@@ -16,19 +26,29 @@ def get_time_series_panel(field: PanelInfos,
is_regex
=
False
if
measurment_name
[
0
]
==
'
/
'
and
measurment_name
[
-
1
]
==
'
/
'
:
is_regex
=
True
query
=
Query
(
select_
=
field
.
name
,
query
=
Query
(
select_
=
panel_infos
.
name
,
from_
=
measurment_name
,
where_
=
where
,
group_by
=
group_by
,
from_string
=
not
is_regex
)
kwargs
=
{}
if
panel_infos
.
absthreshold
is
not
None
:
kwargs
.
update
({
'
thresholdType
'
:
'
absolute
'
,
'
thresholds
'
:
[
Threshold
(
'
green
'
,
0
,
0.0
),
Threshold
(
'
red
'
,
index
=
1
,
value
=
float
(
panel_infos
.
absthreshold
),
op
=
'
lt
'
),
],
'
thresholdsStyleMode
'
:
'
line
'
,
}
)
return
TimeSeries
(
title
=
field
.
name
,
title
=
panel_infos
.
name
,
dataSource
=
data_source
,
targets
=
[
get_influx_target
(
str
(
query
))],
unit
=
field
.
unit
,
unit
=
panel_infos
.
unit
,
pointSize
=
9
,
overrides
=
overrides
,
**
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