mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 15:57:23 -04:00
Revert "Statsd to prometheus"
This commit is contained in:
@@ -24,7 +24,6 @@ from flask.globals import _lookup_req_object, _request_ctx_stack
|
|||||||
from flask_login import LoginManager, current_user
|
from flask_login import LoginManager, current_user
|
||||||
from flask_wtf import CSRFProtect
|
from flask_wtf import CSRFProtect
|
||||||
from flask_wtf.csrf import CSRFError
|
from flask_wtf.csrf import CSRFError
|
||||||
from gds_metrics import GDSMetrics
|
|
||||||
from govuk_frontend_jinja.flask_ext import init_govuk_frontend
|
from govuk_frontend_jinja.flask_ext import init_govuk_frontend
|
||||||
from itsdangerous import BadSignature
|
from itsdangerous import BadSignature
|
||||||
from notifications_python_client.errors import HTTPError
|
from notifications_python_client.errors import HTTPError
|
||||||
@@ -46,7 +45,12 @@ from app import proxy_fix
|
|||||||
from app.asset_fingerprinter import asset_fingerprinter
|
from app.asset_fingerprinter import asset_fingerprinter
|
||||||
from app.commands import setup_commands
|
from app.commands import setup_commands
|
||||||
from app.config import configs
|
from app.config import configs
|
||||||
from app.extensions import antivirus_client, redis_client, zendesk_client
|
from app.extensions import (
|
||||||
|
antivirus_client,
|
||||||
|
redis_client,
|
||||||
|
statsd_client,
|
||||||
|
zendesk_client,
|
||||||
|
)
|
||||||
from app.models.organisation import Organisation
|
from app.models.organisation import Organisation
|
||||||
from app.models.service import Service
|
from app.models.service import Service
|
||||||
from app.models.user import AnonymousUser, User
|
from app.models.user import AnonymousUser, User
|
||||||
@@ -95,7 +99,6 @@ from app.utils import format_thousands, get_logo_cdn_domain, id_safe
|
|||||||
|
|
||||||
login_manager = LoginManager()
|
login_manager = LoginManager()
|
||||||
csrf = CSRFProtect()
|
csrf = CSRFProtect()
|
||||||
metrics = GDSMetrics()
|
|
||||||
|
|
||||||
|
|
||||||
# The current service attached to the request stack.
|
# The current service attached to the request stack.
|
||||||
@@ -134,7 +137,6 @@ def create_app(application):
|
|||||||
# Gubbins
|
# Gubbins
|
||||||
csrf,
|
csrf,
|
||||||
login_manager,
|
login_manager,
|
||||||
metrics,
|
|
||||||
proxy_fix,
|
proxy_fix,
|
||||||
request_helper,
|
request_helper,
|
||||||
|
|
||||||
@@ -164,13 +166,14 @@ def create_app(application):
|
|||||||
|
|
||||||
# External API clients
|
# External API clients
|
||||||
antivirus_client,
|
antivirus_client,
|
||||||
redis_client,
|
statsd_client,
|
||||||
zendesk_client,
|
zendesk_client,
|
||||||
|
redis_client
|
||||||
|
|
||||||
):
|
):
|
||||||
client.init_app(application)
|
client.init_app(application)
|
||||||
|
|
||||||
logging.init_app(application)
|
logging.init_app(application, statsd_client)
|
||||||
|
|
||||||
login_manager.login_view = 'main.sign_in'
|
login_manager.login_view = 'main.sign_in'
|
||||||
login_manager.login_message_category = 'default'
|
login_manager.login_message_category = 'default'
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ class Config(object):
|
|||||||
TEMPLATE_PREVIEW_API_HOST = os.environ.get('TEMPLATE_PREVIEW_API_HOST', 'http://localhost:6013')
|
TEMPLATE_PREVIEW_API_HOST = os.environ.get('TEMPLATE_PREVIEW_API_HOST', 'http://localhost:6013')
|
||||||
TEMPLATE_PREVIEW_API_KEY = os.environ.get('TEMPLATE_PREVIEW_API_KEY', 'my-secret-key')
|
TEMPLATE_PREVIEW_API_KEY = os.environ.get('TEMPLATE_PREVIEW_API_KEY', 'my-secret-key')
|
||||||
|
|
||||||
|
# Hosted graphite statsd prefix
|
||||||
|
STATSD_ENABLED = False
|
||||||
|
STATSD_HOST = os.getenv('STATSD_HOST')
|
||||||
|
STATSD_PORT = 8125
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
NOTIFY_LOG_PATH = os.getenv('NOTIFY_LOG_PATH')
|
NOTIFY_LOG_PATH = os.getenv('NOTIFY_LOG_PATH')
|
||||||
@@ -92,6 +97,7 @@ class Development(Config):
|
|||||||
DEBUG = True
|
DEBUG = True
|
||||||
SESSION_COOKIE_SECURE = False
|
SESSION_COOKIE_SECURE = False
|
||||||
SESSION_PROTECTION = None
|
SESSION_PROTECTION = None
|
||||||
|
STATSD_ENABLED = False
|
||||||
CSV_UPLOAD_BUCKET_NAME = 'development-notifications-csv-upload'
|
CSV_UPLOAD_BUCKET_NAME = 'development-notifications-csv-upload'
|
||||||
CONTACT_LIST_UPLOAD_BUCKET_NAME = 'development-contact-list'
|
CONTACT_LIST_UPLOAD_BUCKET_NAME = 'development-contact-list'
|
||||||
LOGO_UPLOAD_BUCKET_NAME = 'public-logos-tools'
|
LOGO_UPLOAD_BUCKET_NAME = 'public-logos-tools'
|
||||||
@@ -114,6 +120,7 @@ class Development(Config):
|
|||||||
class Test(Development):
|
class Test(Development):
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
TESTING = True
|
TESTING = True
|
||||||
|
STATSD_ENABLED = False
|
||||||
WTF_CSRF_ENABLED = False
|
WTF_CSRF_ENABLED = False
|
||||||
CSV_UPLOAD_BUCKET_NAME = 'test-notifications-csv-upload'
|
CSV_UPLOAD_BUCKET_NAME = 'test-notifications-csv-upload'
|
||||||
CONTACT_LIST_UPLOAD_BUCKET_NAME = 'test-contact-list'
|
CONTACT_LIST_UPLOAD_BUCKET_NAME = 'test-contact-list'
|
||||||
@@ -134,6 +141,7 @@ class Test(Development):
|
|||||||
class Preview(Config):
|
class Preview(Config):
|
||||||
HTTP_PROTOCOL = 'https'
|
HTTP_PROTOCOL = 'https'
|
||||||
HEADER_COLOUR = '#F499BE' # $baby-pink
|
HEADER_COLOUR = '#F499BE' # $baby-pink
|
||||||
|
STATSD_ENABLED = True
|
||||||
CSV_UPLOAD_BUCKET_NAME = 'preview-notifications-csv-upload'
|
CSV_UPLOAD_BUCKET_NAME = 'preview-notifications-csv-upload'
|
||||||
CONTACT_LIST_UPLOAD_BUCKET_NAME = 'preview-contact-list'
|
CONTACT_LIST_UPLOAD_BUCKET_NAME = 'preview-contact-list'
|
||||||
LOGO_UPLOAD_BUCKET_NAME = 'public-logos-preview'
|
LOGO_UPLOAD_BUCKET_NAME = 'public-logos-preview'
|
||||||
@@ -152,6 +160,7 @@ class Staging(Config):
|
|||||||
SHOW_STYLEGUIDE = False
|
SHOW_STYLEGUIDE = False
|
||||||
HTTP_PROTOCOL = 'https'
|
HTTP_PROTOCOL = 'https'
|
||||||
HEADER_COLOUR = '#6F72AF' # $mauve
|
HEADER_COLOUR = '#6F72AF' # $mauve
|
||||||
|
STATSD_ENABLED = True
|
||||||
CSV_UPLOAD_BUCKET_NAME = 'staging-notifications-csv-upload'
|
CSV_UPLOAD_BUCKET_NAME = 'staging-notifications-csv-upload'
|
||||||
CONTACT_LIST_UPLOAD_BUCKET_NAME = 'staging-contact-list'
|
CONTACT_LIST_UPLOAD_BUCKET_NAME = 'staging-contact-list'
|
||||||
LOGO_UPLOAD_BUCKET_NAME = 'public-logos-staging'
|
LOGO_UPLOAD_BUCKET_NAME = 'public-logos-staging'
|
||||||
@@ -167,6 +176,7 @@ class Live(Config):
|
|||||||
SHOW_STYLEGUIDE = False
|
SHOW_STYLEGUIDE = False
|
||||||
HEADER_COLOUR = '#005EA5' # $govuk-blue
|
HEADER_COLOUR = '#005EA5' # $govuk-blue
|
||||||
HTTP_PROTOCOL = 'https'
|
HTTP_PROTOCOL = 'https'
|
||||||
|
STATSD_ENABLED = True
|
||||||
CSV_UPLOAD_BUCKET_NAME = 'live-notifications-csv-upload'
|
CSV_UPLOAD_BUCKET_NAME = 'live-notifications-csv-upload'
|
||||||
CONTACT_LIST_UPLOAD_BUCKET_NAME = 'production-contact-list'
|
CONTACT_LIST_UPLOAD_BUCKET_NAME = 'production-contact-list'
|
||||||
LOGO_UPLOAD_BUCKET_NAME = 'public-logos-production'
|
LOGO_UPLOAD_BUCKET_NAME = 'public-logos-production'
|
||||||
@@ -186,6 +196,7 @@ class CloudFoundryConfig(Config):
|
|||||||
class Sandbox(CloudFoundryConfig):
|
class Sandbox(CloudFoundryConfig):
|
||||||
HTTP_PROTOCOL = 'https'
|
HTTP_PROTOCOL = 'https'
|
||||||
HEADER_COLOUR = '#F499BE' # $baby-pink
|
HEADER_COLOUR = '#F499BE' # $baby-pink
|
||||||
|
STATSD_ENABLED = True
|
||||||
CSV_UPLOAD_BUCKET_NAME = 'cf-sandbox-notifications-csv-upload'
|
CSV_UPLOAD_BUCKET_NAME = 'cf-sandbox-notifications-csv-upload'
|
||||||
LOGO_UPLOAD_BUCKET_NAME = 'cf-sandbox-notifications-logo-upload'
|
LOGO_UPLOAD_BUCKET_NAME = 'cf-sandbox-notifications-logo-upload'
|
||||||
NOTIFY_ENVIRONMENT = 'sandbox'
|
NOTIFY_ENVIRONMENT = 'sandbox'
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ from notifications_utils.clients.antivirus.antivirus_client import (
|
|||||||
AntivirusClient,
|
AntivirusClient,
|
||||||
)
|
)
|
||||||
from notifications_utils.clients.redis.redis_client import RedisClient
|
from notifications_utils.clients.redis.redis_client import RedisClient
|
||||||
|
from notifications_utils.clients.statsd.statsd_client import StatsdClient
|
||||||
from notifications_utils.clients.zendesk.zendesk_client import ZendeskClient
|
from notifications_utils.clients.zendesk.zendesk_client import ZendeskClient
|
||||||
|
|
||||||
antivirus_client = AntivirusClient()
|
antivirus_client = AntivirusClient()
|
||||||
|
statsd_client = StatsdClient()
|
||||||
zendesk_client = ZendeskClient()
|
zendesk_client = ZendeskClient()
|
||||||
redis_client = RedisClient()
|
redis_client = RedisClient()
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class Navigation:
|
|||||||
def endpoints_without_navigation(self):
|
def endpoints_without_navigation(self):
|
||||||
return tuple(
|
return tuple(
|
||||||
self._get_endpoint_with_blueprint(endpoint) for endpoint in self.exclude
|
self._get_endpoint_with_blueprint(endpoint) for endpoint in self.exclude
|
||||||
) + ('static', 'status.show_status', 'metrics')
|
) + ('static', 'status.show_status')
|
||||||
|
|
||||||
def is_selected(self, navigation_item):
|
def is_selected(self, navigation_item):
|
||||||
if request.endpoint in self.mapping[navigation_item]:
|
if request.endpoint in self.mapping[navigation_item]:
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import traceback
|
|||||||
|
|
||||||
import gunicorn
|
import gunicorn
|
||||||
|
|
||||||
from gds_metrics.gunicorn import child_exit # noqa
|
|
||||||
|
|
||||||
workers = 5
|
workers = 5
|
||||||
worker_class = "eventlet"
|
worker_class = "eventlet"
|
||||||
errorlog = "/home/vcap/logs/gunicorn_error.log"
|
errorlog = "/home/vcap/logs/gunicorn_error.log"
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ applications:
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
- logit-ssl-syslog-drain
|
- logit-ssl-syslog-drain
|
||||||
- notify-prometheus
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
NOTIFY_APP_NAME: admin
|
NOTIFY_APP_NAME: admin
|
||||||
@@ -51,6 +50,8 @@ applications:
|
|||||||
ANTIVIRUS_API_HOST: '{{ ANTIVIRUS_API_HOST }}'
|
ANTIVIRUS_API_HOST: '{{ ANTIVIRUS_API_HOST }}'
|
||||||
ANTIVIRUS_API_KEY: '{{ ANTIVIRUS_API_KEY }}'
|
ANTIVIRUS_API_KEY: '{{ ANTIVIRUS_API_KEY }}'
|
||||||
|
|
||||||
|
STATSD_HOST: 'notify-statsd-exporter-{{ environment }}.apps.internal'
|
||||||
|
|
||||||
ZENDESK_API_KEY: '{{ ZENDESK_API_KEY }}'
|
ZENDESK_API_KEY: '{{ ZENDESK_API_KEY }}'
|
||||||
|
|
||||||
TEMPLATE_PREVIEW_API_HOST: '{{ TEMPLATE_PREVIEW_API_HOST }}'
|
TEMPLATE_PREVIEW_API_HOST: '{{ TEMPLATE_PREVIEW_API_HOST }}'
|
||||||
|
|||||||
@@ -25,7 +25,3 @@ itsdangerous==1.1.0
|
|||||||
|
|
||||||
git+https://github.com/alphagov/notifications-utils.git@39.7.0#egg=notifications-utils==39.7.0
|
git+https://github.com/alphagov/notifications-utils.git@39.7.0#egg=notifications-utils==39.7.0
|
||||||
git+https://github.com/alphagov/govuk-frontend-jinja.git@v0.5.1-alpha#egg=govuk-frontend-jinja==0.5.1-alpha
|
git+https://github.com/alphagov/govuk-frontend-jinja.git@v0.5.1-alpha#egg=govuk-frontend-jinja==0.5.1-alpha
|
||||||
|
|
||||||
# gds-metrics requires prometheseus 0.2.0, override that requirement as later versions bring significant performance gains
|
|
||||||
prometheus-client==0.8.0
|
|
||||||
gds-metrics==0.2.0
|
|
||||||
|
|||||||
@@ -28,10 +28,6 @@ itsdangerous==1.1.0
|
|||||||
git+https://github.com/alphagov/notifications-utils.git@39.7.0#egg=notifications-utils==39.7.0
|
git+https://github.com/alphagov/notifications-utils.git@39.7.0#egg=notifications-utils==39.7.0
|
||||||
git+https://github.com/alphagov/govuk-frontend-jinja.git@v0.5.1-alpha#egg=govuk-frontend-jinja==0.5.1-alpha
|
git+https://github.com/alphagov/govuk-frontend-jinja.git@v0.5.1-alpha#egg=govuk-frontend-jinja==0.5.1-alpha
|
||||||
|
|
||||||
# gds-metrics requires prometheseus 0.2.0, override that requirement as later versions bring significant performance gains
|
|
||||||
prometheus-client==0.8.0
|
|
||||||
gds-metrics==0.2.0
|
|
||||||
|
|
||||||
## The following requirements were added by pip freeze:
|
## The following requirements were added by pip freeze:
|
||||||
awscli==1.18.90
|
awscli==1.18.90
|
||||||
bleach==3.1.4
|
bleach==3.1.4
|
||||||
|
|||||||
Reference in New Issue
Block a user