Skip to content

Commit

Permalink
[set] monitoring-fin
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzyoon committed Sep 26, 2022
2 parents 8bd2916 + 37db229 commit 5fc281f
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 18 deletions.
10 changes: 8 additions & 2 deletions backend/backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@
'users',
'letters',
#s3 bucket
'storages'
'storages',
#Monitoring
'django_prometheus'
]

AUTH_USER_MODEL = 'users.User'
Expand All @@ -92,9 +94,13 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
#Monitoring
'django_prometheus.middleware.PrometheusBeforeMiddleware',
'django_prometheus.middleware.PrometheusAfterMiddleware'
]

ROOT_URLCONF = 'backend.urls'
# ROOT_URLCONF = "graphite.urls_prometheus_wrapper"

TEMPLATES = [
{
Expand Down Expand Up @@ -167,4 +173,4 @@
# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
5 changes: 4 additions & 1 deletion backend/backend/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.contrib import admin
from django.urls import path, include, re_path
# from django.conf.urls import include, path

from drf_yasg.views import get_schema_view
from drf_yasg import openapi
Expand All @@ -25,4 +26,6 @@
re_path(r'^swagger(?P<format>\.json|\.yaml)$', schema_view_v1.without_ui(cache_timeout=0), name='schema-json'),
re_path(r'^swagger/$', schema_view_v1.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
re_path(r'^redoc/$', schema_view_v1.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
]
]

urlpatterns.append(path('', include('django_prometheus.urls')))
2 changes: 1 addition & 1 deletion backend/letters/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get_file_url(data, uuid, input_type="file"):
if input_type == "file":
type = "jpg"
elif input_type == "media":
type = "mp3"
type = "wav"
s3_client.put_object(Body=data, Bucket=AWS_STORAGE_BUCKET_NAME, Key=uuid + "." + type)
url = "http://"+AWS_STORAGE_BUCKET_NAME+".s3.ap-northeast-2.amazonaws.com/" + \
uuid + "." + type
Expand Down
3 changes: 3 additions & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ drf-yasg==1.21.3
boto3==1.24.67
django-storages==1.13.1

#prometheus
django-prometheus

python-dateutil==2.8.2
33 changes: 25 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
version: "3"

volumes:
mysql_data: {}

services:
# docker-compose.yml 파일이 밖에 있을 때 기준
# frontend:
Expand Down Expand Up @@ -35,8 +32,11 @@ services:
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost" ]
timeout: 20s
retries: 10
networks:
- letterman

backend:
container_name: django
build: ./backend
command: >
bash -c "python3 manage.py makemigrations &&
Expand All @@ -49,8 +49,11 @@ services:
depends_on:
db:
condition: service_healthy

networks:
- letterman

prometheus:
container_name: prometheus
image: prom/prometheus
restart: unless-stopped
ports:
Expand All @@ -66,16 +69,30 @@ services:
- --web.console.libraries=/usr/share/prometheus/console_libraries
- --web.console.templates=/usr/share/proemtheus/consoles
- --web.enable-admin-api
networks:
- letterman

grafana:
container_name: grafana
image: grafana/grafana
restart: unless-stopped
ports:
- 3000:3000
- 4000:3000
volumes:
- ./grafana:/var/lib/grafana
environment:
- GF_SECURITY_ADMIN_USER=admin # grafana 사용자 이름
- GF_SECURITY_ADMIN_PASSWORD=admin # grafana 사용자 비밀번호
- GF_USERS_ALLOW_SIGN_UP=false
GF_INSTALL_PLUGINS: "grafana-clock-panel,grafana-simple-json-datasource"
depends_on:
- prometheus
networks:
- letterman


networks:
letterman:
driver: bridge

volumes:
mysql_data: {}
prometheus_data: {}
grafana_data: {}
11 changes: 5 additions & 6 deletions prometheus.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
global:
scrape_interval: 10s # By default, scrape targets every 15 seconds.
evaluation_interval: 10s # Evaluate rules every 15 seconds.

rule_files:
- 'prometheus.rules.yml'
scrape_interval: 15s # By default, scrape targets every 15 seconds.
evaluation_interval: 15s # Evaluate rules every 15 seconds.

scrape_configs:
- job_name: 'letterman'
metrics_path: '/metrics'
static_configs:
- targets: ['minecraft:9225']
- targets:
- host.docker.internal:8080

0 comments on commit 5fc281f

Please sign in to comment.