Skip to content

recoord/heroku-grafana

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

heroku-grafana

Run Grafana on Heroku

Automated Install

Heroku-Grafana provides an automatic deployment script which will perform all of the following steps for you.

Should you wish to use this script, simply invoke it as follows:

./deploy.sh <app name>

Otherwise, please follow these steps to manually deploy Heroku-Grafana.

Manual Install

Init

  1. Install the Heroku Toolbelt
  2. Fork and clone this repo
  3. Create the app, e.g. heroku create
  4. Set the buildpack to the Null buildpack:
heroku buildpacks:add http://github.com/ryandotsmith/null-buildpack.git

Database Setup

Heroku dynos use an ephemeral filesystem, and as such will not persist changes between deployments. Specifically for Grafana, this means the database engine cannot be sqlite, but instead a Heroku database add-on. Here we are using the Postgres:

  1. Add on a database: heroku addons:create heroku-postgresql:hobby-dev
  2. View the full Postgres connection URL: heroku config:get DATABASE_URL
  3. Create Grafana environment variables based on Postgres URL:
# Postgres URL format:
# postgres://<username>:<password>@<host>/<dbname>
heroku config:set GF_DATABASE_TYPE=postgres
heroku config:set GF_DATABASE_HOST=<host>
heroku config:set GF_DATABASE_NAME=<dbname>
heroku config:set GF_DATABASE_USER=<username>
heroku config:set GF_DATABASE_PASSWORD=<password>
heroku config:set GF_DATABASE_SSL_MODE=require

Grafana also needs some configuration to use Postgres as the session provider.

First, you'll need to connect to your Postgres DB to create the session table:

# only swap out for values where <> is below
heroku pg:psql --app <app-name> DATABASE_URL

\connect <dbname>
CREATE TABLE session (key CHAR(16) NOT NULL, data bytea, expiry INT NOT NULL, PRIMARY KEY (key));

# use \dt to ensure the session table exists
\dt

Now configure Grafana to use Postgres as the session store.

heroku config:set GF_SESSION_PROVIDER=postgres
heroku config:set GF_SESSION_PROVIDER_CONFIG="$(heroku pg:credentials:url DATABASE | grep dbname | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"

If you're running Heroku on Windows, set GF_SESSION_PROVIDER_CONFIG (space-delimited) based on the output of:

heroku pg:credentials:url DATABASE

Deploy

  1. Deploy: git push heroku master
  2. View the running app: heroku open

Configuration

Most changes can be made to Grafana through the use of environment variables. It is recommended to change the Grafana security at set-up time:

heroku config:set GF_SECURITY_ADMIN_USER=<admin user>
heroku config:set GF_SECURITY_ADMIN_PASSWORD=<admin password>
heroku config:set GF_SECURITY_SECRET_KEY=<secret key>

Running locally

The binary for the Grafana server has been built specifically for the platform running on Heroku, which is 64-bit Linux. If you are running another OS, you will not be able to run this locally as-is.

# Launch the grafana server locally
heroku local web

About

Run Grafana on Heroku

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 53.1%
  • HTML 27.7%
  • CSS 16.2%
  • Shell 1.9%
  • JavaScript 1.1%