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
1d72c20d
Commit
1d72c20d
authored
2 years ago
by
Javier Moreno
Browse files
Options
Downloads
Patches
Plain Diff
Changes in the IncludeKpi Method
parent
3a1c47f0
No related branches found
No related tags found
2 merge requests
!5
Feat/monitoring subscriptions
,
!4
Compute component:
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
proto/monitoring.proto
+1
-1
1 addition, 1 deletion
proto/monitoring.proto
src/monitoring/service/MonitoringServiceServicerImpl.py
+28
-19
28 additions, 19 deletions
src/monitoring/service/MonitoringServiceServicerImpl.py
with
29 additions
and
20 deletions
proto/monitoring.proto
+
1
−
1
View file @
1d72c20d
...
@@ -99,7 +99,7 @@ message KpiValue {
...
@@ -99,7 +99,7 @@ message KpiValue {
message
KpiList
{
message
KpiList
{
repeated
Kpi
kpi
_list
=
1
;
repeated
Kpi
kpi
=
1
;
}
}
message
KpiDescriptorList
{
message
KpiDescriptorList
{
...
...
This diff is collapsed.
Click to expand it.
src/monitoring/service/MonitoringServiceServicerImpl.py
+
28
−
19
View file @
1d72c20d
...
@@ -28,6 +28,7 @@ from common.proto.monitoring_pb2 import AlarmResponse, AlarmDescriptor, AlarmLis
...
@@ -28,6 +28,7 @@ from common.proto.monitoring_pb2 import AlarmResponse, AlarmDescriptor, AlarmLis
KpiDescriptor
,
KpiList
,
KpiQuery
,
SubsDescriptor
,
SubscriptionID
,
AlarmID
,
KpiDescriptorList
,
\
KpiDescriptor
,
KpiList
,
KpiQuery
,
SubsDescriptor
,
SubscriptionID
,
AlarmID
,
KpiDescriptorList
,
\
MonitorKpiRequest
,
Kpi
,
AlarmSubscription
,
SubsResponse
MonitorKpiRequest
,
Kpi
,
AlarmSubscription
,
SubsResponse
from
common.rpc_method_wrapper.ServiceExceptions
import
ServiceException
from
common.rpc_method_wrapper.ServiceExceptions
import
ServiceException
from
common.tools.timestamp.Converters
import
timestamp_string_to_float
from
monitoring.service
import
ManagementDBTools
,
MetricsDBTools
from
monitoring.service
import
ManagementDBTools
,
MetricsDBTools
from
device.client.DeviceClient
import
DeviceClient
from
device.client.DeviceClient
import
DeviceClient
...
@@ -153,23 +154,23 @@ class MonitoringServiceServicerImpl(MonitoringServiceServicer):
...
@@ -153,23 +154,23 @@ class MonitoringServiceServicerImpl(MonitoringServiceServicer):
try
:
try
:
kpiDescriptor
=
self
.
GetKpiDescriptor
(
request
.
kpi_id
,
grpc_context
)
kpiDescriptor
=
self
.
GetKpiDescriptor
(
request
.
kpi_id
,
grpc_context
)
if
kpiDescriptor
is
None
:
if
kpiDescriptor
is
None
:
LOGGER
.
warning
(
'
Ignoring sample with KPIId({:s}): not found in database
'
.
format
(
str
(
request
.
kpi_id
)))
raise
Exception
(
LOGGER
.
exception
(
'
IncludeKpi exception: Sample with KPIId({:s}): not found in database
'
.
format
(
str
(
request
.
kpi_id
))))
else
:
kpiSampleType
=
KpiSampleType
.
Name
(
kpiDescriptor
.
kpi_sample_type
).
upper
().
replace
(
'
KPISAMPLETYPE_
'
,
''
)
kpiId
=
request
.
kpi_id
.
kpi_id
.
uuid
deviceId
=
kpiDescriptor
.
device_id
.
device_uuid
.
uuid
endpointId
=
kpiDescriptor
.
endpoint_id
.
endpoint_uuid
.
uuid
serviceId
=
kpiDescriptor
.
service_id
.
service_uuid
.
uuid
time_stamp
=
request
.
timestamp
.
timestamp
kpi_value
=
getattr
(
request
.
kpi_value
,
request
.
kpi_value
.
WhichOneof
(
'
value
'
))
# Build the structure to be included as point in the MetricsDB
self
.
metrics_db
.
write_KPI
(
time_stamp
,
kpiId
,
kpiSampleType
,
deviceId
,
endpointId
,
serviceId
,
kpi_value
)
#self.influx_db.read_KPI_points()
return
Empty
()
return
Empty
()
kpiSampleType
=
KpiSampleType
.
Name
(
kpiDescriptor
.
kpi_sample_type
).
upper
().
replace
(
'
KPISAMPLETYPE_
'
,
''
)
kpiId
=
request
.
kpi_id
.
kpi_id
.
uuid
deviceId
=
kpiDescriptor
.
device_id
.
device_uuid
.
uuid
endpointId
=
kpiDescriptor
.
endpoint_id
.
endpoint_uuid
.
uuid
serviceId
=
kpiDescriptor
.
service_id
.
service_uuid
.
uuid
time_stamp
=
request
.
timestamp
.
timestamp
kpi_value
=
getattr
(
request
.
kpi_value
,
request
.
kpi_value
.
WhichOneof
(
'
value
'
))
# Build the structure to be included as point in the MetricsDB
self
.
metrics_db
.
write_KPI
(
time_stamp
,
kpiId
,
kpiSampleType
,
deviceId
,
endpointId
,
serviceId
,
kpi_value
)
#self.influx_db.read_KPI_points()
except
ServiceException
as
e
:
except
ServiceException
as
e
:
LOGGER
.
exception
(
'
IncludeKpi exception
'
)
LOGGER
.
exception
(
'
IncludeKpi exception
'
)
# CREATEKPI_COUNTER_FAILED.inc()
# CREATEKPI_COUNTER_FAILED.inc()
...
@@ -177,7 +178,7 @@ class MonitoringServiceServicerImpl(MonitoringServiceServicer):
...
@@ -177,7 +178,7 @@ class MonitoringServiceServicerImpl(MonitoringServiceServicer):
except
Exception
:
# pragma: no cover
except
Exception
:
# pragma: no cover
LOGGER
.
exception
(
'
IncludeKpi exception
'
)
LOGGER
.
exception
(
'
IncludeKpi exception
'
)
# CREATEKPI_COUNTER_FAILED.inc()
# CREATEKPI_COUNTER_FAILED.inc()
return
Empty
()
# rpc MonitorKpi (MonitorKpiRequest) returns (context.Empty) {}
# rpc MonitorKpi (MonitorKpiRequest) returns (context.Empty) {}
def
MonitorKpi
(
self
,
request
:
MonitorKpiRequest
,
grpc_context
:
grpc
.
ServicerContext
)
->
Empty
:
def
MonitorKpi
(
self
,
request
:
MonitorKpiRequest
,
grpc_context
:
grpc
.
ServicerContext
)
->
Empty
:
...
@@ -235,14 +236,22 @@ class MonitoringServiceServicerImpl(MonitoringServiceServicer):
...
@@ -235,14 +236,22 @@ class MonitoringServiceServicerImpl(MonitoringServiceServicer):
start_timestamp
=
request
.
start_timestamp
.
timestamp
start_timestamp
=
request
.
start_timestamp
.
timestamp
end_timestamp
=
request
.
end_timestamp
.
timestamp
end_timestamp
=
request
.
end_timestamp
.
timestamp
subscriber
=
"
localhost
"
subscriber
=
"
localhost
"
# Investigate how to get info from the requester
subs_id
=
self
.
management_db
.
insert_subscription
(
kpi_id
,
subscriber
,
sampling_duration_s
,
sampling_interval_s
,
start_timestamp
,
end_timestamp
)
subs_id
=
self
.
management_db
.
insert_subscription
(
kpi_id
,
subscriber
,
sampling_duration_s
,
sampling_interval_s
,
start_timestamp
,
end_timestamp
)
self
.
subs_manager
.
create_subscription
(
subs_id
,
kpi_id
,
sampling_
duration
_s
,
sampling_
interval
_s
,
start_timestamp
,
end_timestamp
)
self
.
subs_manager
.
create_subscription
(
subs_
queue
,
subs_
id
,
kpi_id
,
sampling_
interval
_s
,
sampling_
duration
_s
,
start_timestamp
,
end_timestamp
)
# parse queue to append kpis into the list
# parse queue to append kpis into the list
while
not
subs_queue
.
empty
():
list
=
subs_queue
.
get_nowait
()
for
item
in
list
:
kpi
=
kpi
.
kpi_id
.
kpi_id
.
uuid
=
item
[
0
]
kpi
.
timestamp
.
timestamp
=
timestamp_string_to_float
(
item
[
1
])
kpi
.
kpi_value
.
floatVal
=
item
[
2
]
# This must be improved
subs_response
.
kpi_list
.
kpi
.
append
(
kpi
)
subs_response
.
subs_id
.
subs_id
.
uuid
=
subs_id
# TBC
yield
subs_response
yield
subs_response
except
ServiceException
as
e
:
except
ServiceException
as
e
:
LOGGER
.
exception
(
'
SubscribeKpi exception
'
)
LOGGER
.
exception
(
'
SubscribeKpi exception
'
)
...
...
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