Purpose

Level: medium.

The purpose of this post is to integrate InfluxDB TICK Stack to your existing web application served by Apache. These are two possible scenarios:

  • Monitor your web application using TICK.
  • Monitor other applications and systems using TICK from your website.

Before you begin

In this tutorial, we’ll learn how to install TICK Stack and proxy pass its UI called Chronograf using Apache Server. The installation of TICK has been tested in Ubuntu/Debian but a Linux/Mac OS machine with Docker and Docker Compose is good enough to follow this tutorial.

Start TICK stack with Docker-compose

The oficial GitHub repository TICK-docker is not up to date, but we can use the last version 1.3 and change the Docker image versions on it. So first step is to clone the repository:

git clone https://github.com/influxdata/TICK-docker.git
cd TICK-docker/1.3

Next step is to update the docker-compose.yml. influxdb-cli and kapacitor-cli are not necessary for this example because we are not going to use the influx CLI tool. Telegraf should be installed on the server to monitor and we can skip it for the purpose of this example as well.

The Influxdb, Chronograf and Kapacitor Docker Compose services that we are using here are newer versions than the current 1.3 TICK Stack version. Finally and for security reasons, the ports section of the Kapacitor can be commented. The final docker-compose.yaml should look like this:

version: '3'

services:
  # Define an InfluxDB service
  influxdb:
    image: influxdb:1.5
    volumes:
      - ./data/influxdb:/var/lib/influxdb
    ports:
      - "8086:8086"
  # Define a Chronograf service
  chronograf:
    image: chronograf:1.7.10
    environment:
      INFLUXDB_URL: http://influxdb:8086
      KAPACITOR_URL: http://kapacitor:9092
    ports:
      - "8888:8888"
    links:
      - influxdb
      - kapacitor
  # Define a Kapacitor service
  kapacitor:
    image: kapacitor:1.5.2
    environment:
      KAPACITOR_HOSTNAME: kapacitor
      KAPACITOR_INFLUXDB_0_URLS_0: http://influxdb:8086
    links:
      - influxdb
    # ports:
    #   - "9092:9092"

Once we have updated the previous file we can start the containers:

docker-compose up -d

Finally, check Chronograf is up and running by going to http://localhost:8888 or the URL of your server. If we can see the homepage of the Chronograf the installation of TICK stack using Docker is finished.

Start Apache with Docker-compose

For the purpose of this example will add an Apache server (Bitnami Docker image version) at the bottom of the docker-compose.yml file:

  apache:
    image: bitnami/apache:2.4
    ports:
      - 80:8080
      - 443:8443

Command to starts the Apache server:

docker-compose up -d apache

Finally, check Apache is up and running by going to http://localhost:80 or the URL of your server.

TICK and Apache integration

First of all you should decide in which subpath you want to server the TICK stack. For example, if you have the homepage of your application at / you could have the Chronograf at /monitoring.

Secondly, in order to display the Chronograf on /monitoring you need to configure the docker-compose.yaml file adding a new environment variable called BASE_PATH to the Chronograf service with the selected subpath like the following example:

chronograf:
    image: chronograf:1.7.10
    environment:
      INFLUXDB_URL: http://influxdb:8086
      KAPACITOR_URL: http://kapacitor:9092
      BASE_PATH: /monitoring

Thirdly, the following Apache configuration my_vhost.conf file should created and mounted as a volume to the docker-compose.yml file:

my_vhost.conf:

<VirtualHost *:8080>
  ServerName www.example.com
  ProxyPreserveHost On
  ProxyPass /monitoring http://chronograf:8888/monitoring
  ProxyPassReverse /monitoring http://chronograf:8888/monitoring
</VirtualHost>

docker-compose.yml

  # Define a Apache service
  apache:
    image: bitnami/apache:2.4
    ports:
      - 80:8080
      - 443:8443
    volumes:
      - ./my_vhost.conf:/vhosts/my_vhost.conf:ro

Finally, run docker-compose up -d again to re-deploy previous services and check the Chronograf is up and running by going to http://localhost/monitoring or the URL of your server.

Although is not the purpose of this post, if you want to see data flowing to the TICK stack you need to deploy Telegraf in the server that you want to monitor pointing to the previous installation.

TICK Stack is one of the most popular Docker OSS monitoring tools but obviously not the only one. In further posts will consider other container monitoring tools. Thanks for reading post.

Finally, you should definitely take a look at these books to fuel your Apache HTTP Server knowledge: