Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monitoring 1 #5

Merged
merged 3 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ packer/variables.json
*.retry
**/roles/jdauphantnginx/*
jdauphant.nginx
docker/.env
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,25 @@ docker exec -it gitlab-runner gitlab-runner register \
- Написал стадии для Staging и Production
- Добавил условия для джобы
- Добавил динамические окружения

## Monitoring 1
### Что было сделано:
- Запустил prometheus
```shell
docker run --rm -p 9090:9090 -d --name prometheus prom/prometheus
```
- Упорядочил структуру репозитория для Docker
- Создал Dockerfile и конфигурацию для Prometheus
- Собрал все образы для сервисов приложения
```shell
for i in ui post-py comment; do cd src/$i; bash docker_build.sh; cd -; done
```
- Добавил сервис prometheus в docker-compose
- Изучил взаимодействие с метриками Prometheus и протестировал отслеживание состояния сервисов которые подключены к мониторингу
- Добавил Node exporter для сбора информации о работе Docker
хоста
- Запушил образы в Docker Hub
- [prometheus](https://hub.docker.com/repository/docker/baykanurov/prometheus/general)
- [post](https://hub.docker.com/repository/docker/baykanurov/post/general)
- [comment](https://hub.docker.com/repository/docker/baykanurov/comment/general)
- [ui](https://hub.docker.com/repository/docker/baykanurov/ui/general)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,30 @@ services:

ui:
container_name: ui
build: ./ui
image: ${USERNAME:-baykanurov}/ui:${UI_IMAGE_TAG:-1.0}
command: ["puma", "--debug", "-w 2"]
ports:
- ${UI_PORT:-9292}:9292/tcp
volumes:
- ./ui:/app:consistent
- ../src/ui:/app:consistent
networks:
- front_net

post:
container_name: post
build: ./post-py
image: ${USERNAME:-baykanurov}/post:${POST_IMAGE_TAG:-1.0}
volumes:
- ./post-py:/app:consistent
- ../src/post-py:/app:consistent
networks:
- back_net
- front_net

comment:
container_name: comment
build: ./comment
image: ${USERNAME:-baykanurov}/comment:${COMMENT_IMAGE_TAG:-1.0}
command: ["puma", "--debug", "-w 2"]
volumes:
- ./comment:/app:consistent
- ../src/comment:/app:consistent
networks:
- back_net
- front_net
Expand Down
68 changes: 68 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
version: '3.3'
services:
mongo:
container_name: post_db
image: mongo:${MONGO_IMAGE_TAG}
volumes:
- post_db:/data/db
networks:
- back_net

ui:
container_name: ui
image: ${USERNAME}/ui:${UI_IMAGE_TAG}
ports:
- ${UI_PORT}:9292/tcp
networks:
- front_net

post:
container_name: post
image: ${USERNAME}/post:${POST_IMAGE_TAG}
networks:
- back_net
- front_net

comment:
container_name: comment
image: ${USERNAME}/comment:${COMMENT_IMAGE_TAG}
networks:
- back_net
- front_net

prometheus:
image: ${USERNAME}/prometheus
ports:
- '9090:9090'
volumes:
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--storage.tsdb.retention=1d'
networks:
- back_net
- front_net

node-exporter:
image: prom/node-exporter:v0.15.2
user: root
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
command:
- '--path.procfs=/host/proc'
- '--path.sysfs=/host/sys'
- '--collector.filesystem.ignored-mount-points="^/(sys|proc|dev|host|etc)($$|/)"'
networks:
- back_net
- front_net

volumes:
post_db:
prometheus_data:

networks:
back_net:
front_net:
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions monitoring/prometheus/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM prom/prometheus:v2.1.0
ADD prometheus.yml /etc/prometheus/
25 changes: 25 additions & 0 deletions monitoring/prometheus/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
global:
scrape_interval: '5s'

scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets:
- 'localhost:9090'

- job_name: 'ui'
static_configs:
- targets:
- 'ui:9292'

- job_name: 'comment'
static_configs:
- targets:
- 'comment:9292'


- job_name: 'node'
static_configs:
- targets:
- 'node-exporter:9100'
1 change: 0 additions & 1 deletion src/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
build_info.txt
prometheus/
.env

## python specific
*.pyc
Loading