Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
controller
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TFS
controller
Commits
f4b549f7
Commit
f4b549f7
authored
1 year ago
by
Waleed Akbar
Browse files
Options
Downloads
Patches
Plain Diff
All KPI tags are added with metric.
parent
d120ce74
No related branches found
No related tags found
2 merge requests
!294
Release TeraFlowSDN 4.0
,
!207
Resolve "(CTTC) Separation of Monitoring"
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/kpi_manager/service/KpiValueComposer.py
+1
-1
1 addition, 1 deletion
src/kpi_manager/service/KpiValueComposer.py
src/kpi_manager/service/KpiWriter.py
+13
-6
13 additions, 6 deletions
src/kpi_manager/service/KpiWriter.py
with
14 additions
and
7 deletions
src/kpi_manager/service/KpiValueComposer.py
+
1
−
1
View file @
f4b549f7
...
...
@@ -86,7 +86,7 @@ class KpiValueComposer:
sub_names
=
kpi_value
=
""
for
line
in
lines
:
try
:
if
pattern
.
search
(
line
)
and
not
line
.
startswith
(
"
# HELP
"
)
and
not
line
.
startswith
(
"
# TYPE
"
):
if
pattern
.
search
(
line
)
and
not
line
.
startswith
(
"
# HELP
"
)
and
not
line
.
startswith
(
"
# TYPE
"
)
and
not
'
device=
"
lo
"'
in
line
:
(
kpi_name
,
kpi_value
)
=
line
.
split
(
"
"
)
if
kpi_name
.
endswith
(
'
}
'
):
(
kpi_name
,
sub_names
)
=
kpi_name
.
replace
(
'
}
'
,
''
).
split
(
'
{
'
)
...
...
This diff is collapsed.
Click to expand it.
src/kpi_manager/service/KpiWriter.py
+
13
−
6
View file @
f4b549f7
...
...
@@ -76,18 +76,25 @@ class KpiWriter:
@staticmethod
def
write_metric_to_promtheus
(
event
):
event
=
ast
.
literal_eval
(
event
)
# converted into dict
print
(
"
New recevied event: {:}
"
.
format
(
event
[
'
kpi_description
'
]
))
print
(
"
New recevied event: {:}
"
.
format
(
event
))
event_kpi_name
=
event
[
'
kpi_description
'
]
if
event_kpi_name
in
KPIs_TO_SEARCH
:
PROM_METRICS
[
event_kpi_name
].
labels
(
tag1
=
"
test tag value
"
,
tag2
=
"
test tag value
"
).
set
(
event
[
'
kpi_value
'
])
kpi_id
=
event
[
'
kpi_id
'
],
kpi_sample_type
=
event
[
'
kpi_sample_type
'
],
device_id
=
event
[
'
device_id
'
],
endpoint_id
=
event
[
'
endpoint_id
'
],
service_id
=
event
[
'
service_id
'
],
slice_id
=
event
[
'
slice_id
'
],
connection_id
=
event
[
'
connection_id
'
],
link_id
=
event
[
'
link_id
'
]
).
set
(
float
(
event
[
'
kpi_value
'
]))
time
.
sleep
(
0.05
)
@staticmethod
def
create_prom_metrics_name
():
metric_tags
=
[
"
tag1
"
,
"
tag2
"
]
metric_tags
=
[
'
kpi_id
'
,
'
kpi_sample_type
'
,
'
device_id
'
,
'
endpoint_id
'
,
'
service_id
'
,
'
slice_id
'
,
'
connection_id
'
,
'
link_id
'
]
for
metric_key
in
KPIs_TO_SEARCH
:
metric_name
=
metric_key
metric_description
=
"
description of
"
+
str
(
metric_key
)
...
...
@@ -95,7 +102,7 @@ class KpiWriter:
PROM_METRICS
[
metric_key
]
=
Gauge
(
metric_name
,
metric_description
,
metric_tags
,
registry
=
KAFKA_REGISTERY
)
print
(
"
Metric pushed to Prometheus: {:}
"
.
format
(
PROM_METRICS
[
metric_key
]))
#
print("Metric pushed to Prometheus: {:}".format(PROM_METRICS[metric_key]))
except
ValueError
as
e
:
if
'
Duplicated timeseries
'
in
str
(
e
):
print
(
"
Metric {:} is already registered. Skipping.
"
.
format
(
metric_name
))
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