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
01721d90
Commit
01721d90
authored
3 years ago
by
Sergio Gonzalez Diaz
Browse files
Options
Downloads
Patches
Plain Diff
test influx monitoring
parent
af9b3e39
No related branches found
Branches containing commit
No related tags found
Tags containing commit
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/monitoring/.gitlab-ci.yml
+30
-30
30 additions, 30 deletions
src/monitoring/.gitlab-ci.yml
src/monitoring/service/MonitoringServiceServicerImpl.py
+2
-3
2 additions, 3 deletions
src/monitoring/service/MonitoringServiceServicerImpl.py
with
32 additions
and
33 deletions
src/monitoring/.gitlab-ci.yml
+
30
−
30
View file @
01721d90
#
# build, tag and push the Docker image to the gitlab registry
#
build monitoring:
#
variables:
#
IMAGE_NAME: 'monitoring' # name of the microservice
#
IMAGE_TAG: 'latest' # tag of the container image (production, development, etc)
#
stage: build
#
before_script:
#
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
#
script:
#
- docker build --build-arg user=$INFLUXDB_USER --build-arg pass=$INFLUXDB_PASSWORD --build-arg db=$INFLUXDB_DATABASE -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/Dockerfile ./src/
#
- docker tag "$IMAGE_NAME:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
#
- docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
#
after_script:
#
- docker rmi $(docker images --quiet --filter=dangling=true)
#
rules:
#
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)'
#
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"'
#
- changes:
#
- src/$IMAGE_NAME/**/*.{py,in,yml}
#
- src/$IMAGE_NAME/Dockerfile
#
- src/$IMAGE_NAME/tests/*.py
#
- src/$IMAGE_NAME/tests/Dockerfile
#
- manifests/$IMAGE_NAME.yaml
#
- .gitlab-ci.yml
# build, tag and push the Docker image to the gitlab registry
build monitoring
:
variables
:
IMAGE_NAME
:
'
monitoring'
# name of the microservice
IMAGE_TAG
:
'
latest'
# tag of the container image (production, development, etc)
stage
:
build
before_script
:
-
docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script
:
-
docker build --build-arg user=$INFLUXDB_USER --build-arg pass=$INFLUXDB_PASSWORD --build-arg db=$INFLUXDB_DATABASE -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/Dockerfile ./src/
-
docker tag "$IMAGE_NAME:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
-
docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
after_script
:
-
docker rmi $(docker images --quiet --filter=dangling=true)
rules
:
-
if
:
'
$CI_PIPELINE_SOURCE
==
"merge_request_event"
&&
($CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
"develop"
||
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$CI_DEFAULT_BRANCH)'
-
if
:
'
$CI_PIPELINE_SOURCE
==
"push"
&&
$CI_COMMIT_BRANCH
==
"develop"'
-
changes
:
-
src/$IMAGE_NAME/**/*.{py,in,yml}
-
src/$IMAGE_NAME/Dockerfile
-
src/$IMAGE_NAME/tests/*.py
-
src/$IMAGE_NAME/tests/Dockerfile
-
manifests/$IMAGE_NAME.yaml
-
.gitlab-ci.yml
kubernetes test
:
stage
:
build
script
:
# - kubectl version
# - kubectl get all
#
- kubectl delete -f "manifests/monitoring.yaml"
-
kubectl delete -f "manifests/monitoring.yaml"
# - sleep 15
#
- kubectl apply -f "manifests/monitoring.yaml"
-
kubectl apply -f "manifests/monitoring.yaml"
# - sleep 30
#
- kubectl get all
-
kubectl --namespace gitlab-ci describe pod monitoring-595c885c6c-trqr4
-
kubectl --namespace gitlab-ci logs monitoring-595c885c6c-trqr4 influxdb
-
kubectl --namespace gitlab-ci logs monitoring-595c885c6c-trqr4 server
-
kubectl get all
#
- kubectl --namespace gitlab-ci describe pod monitoring-595c885c6c-trqr4
#
- kubectl --namespace gitlab-ci logs monitoring-595c885c6c-trqr4 influxdb
#
- kubectl --namespace gitlab-ci logs monitoring-595c885c6c-trqr4 server
# # test if the Docker image can be pulled from the gitlab registry
# test monitoring pull:
...
...
This diff is collapsed.
Click to expand it.
src/monitoring/service/MonitoringServiceServicerImpl.py
+
2
−
3
View file @
01721d90
...
...
@@ -28,9 +28,8 @@ class MonitoringServiceServicerImpl(monitoring_pb2_grpc.MonitoringServiceService
# Create influx_db client
self
.
influx_db
=
influx_tools
.
Influx
(
"
localhost
"
,
"
8086
"
,
INFLUXDB_USER
,
INFLUXDB_PASS
,
INFLUXDB_DB
)
LOGGER
.
info
(
INFLUXDB_USER
)
LOGGER
.
info
(
INFLUXDB_PASS
)
LOGGER
.
info
(
INFLUXDB_DB
)
self
.
influx_db
.
write_KPI
(
"
2021-10-12T13:14:42Z
"
,
1
,
1
,
101
,
1000
)
self
.
influx_db
.
client
.
query
(
'
select * from samples;
'
)
# CreateKpi (CreateKpiRequest) returns (KpiId) {}
def
CreateKpi
(
self
,
request
:
monitoring_pb2
.
CreateKpiRequest
,
context
)
->
monitoring_pb2
.
KpiId
:
...
...
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