Skip to content

Dockerfile to run Grafana (monitoring) on Dokku (mini-Heroku)

License

Notifications You must be signed in to change notification settings

d1ceward/grafana_on_dokku

Grafana Dokku Maintenance

Run Grafana on Dokku

Perquisites

What is Grafana?

Grafana is an open source, feature rich metrics dashboard and graph editor for Graphite, Elasticsearch, OpenTSDB, Prometheus and InfluxDB.

What is Dokku?

Dokku is the smallest PaaS implementation you've ever seen - Docker powered mini-Heroku.

Requirements

Setup

Note: We are going to use the domain grafana.example.com for demonstration purposes. Make sure to replace it to your domain name.

App and plugins

Create the app

Log onto your Dokku Host to create the Grafana app:

dokku apps:create grafana

Add plugins

Install, create and link PostgreSQL plugin:

# Install postgres plugin on Dokku
dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres
# Create running plugin
dokku postgres:create grafana
# Link plugin to the main app
dokku postgres:link grafana grafana

Configuration

Add GF_DATABASE_URL and GF_SERVER_HTTP_PORT to environement variables

# Show all enironement variables to copy content of DATABASE_URL variable
dokku config grafana
# Set GF_DATABASE_URL
dokku config:set grafana GF_DATABASE_URL='previously_copied_database_url'
# Set port to 5000
dokku config:set grafana GF_SERVER_HTTP_PORT=5000

Setting secret key

dokku config:set grafana GF_SECURITY_SECRET_KEY=$(echo `openssl rand -base64 45` | tr -d \=+ | cut -c 1-32)

Domain setup

To get the routing working, we need to apply a few settings. First we set the domain.

dokku domains:set grafana grafana.example.com

Push Grafana to Dokku

Grabbing the repository

First clone this repository onto your machine.

Via SSH

git clone [email protected]:d1ceward/grafana_on_dokku.git

Via HTTPS

git clone https://github.com/d1ceward/grafana_on_dokku.git

Set up git remote

Now you need to set up your Dokku server as a remote.

git remote add dokku [email protected]:grafana

Push Grafana

Now we can push Grafana to Dokku (before moving on to the next part).

git push dokku master

SSL certificate

Last but not least, we can go an grab the SSL certificate from Let's Encrypt.

# Install letsencrypt plugin
dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git

# Set certificate contact email
dokku letsencrypt:set grafana email [email protected]

# Generate certificate
dokku letsencrypt:enable grafana

In case of an error Challenge validation has failed, please check your proxy settings:

dokku proxy:report                          # you should see http:80:5000
dokku proxy:ports-add grafana http:80:5000  # otherwise, add the proxy to the port

Wrapping up

Your Grafana instance should now be available on https://grafana.example.com.

To add Grafana plugins, simply set the environment variable named GF_INSTALL_PLUGINS:

dokku config:set grafana GF_INSTALL_PLUGINS=grafana-piechart-panel,grafana-github-datasource

About

Dockerfile to run Grafana (monitoring) on Dokku (mini-Heroku)

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks