From da10e5e8c4fd1c72dfc409fbfaf7565338181b92 Mon Sep 17 00:00:00 2001 From: Igor Santos Date: Mon, 4 Sep 2023 15:57:27 -0300 Subject: [PATCH 01/10] chore: add monitoring with prometheus and grafana --- Dockerfile.local | 58 +++++++++++++++++++++++ app/project/settings/base.py | 8 +++- app/project/settings_prod.py | 28 ++++++----- app/project/urls.py | 7 +-- app/requirements.txt | 2 +- deploy/prometheus.yml | 9 ++++ docker-compose.yml | 90 ++++++++++++++++++++++++++---------- 7 files changed, 160 insertions(+), 42 deletions(-) create mode 100644 Dockerfile.local create mode 100644 deploy/prometheus.yml diff --git a/Dockerfile.local b/Dockerfile.local new file mode 100644 index 00000000..01da44de --- /dev/null +++ b/Dockerfile.local @@ -0,0 +1,58 @@ +# Build staticfiles +FROM node:18-alpine AS node-builder + +WORKDIR /app + +COPY /app . + +WORKDIR /app/tailwind + +RUN npm i + +RUN npm run page:build + +RUN npm run admin:build + +# Use an official Python runtime based on Debian 10 "buster" as a parent image. +FROM python:slim-buster + +# Port used by this container to serve HTTP. +EXPOSE 8000 + +# Set environment variables. +# 1. Force Python stdout and stderr streams to be unbuffered. +# 2. Set PORT variable that is used by Gunicorn. This should match "EXPOSE" +# command. +ENV PYTHONUNBUFFERED=1 \ + PORT=8000 + +# Install system packages required by Django CMS and Django. +RUN apt-get update --yes --quiet && apt-get install --yes --quiet --no-install-recommends \ + build-essential \ + cargo \ + libssl-dev \ + libffi-dev \ + sox \ + ffmpeg \ + libcairo2 \ + libcairo2-dev \ + python3-dev \ +&& rm -rf /var/lib/apt/lists/* + +# Install the application server. +RUN pip install uwsgi django-storages boto3 django-prometheus + +# Install the project requirements. +COPY app/requirements.txt / +RUN pip install -r requirements.txt + +# Use /app folder as a directory where the source code is stored. +WORKDIR /app + +# Copy the source code of the project into the container. +COPY --from=node-builder /app ./ + +RUN python manage.py collectstatic --noinput --clear -i tailwindcss + +# Runtime command that executes when "docker run" is called. +CMD ["uwsgi", "--ini", "/app/wsgi.ini"] \ No newline at end of file diff --git a/app/project/settings/base.py b/app/project/settings/base.py index 5524a0a2..5e47285d 100644 --- a/app/project/settings/base.py +++ b/app/project/settings/base.py @@ -82,10 +82,14 @@ "contrib.ga", # Experimentação "eleicao", - "django_social_share" + "django_social_share", + # + "django_prometheus" ] MIDDLEWARE = [ + "django_prometheus.middleware.PrometheusBeforeMiddleware", + # "django.middleware.security.SecurityMiddleware", "project.middleware.WwwRedirectMiddleware", "eleicao.middleware.EleicaoRedirectMiddleware", @@ -101,6 +105,8 @@ "cms.middleware.page.CurrentPageMiddleware", "cms.middleware.toolbar.ToolbarMiddleware", "cms.middleware.language.LanguageCookieMiddleware", + # + "django_prometheus.middleware.PrometheusAfterMiddleware", ] ROOT_URLCONF = "project.urls" diff --git a/app/project/settings_prod.py b/app/project/settings_prod.py index 80a1e4a7..5afd90d7 100644 --- a/app/project/settings_prod.py +++ b/app/project/settings_prod.py @@ -1,22 +1,26 @@ from .settings import * -INSTALLED_APPS += [ - 'project', - 'storages' -] +MIDDLEWARE = ( + ["django_prometheus.middleware.PrometheusBeforeMiddleware"] + + MIDDLEWARE + + ["django_prometheus.middleware.PrometheusAfterMiddleware"] +) + + +INSTALLED_APPS += ["project", "storages", "django_prometheus"] # aws settings -AWS_ACCESS_KEY_ID = env('AWS_ACCESS_KEY_ID') +AWS_ACCESS_KEY_ID = env("AWS_ACCESS_KEY_ID") -AWS_SECRET_ACCESS_KEY = env('AWS_SECRET_ACCESS_KEY') +AWS_SECRET_ACCESS_KEY = env("AWS_SECRET_ACCESS_KEY") -AWS_STORAGE_BUCKET_NAME = env('AWS_STORAGE_BUCKET_NAME') +AWS_STORAGE_BUCKET_NAME = env("AWS_STORAGE_BUCKET_NAME") # AWS_DEFAULT_ACL = 'public-read' -AWS_S3_CUSTOM_DOMAIN = f'{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com' +AWS_S3_CUSTOM_DOMAIN = f"{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com" -AWS_S3_OBJECT_PARAMETERS = {'CacheControl': 'max-age=86400'} +AWS_S3_OBJECT_PARAMETERS = {"CacheControl": "max-age=86400"} # s3 static settings # STATIC_LOCATION = 'static' @@ -26,8 +30,8 @@ # STATICFILES_STORAGE = 'project.storages.StaticStorage' # s3 public media settings -PUBLIC_MEDIA_LOCATION = 'media' +PUBLIC_MEDIA_LOCATION = "media" -MEDIA_URL = f'https://{AWS_S3_CUSTOM_DOMAIN}/{PUBLIC_MEDIA_LOCATION}/' +MEDIA_URL = f"https://{AWS_S3_CUSTOM_DOMAIN}/{PUBLIC_MEDIA_LOCATION}/" -DEFAULT_FILE_STORAGE = 'project.storages.PublicMediaStorage' \ No newline at end of file +DEFAULT_FILE_STORAGE = "project.storages.PublicMediaStorage" diff --git a/app/project/urls.py b/app/project/urls.py index 31118043..ff1b1af6 100644 --- a/app/project/urls.py +++ b/app/project/urls.py @@ -21,16 +21,17 @@ urlpatterns = [ + path("monitoring/", include("django_prometheus.urls")), path("admin/", admin.site.urls), path("select2/", include("django_select2.urls")), path("actions/", include("contrib.actions.pressure.urls")), - path("", include("cms.urls")) + path("", include("cms.urls")), ] urlpatterns += staticfiles_urlpatterns() -handler404 = 'contrib.frontend.views.error_404' -handler500 = 'contrib.frontend.views.error_500' +handler404 = "contrib.frontend.views.error_404" +handler500 = "contrib.frontend.views.error_500" if settings.DEBUG: urlpatterns.extend(static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)) diff --git a/app/requirements.txt b/app/requirements.txt index bc355999..b0c725c2 100644 --- a/app/requirements.txt +++ b/app/requirements.txt @@ -17,4 +17,4 @@ bcrypt whitenoise svglib reportlab -django-social-share \ No newline at end of file +django-social-share diff --git a/deploy/prometheus.yml b/deploy/prometheus.yml new file mode 100644 index 00000000..45b1069c --- /dev/null +++ b/deploy/prometheus.yml @@ -0,0 +1,9 @@ +global: + scrape_interval: 15s + evaluation_interval: 15s + +scrape_configs: + - job_name: django + metrics_path: '/monitoring/metrics' + static_configs: + - targets: ['localhost:8000'] diff --git a/docker-compose.yml b/docker-compose.yml index ea7163bc..cda1536f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,27 +1,67 @@ services: - web: - build: - context: . - dockerfile: Dockerfile - ports: - - "80:8000" - env_file: - - .env-local - depends_on: - - db + # web: + # build: + # context: . + # dockerfile: Dockerfile.local + # # image: nossas/cms:main + # networks: + # - bonde + # ports: + # - "80:8000" + # env_file: + # - .env-local + # depends_on: + # - db - db: - image: postgres:latest - restart: always - environment: - - POSTGRES_USER=postgres - - POSTGRES_PASSWORD=postgres - - POSTGRES_DB=cms - # logging: - # options: - # max-size: 10m - # max-file: "3" - ports: - - '5432:5432' - volumes: - - /tmp/data:/var/lib/postgresql/data \ No newline at end of file + # db: + # image: postgres:latest + # restart: always + # environment: + # - POSTGRES_USER=postgres + # - POSTGRES_PASSWORD=postgres + # - POSTGRES_DB=cms + # # logging: + # # options: + # # max-size: 10m + # # max-file: "3" + # networks: + # - bonde + # ports: + # - '5432:5432' + # volumes: + # - /tmp/data:/var/lib/postgresql/data + + prometheus: + image: prom/prometheus + restart: 'no' + user: root + volumes: + - /tmp/prometheus_data:/prometheus + - ./deploy/prometheus.yml:/etc/prometheus/prometheus.yml + # networks: + # - bonde + # ports: + # - 9090:9090 + network_mode: "host" + # depends_on: + # - web + + grafana: + image: grafana/grafana + user: root + environment: + GF_INSTALL_PLUGINS: "grafana-clock-panel,grafana-simple-json-datasource" + restart: 'no' + volumes: + - /tmp/grafana_data:/var/lib/grafana + # networks: + # - bonde + # ports: + # - 3000:3000 + network_mode: "host" + depends_on: + - prometheus + +# networks: +# bonde: +# external: True \ No newline at end of file From c290367fb9b4cdcfe0a39c11f608aeca4e699b86 Mon Sep 17 00:00:00 2001 From: Igor Santos Date: Mon, 4 Sep 2023 18:30:12 -0300 Subject: [PATCH 02/10] chore: add locust for load testing --- locustfile.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 locustfile.py diff --git a/locustfile.py b/locustfile.py new file mode 100644 index 00000000..920ce296 --- /dev/null +++ b/locustfile.py @@ -0,0 +1,6 @@ +from locust import HttpUser, task + +class HelloWorldUser(HttpUser): + @task + def hello_world(self): + self.client.get("/candidaturas/") From c8e5629157ea0832d296d6e82c46704c6505ebf7 Mon Sep 17 00:00:00 2001 From: Igor Santos Date: Tue, 5 Sep 2023 15:44:26 -0300 Subject: [PATCH 03/10] feat: add redis cache --- .../templates/eleicao/plugins/candidate_list.html | 4 ++++ app/project/settings/base.py | 14 ++++++++++++++ app/requirements.txt | 1 + docker-compose.yml | 10 ++++++++++ 4 files changed, 29 insertions(+) diff --git a/app/eleicao/templates/eleicao/plugins/candidate_list.html b/app/eleicao/templates/eleicao/plugins/candidate_list.html index 222846d5..2ef5b155 100644 --- a/app/eleicao/templates/eleicao/plugins/candidate_list.html +++ b/app/eleicao/templates/eleicao/plugins/candidate_list.html @@ -1,3 +1,5 @@ +{% load cache %} +
@@ -10,11 +12,13 @@

Conheça as candidaturas

{{ form.as_html }}
+ {% cache 60 candidate_list form.state.value %}
    {% for candidate in object_list %} {% include 'eleicao/includes/card.html' %} {% endfor %}
+ {% endcache %}
{% if is_paginated %} diff --git a/app/project/settings/base.py b/app/project/settings/base.py index 5e47285d..4d1e2f19 100644 --- a/app/project/settings/base.py +++ b/app/project/settings/base.py @@ -148,6 +148,20 @@ "contrib.bonde.router.AuthRouter", ] +# Cache +# https://docs.djangoproject.com/en/4.2/topics/cache/ + +CACHES = { + "default": { + "BACKEND": "django_redis.cache.RedisCache", + "LOCATION": "redis://127.0.0.1:6379", + "OPTIONS": { + "CLIENT_CLASS": "django_redis.client.DefaultClient", + "PASSWORD": "eYVX7EwVmmxKPCDmwMtyKVge8oLd2t81" + } + } +} + # Password validation # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators diff --git a/app/requirements.txt b/app/requirements.txt index b0c725c2..e4688fb2 100644 --- a/app/requirements.txt +++ b/app/requirements.txt @@ -18,3 +18,4 @@ whitenoise svglib reportlab django-social-share +django-redis \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index cda1536f..6f03f9ad 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -62,6 +62,16 @@ services: depends_on: - prometheus + redis: + image: redis:6.2-alpine + restart: always + command: redis-server --save 20 1 --loglevel warning --requirepass eYVX7EwVmmxKPCDmwMtyKVge8oLd2t81 + # ports: + # - '6379:6379' + network_mode: "host" + volumes: + - /tmp/redis_data:/data + # networks: # bonde: # external: True \ No newline at end of file From e9aa3695e340cdd4b9b86296cfda85a7595d5eb1 Mon Sep 17 00:00:00 2001 From: Igor Santos Date: Thu, 14 Sep 2023 17:17:57 -0300 Subject: [PATCH 04/10] feat(monitoring): add monitor to staging --- deploy/docker-compose.yml | 33 +++++++++++++++++++++++++++++---- deploy/prometheus.yml | 2 +- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml index e335e1ff..f8dd1c0e 100644 --- a/deploy/docker-compose.yml +++ b/deploy/docker-compose.yml @@ -21,10 +21,35 @@ services: - traefik.http.routers.cms.tls=true - traefik.http.routers.cms.tls.certresolver=myresolver - traefik.http.routers.cms.rule=${TRAEFIK_ROUTERS_RULE} - # prod - # - traefik.http.routers.cms.rule=HostRegexp(`aeleicaodoano.org`,`{subdomain:[a-z]+}.aeleicaodoano.org`,`cms.bonde.org`,`{subdomain:[a-z]+}.cms.bonde.org`) - # staging - # - traefik.http.routers.cms.rule=HostRegexp(`cms.staging.bonde.org`,`{subdomain:[a-z]+}.cms.staging.bonde.org`) + + prometheus: + image: prom/prometheus + restart: 'yes' + user: root + volumes: + - prometheus_data:/prometheus + - ./prometheus.yml:/etc/prometheus/prometheus.yml + labels: + - traefik.enable=true + - traefik.http.services.prometheus.loadbalancer.server.port=9090 + - traefik.http.routers.prometheus.tls=true + - traefik.http.routers.prometheus.tls.certresolver=myresolver + + grafana: + image: grafana/grafana + user: root + environment: + GF_INSTALL_PLUGINS: "grafana-clock-panel,grafana-simple-json-datasource" + restart: 'no' + volumes: + - grafana_data:/var/lib/grafana + depends_on: + - prometheus + labels: + - traefik.enable=true + - traefik.http.services.grafana.loadbalancer.server.port=3000 + - traefik.http.routers.grafana.tls=true + - traefik.http.routers.grafana.tls.certresolver=myresolver networks: default: diff --git a/deploy/prometheus.yml b/deploy/prometheus.yml index 45b1069c..ff848ffd 100644 --- a/deploy/prometheus.yml +++ b/deploy/prometheus.yml @@ -6,4 +6,4 @@ scrape_configs: - job_name: django metrics_path: '/monitoring/metrics' static_configs: - - targets: ['localhost:8000'] + - targets: ['cms.staging.bonde.org'] From 8462d2cf41052d83b60a794c7b1297a4efc26cfb Mon Sep 17 00:00:00 2001 From: Igor Santos Date: Thu, 14 Sep 2023 17:22:57 -0300 Subject: [PATCH 05/10] fix(monitoring): install django-prometheus on build --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 84bde1b3..e1dbb2ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,7 +40,7 @@ RUN apt-get update --yes --quiet && apt-get install --yes --quiet --no-install-r && rm -rf /var/lib/apt/lists/* # Install the application server. -RUN pip install uwsgi django-storages boto3 +RUN pip install uwsgi django-storages boto3 django-prometheus # Install the project requirements. COPY requirements.txt / From 12ecdbbe07fa8db4ee65c0cc7b819b223271e687 Mon Sep 17 00:00:00 2001 From: Igor Santos Date: Thu, 14 Sep 2023 17:32:59 -0300 Subject: [PATCH 06/10] fix(monitoring): remove cache unused --- .../templates/eleicao/plugins/candidate_list.html | 4 ---- app/project/settings/base.py | 15 --------------- 2 files changed, 19 deletions(-) diff --git a/app/eleicao/templates/eleicao/plugins/candidate_list.html b/app/eleicao/templates/eleicao/plugins/candidate_list.html index 2ef5b155..222846d5 100644 --- a/app/eleicao/templates/eleicao/plugins/candidate_list.html +++ b/app/eleicao/templates/eleicao/plugins/candidate_list.html @@ -1,5 +1,3 @@ -{% load cache %} -
@@ -12,13 +10,11 @@

Conheça as candidaturas

{{ form.as_html }}
- {% cache 60 candidate_list form.state.value %}
    {% for candidate in object_list %} {% include 'eleicao/includes/card.html' %} {% endfor %}
- {% endcache %}
{% if is_paginated %} diff --git a/app/project/settings/base.py b/app/project/settings/base.py index 4d1e2f19..6948d0e2 100644 --- a/app/project/settings/base.py +++ b/app/project/settings/base.py @@ -148,21 +148,6 @@ "contrib.bonde.router.AuthRouter", ] -# Cache -# https://docs.djangoproject.com/en/4.2/topics/cache/ - -CACHES = { - "default": { - "BACKEND": "django_redis.cache.RedisCache", - "LOCATION": "redis://127.0.0.1:6379", - "OPTIONS": { - "CLIENT_CLASS": "django_redis.client.DefaultClient", - "PASSWORD": "eYVX7EwVmmxKPCDmwMtyKVge8oLd2t81" - } - } -} - - # Password validation # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators From c48e929406a06138ae48bbbcd5bb681af984d8a5 Mon Sep 17 00:00:00 2001 From: Igor Santos Date: Thu, 14 Sep 2023 17:40:47 -0300 Subject: [PATCH 07/10] fix(deploy): add default env to traefik route rule --- deploy/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml index f8dd1c0e..7b096daf 100644 --- a/deploy/docker-compose.yml +++ b/deploy/docker-compose.yml @@ -20,7 +20,7 @@ services: - traefik.http.services.cms.loadbalancer.server.port=8000 - traefik.http.routers.cms.tls=true - traefik.http.routers.cms.tls.certresolver=myresolver - - traefik.http.routers.cms.rule=${TRAEFIK_ROUTERS_RULE} + - traefik.http.routers.cms.rule=${TRAEFIK_ROUTERS_RULE:-"HostRegexp(`cms.staging.bonde.org`)"} prometheus: image: prom/prometheus From 68da05f35e112d52b2cfd80122ae894e82e3cd7a Mon Sep 17 00:00:00 2001 From: Igor Santos Date: Thu, 14 Sep 2023 17:45:52 -0300 Subject: [PATCH 08/10] fix(monitoring): add volume to deploy graphana and prometheus --- deploy/docker-compose.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml index 7b096daf..c3985f37 100644 --- a/deploy/docker-compose.yml +++ b/deploy/docker-compose.yml @@ -24,11 +24,11 @@ services: prometheus: image: prom/prometheus - restart: 'yes' + restart: 'no' user: root volumes: - prometheus_data:/prometheus - - ./prometheus.yml:/etc/prometheus/prometheus.yml + - ./prometheus_data/prometheus.yml:/etc/prometheus/prometheus.yml labels: - traefik.enable=true - traefik.http.services.prometheus.loadbalancer.server.port=9090 @@ -54,3 +54,9 @@ services: networks: default: name: bonde + +volumes: + prometheus_data: + driver: local + grafana_data: + driver: local \ No newline at end of file From 489567ad5d51049c3c8981614f21c3ab4ac37e5d Mon Sep 17 00:00:00 2001 From: Igor Santos Date: Fri, 15 Sep 2023 09:53:38 -0300 Subject: [PATCH 09/10] fix(monitoring): enable monitoring only production builds --- app/project/settings/base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/project/settings/base.py b/app/project/settings/base.py index 6948d0e2..042eb04d 100644 --- a/app/project/settings/base.py +++ b/app/project/settings/base.py @@ -84,11 +84,11 @@ "eleicao", "django_social_share", # - "django_prometheus" + # "django_prometheus" ] MIDDLEWARE = [ - "django_prometheus.middleware.PrometheusBeforeMiddleware", + # "django_prometheus.middleware.PrometheusBeforeMiddleware", # "django.middleware.security.SecurityMiddleware", "project.middleware.WwwRedirectMiddleware", @@ -106,7 +106,7 @@ "cms.middleware.toolbar.ToolbarMiddleware", "cms.middleware.language.LanguageCookieMiddleware", # - "django_prometheus.middleware.PrometheusAfterMiddleware", + # "django_prometheus.middleware.PrometheusAfterMiddleware", ] ROOT_URLCONF = "project.urls" From 03ca0ba335d9ca6b17dfec89ad0de7b3e5883ae0 Mon Sep 17 00:00:00 2001 From: Igor Santos Date: Fri, 15 Sep 2023 17:25:45 -0300 Subject: [PATCH 10/10] chore(monitoring): remove unused snippet codes --- app/requirements.txt | 1 - deploy/docker-compose.yml | 64 +++++++++++++++++++-------------------- deploy/prometheus.yml | 9 ------ locustfile.py | 21 +++++++++++-- 4 files changed, 51 insertions(+), 44 deletions(-) delete mode 100644 deploy/prometheus.yml diff --git a/app/requirements.txt b/app/requirements.txt index e4688fb2..b0c725c2 100644 --- a/app/requirements.txt +++ b/app/requirements.txt @@ -18,4 +18,3 @@ whitenoise svglib reportlab django-social-share -django-redis \ No newline at end of file diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml index c3985f37..a992a6ca 100644 --- a/deploy/docker-compose.yml +++ b/deploy/docker-compose.yml @@ -22,41 +22,41 @@ services: - traefik.http.routers.cms.tls.certresolver=myresolver - traefik.http.routers.cms.rule=${TRAEFIK_ROUTERS_RULE:-"HostRegexp(`cms.staging.bonde.org`)"} - prometheus: - image: prom/prometheus - restart: 'no' - user: root - volumes: - - prometheus_data:/prometheus - - ./prometheus_data/prometheus.yml:/etc/prometheus/prometheus.yml - labels: - - traefik.enable=true - - traefik.http.services.prometheus.loadbalancer.server.port=9090 - - traefik.http.routers.prometheus.tls=true - - traefik.http.routers.prometheus.tls.certresolver=myresolver + # prometheus: + # image: prom/prometheus + # restart: 'no' + # user: root + # volumes: + # - prometheus_data:/prometheus + # # - ./prometheus.yml:/etc/prometheus/prometheus.yml + # labels: + # - traefik.enable=true + # - traefik.http.services.prometheus.loadbalancer.server.port=9090 + # - traefik.http.routers.prometheus.tls=true + # - traefik.http.routers.prometheus.tls.certresolver=myresolver - grafana: - image: grafana/grafana - user: root - environment: - GF_INSTALL_PLUGINS: "grafana-clock-panel,grafana-simple-json-datasource" - restart: 'no' - volumes: - - grafana_data:/var/lib/grafana - depends_on: - - prometheus - labels: - - traefik.enable=true - - traefik.http.services.grafana.loadbalancer.server.port=3000 - - traefik.http.routers.grafana.tls=true - - traefik.http.routers.grafana.tls.certresolver=myresolver + # grafana: + # image: grafana/grafana + # user: root + # environment: + # GF_INSTALL_PLUGINS: "grafana-clock-panel,grafana-simple-json-datasource" + # restart: 'no' + # volumes: + # - grafana_data:/var/lib/grafana + # depends_on: + # - prometheus + # labels: + # - traefik.enable=true + # - traefik.http.services.grafana.loadbalancer.server.port=3000 + # - traefik.http.routers.grafana.tls=true + # - traefik.http.routers.grafana.tls.certresolver=myresolver networks: default: name: bonde -volumes: - prometheus_data: - driver: local - grafana_data: - driver: local \ No newline at end of file +# volumes: +# prometheus_data: +# driver: local +# grafana_data: +# driver: local diff --git a/deploy/prometheus.yml b/deploy/prometheus.yml deleted file mode 100644 index ff848ffd..00000000 --- a/deploy/prometheus.yml +++ /dev/null @@ -1,9 +0,0 @@ -global: - scrape_interval: 15s - evaluation_interval: 15s - -scrape_configs: - - job_name: django - metrics_path: '/monitoring/metrics' - static_configs: - - targets: ['cms.staging.bonde.org'] diff --git a/locustfile.py b/locustfile.py index 920ce296..e776e4f9 100644 --- a/locustfile.py +++ b/locustfile.py @@ -1,6 +1,23 @@ from locust import HttpUser, task -class HelloWorldUser(HttpUser): +class SimulateRequestOverUser(HttpUser): + @task - def hello_world(self): + def index(self): + self.client.get("/") + + @task + def list(self): self.client.get("/candidaturas/") + + @task + def admin(self): + self.client.get("/admin") + + @task + def not_found(self): + self.client.get("/not_found/asdasdasd") + + @task + def form(self): + self.client.get("/candidaturas/cadastro/") \ No newline at end of file