A simple dockerized Django-based Elasticsearch monitor. Have all your clusters at one place and immediately know if any one of them is down.
- Is your Elasticsearch Cluster down?
- Is your Ingest pipeline/logstash working properly?
- What is the health of the cluster? (Green/Yellow/Red)
DO NOT MISS THE FOLLOWING STEPS
-
Clone the repo
$ git clone https://github.com/govind-menon110/django-elasticsearch-monitor-dashboard.git
-
Configure the env variables
$ cd django-elasticsearch-monitor-dashboard
$ vi .env
SECRET_KEY=5(15ds+i2+%ik6z&!yer+ga9m=e%jcqiz_5wszg)r-z!2--b2d #Change this DB_NAME=postgres #Note this DB_USER=postgres DB_PASS=postgres DB_SERVICE=postgres DB_PORT=5432 SU_NAME=admin #Change this SU_PASS=Admin123@ #Change this SU_EMAIL=admin@test.com
$ vi .env.db
POSTGRES_USER=postgres POSTGRES_PASSWORD=postgres POSTGRES_DB=postgres #Same as DB_Name
-
Configure the docker-compose file
$ vi docker-compose.yml
version: '3.7' services: web: restart: always build: context: ./django_es dockerfile: Dockerfile expose: - "8000" links: - postgres:postgres volumes: - web-static:/static env_file: .env command: sh -c "/usr/local/bin/gunicorn django_es.wsgi:application -w 3 -b :8000 && /bin/python manage.py collectstatic --no-input" nginx: restart: always build: ./nginx ports: - "80:80" volumes: - web-static:/static links: - web:web postgres: # Must be same as DB_Name restart: always image: postgres:latest ports: - "5432:5432" env_file: - ./.env.db volumes: - pgdata:/var/lib/postgresql/data/ volumes: web-static: pgdata:
-
Update the nginx config if you need to
-
Fill in details of your elasticsearch cluster (I assume you are still in the root directory of the project)
$ vi ./django_es/config.json
If for example your elasticsearch cluster has the following properties:
1. Name: My_ES 2. ES_URL: http://1.1.1.1:9200 3. Kibana_URL: http://1.1.1.1:5601 4. Query Index: /logstash-*/_search?pretty or 'x' # Note that the url slug must begin with '/' 5. Kibana_Filter: URL of Dashboard or 'x' 6. doc_limit: INTEGER (Baseline of logs that one generally observes for half hour) 7. ES_DESC: Description of ES
The
config.json
would look like the following:[ { "id":"1", "es_name":"My ES", "es_url":"http://1.1.1.1:9200", "kibana_url":"http://1.1.1.1:5601", "query_index":"/logstash-*/_search?pretty", "kibana_filter":"http://1.1.1.1:5601", "doc_limit":"1000", "es_desc":"This is my ES for testing the ES Monitor application" }, { "id":"2", "es_name":"YOUR_ES_NAME", "es_url":"https://ES_URL", "kibana_url":"KIBANA_URL", "query_index":"/ES_INDEX-*/_search?pretty", "kibana_filter":"DASHBOARD/CUSTOM_SEARCH URL", "doc_limit":"0", "es_desc":"DESCRIPTION" } ]
-
Although not necessary, do customize the dashboad according to your needs through the template files
base.html
andhome.html
located here
-
Install Docker and Docker-compose according to your system
$ sudo apt install docker docker-compose -y
OR
$ sudo yum install docker docker-compose -y
-
Start docker daemon
$ systemctl start docker
-
Run docker-compose
$ sudo `which docker-compose` up -d
-
Migrate the database
$ sudo `which docker-compose` run -d web python manage.py migrate
-
Wait for 120s (> 2mins) or so
Your dashboard would be ready!
If you wish to add/remove Elasticsearch clusters or change anything in the config.json
file or in the template files, then, after updating the same in the folder on host system, run the following to reflect the changes in docker as well:
$ sudo `which docker-compose` up -d --build --force-recreate
- Dockerizing Django Blog Post 1
- Dockerizing Django Blog Post 2
- Dockerizing Django Blog Post 3 and its github repo
- Dockerizing Django Blog Post 4
- Rebuilding Docker container after config change
- Performing Migrations in Django Docker container
- Creating a default superuser in Django Docker containercreate-django-super-user-in-a-docker-container-without-inputting-password
- Clean Restart of Docker Containers
- Executing multiple commands in docker-compose