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
d646caf9
Commit
d646caf9
authored
2 years ago
by
Carlos Natalino Da Silva
Browse files
Options
Downloads
Plain Diff
Merge branch 'feat/monitoring' into fix/ofc22-tests
parents
2dcc49de
c2b7ad7d
No related branches found
No related tags found
1 merge request
!54
Release 2.0.0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+3
-0
3 additions, 0 deletions
.gitignore
src/monitoring/.gitlab-ci.yml
+1
-1
1 addition, 1 deletion
src/monitoring/.gitlab-ci.yml
src/monitoring/service/MetricsDBTools.py
+17
-6
17 additions, 6 deletions
src/monitoring/service/MetricsDBTools.py
with
21 additions
and
7 deletions
.gitignore
+
3
−
0
View file @
d646caf9
...
@@ -162,3 +162,6 @@ cython_debug/
...
@@ -162,3 +162,6 @@ cython_debug/
# TeraFlowSDN-generated files
# TeraFlowSDN-generated files
tfs_runtime_env_vars.sh
tfs_runtime_env_vars.sh
delete_local_deployment.sh
local_docker_deployment.sh
local_k8s_deployment.sh
This diff is collapsed.
Click to expand it.
src/monitoring/.gitlab-ci.yml
+
1
−
1
View file @
d646caf9
...
@@ -56,7 +56,7 @@ unit test monitoring:
...
@@ -56,7 +56,7 @@ unit test monitoring:
-
docker pull questdb/questdb
-
docker pull questdb/questdb
-
docker run --name questdb -d -p 9000:9000 -p 9009:9009 -p 8812:8812 -p 9003:9003 -e QDB_CAIRO_COMMIT_LAG=1000 -e QDB_CAIRO_MAX_UNCOMMITTED_ROWS=100000 --network=teraflowbridge --rm questdb/questdb
-
docker run --name questdb -d -p 9000:9000 -p 9009:9009 -p 8812:8812 -p 9003:9003 -e QDB_CAIRO_COMMIT_LAG=1000 -e QDB_CAIRO_MAX_UNCOMMITTED_ROWS=100000 --network=teraflowbridge --rm questdb/questdb
-
sleep
10
-
sleep
10
-
docker run --name $IMAGE_NAME -d -p 7070:7070 --env METRICSDB_HOSTNAME=
localhost
--env METRICSDB_ILP_PORT=9009 --env METRICSDB_REST_PORT=9000 --env METRICSDB_TABLE=monitoring -v "$PWD/src/$IMAGE_NAME/tests:/opt/results" --network=teraflowbridge $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG
-
docker run --name $IMAGE_NAME -d -p 7070:7070 --env METRICSDB_HOSTNAME=
questdb
--env METRICSDB_ILP_PORT=9009 --env METRICSDB_REST_PORT=9000 --env METRICSDB_TABLE=monitoring -v "$PWD/src/$IMAGE_NAME/tests:/opt/results" --network=teraflowbridge $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG
-
sleep
30
-
sleep
30
-
docker ps -a
-
docker ps -a
-
docker logs $IMAGE_NAME
-
docker logs $IMAGE_NAME
...
...
This diff is collapsed.
Click to expand it.
src/monitoring/service/MetricsDBTools.py
+
17
−
6
View file @
d646caf9
...
@@ -28,6 +28,7 @@ class MetricsDB():
...
@@ -28,6 +28,7 @@ class MetricsDB():
self
.
ilp_port
=
int
(
ilp_port
)
self
.
ilp_port
=
int
(
ilp_port
)
self
.
rest_port
=
rest_port
self
.
rest_port
=
rest_port
self
.
table
=
table
self
.
table
=
table
self
.
create_table
()
def
write_KPI
(
self
,
time
,
kpi_id
,
kpi_sample_type
,
device_id
,
endpoint_id
,
service_id
,
kpi_value
):
def
write_KPI
(
self
,
time
,
kpi_id
,
kpi_sample_type
,
device_id
,
endpoint_id
,
service_id
,
kpi_value
):
self
.
socket
.
connect
((
self
.
host
,
self
.
ilp_port
))
self
.
socket
.
connect
((
self
.
host
,
self
.
ilp_port
))
...
@@ -47,9 +48,19 @@ class MetricsDB():
...
@@ -47,9 +48,19 @@ class MetricsDB():
def
run_query
(
self
,
sql_query
):
def
run_query
(
self
,
sql_query
):
query_params
=
{
'
query
'
:
sql_query
,
'
fmt
'
:
'
json
'
}
query_params
=
{
'
query
'
:
sql_query
,
'
fmt
'
:
'
json
'
}
url
=
f
"
http://
{
self
.
host
}
:
{
self
.
rest_port
}
/exec
"
url
=
f
"
http://
{
self
.
host
}
:
{
self
.
rest_port
}
/exec
"
try
:
response
=
requests
.
get
(
url
,
params
=
query_params
)
response
=
requests
.
get
(
url
,
params
=
query_params
)
json_response
=
json
.
loads
(
response
.
text
)
json_response
=
json
.
loads
(
response
.
text
)
LOGGER
.
info
(
f
"
Query executed, result:
{
json_response
}
"
)
LOGGER
.
info
(
json_response
)
except
requests
.
exceptions
.
RequestException
as
e
:
def
create_table
(
self
):
LOGGER
.
info
(
f
'
Error:
{
e
}
'
,
file
=
sys
.
stderr
)
query
=
f
'
CREATE TABLE IF NOT EXISTS
{
self
.
table
}
'
\
'
(kpi_id SYMBOL,
'
\
'
kpi_sample_type SYMBOL,
'
\
'
device_id SYMBOL,
'
\
'
endpoint_id SYMBOL,
'
\
'
service_id SYMBOL,
'
\
'
timestamp TIMESTAMP,
'
\
'
kpi_value DOUBLE)
'
\
'
TIMESTAMP(timestamp);
'
self
.
run_query
(
query
)
LOGGER
.
info
(
f
"
Table
{
self
.
table
}
created
"
)
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