diff --git a/apps/amo/templates/services/monitor.html b/apps/amo/templates/services/monitor.html index 9a7ab787f0..58f7865d5e 100644 --- a/apps/amo/templates/services/monitor.html +++ b/apps/amo/templates/services/monitor.html @@ -133,4 +133,22 @@ +{% if settings.USE_ELASTIC %} +
+

[Elastic Search] Health Check

+ +
+{% endif %} + {% endblock main_content %} diff --git a/apps/amo/views.py b/apps/amo/views.py index 8f1af5740a..b15431e0ae 100644 --- a/apps/amo/views.py +++ b/apps/amo/views.py @@ -5,6 +5,7 @@ from PIL import Image import socket import StringIO import time +import traceback import urllib2 from urlparse import urlparse @@ -19,6 +20,7 @@ from django.views.decorators.http import require_POST from django_arecibo.tasks import post import caching.invalidation import commonware.log +import elasticutils import jingo import phpserialize as php import waffle @@ -122,6 +124,16 @@ def monitor(request, format=None): msg = "Please set SPIDERMONKEY in your settings file." libraries_results.append(("Spidermonkey isn't set up.", False, msg)) + elastic_results = None + if settings.USE_ELASTIC: + status_summary['elastic'] = False + try: + health = elasticutils.get_es().cluster_health() + status_summary['elastic'] = health['status'] != 'red' + elastic_results = health + except Exception: + elastic_results = traceback.format_exc() + # Check file paths / permissions rw = (settings.TMP_PATH, settings.NETAPP_STORAGE, @@ -196,6 +208,7 @@ def monitor(request, format=None): 'hera_results': hera_results, 'mongo_results': mongo_results, 'rabbit_results': rabbit_results, + 'elastic_results': elastic_results, 'status_summary': status_summary}, status=status) diff --git a/settings.py b/settings.py index c2dde21223..7ee544f777 100644 --- a/settings.py +++ b/settings.py @@ -952,3 +952,9 @@ VALID_LOGIN_REDIRECTS = { # Secret key we send to builder so we can trust responses from the builder. BUILDER_SECRET_KEY = 'love will tear us apart' + + +## Elastic Search +ES_HOSTS = ['127.0.0.1:9200'] +ES_INDEX = 'amo' +USE_ELASTIC = True