Public | Automated Build

Last pushed: 2 months ago
Short Description
Create Kibana dashboards from an external Mysql Database. Possibly through SSH.
Full Description

Setup

Add a docker-compose.yml file, following this model :

version: '2'
services:
    elk:
        image: tpettinotti/elk-jdbc
        ports:
            - "5601:5601"
            - "9200:9200"
            - "5044:5044"
        environment:
            CONNEXION_STRING: ~
            CONNEXION_USER: ~
            CONNEXION_PWD: ~
        volumes:
            - './queries:/queries'

Using SSH Tunneling option

To enable SSH tunneling, just add the following environnement variables :

    environment:
        SSH_TUNNEL_USER: ~
        SSH_TUNNEL_HOST: ~

You may want to override the default values for your tunnel, using :

    environment:
        SSH_TUNNEL_PORT: 22
        SSH_TUNNEL_MYSQL_LOCAL_PORT: 1234
        SSH_TUNNEL_MYSQL_REMOTE_HOST: 127.0.0.1
        SSH_TUNNEL_MYSQL_REMOTE_PORT: 3306

Private key authentification for SSH Tunneling

In order to use your host's private key, you need to add it to your ssh-agent. The docker-compose will share it with the container.

        environment:
            SSH_AUTH_SOCK: /ssh-agent
        volumes:
            - '$SSH_AUTH_SOCK:/ssh-agent'

Remeber to add your SSH private key to the ssh-agent.

ssh-add ~/.ssh/id_rsa

If you named your key differently, replace _idrsa in the command with the name of your private key file.

Usage

Add yours SQL queries under the queries/ directory (as defined in your docker-compose).
You need to set an 'id' column for all queries. Alias another if there is none.

Example:

queries/user.sql

SELECT * From user;

Then you can build and up your image.

Kibana : localhost:5601

Known issues

If the container stop silently after a moment, it may be a memory error

https://www.elastic.co/guide/en/elasticsearch/reference/5.0/vm-max-map-count.html#vm-max-map-count

Specific use case

Connexion to a local database in Vagrant

In order to create a SSH Tunnel to a Vagrant machine, you need to find your host IP adress from the vagrant.

Then, use it in docker-compose.yml to set the SSH_TUNNEL_HOST environnement variable. You also need to set the network_mode to host.

Docker Pull Command
Owner
tpettinotti
Source Repository