Version v2.7.0 of the documentation is no longer actively maintained. The site that you are currently viewing is an archived snapshot. For up-to-date documentation, see the latest version.
Use PostgreSQL as Grafana Backend
Grafana uses SQLite for its metadata by default. Pigsty v2.7 can provision a PostgreSQL user and database for Grafana, after which Grafana can be pointed at that database manually.
The old grafana_database and grafana_pgurl Pigsty parameters were already
obsolete in v2.7.0. The release’s
grafana.ini.j2
does not manage a PostgreSQL backend URL, so re-running the grafana_config
task can overwrite a manual edit. Keep the change under your own configuration
management.
Provision the database
Add the user and database to a PGSQL cluster definition:
For an existing pg-meta cluster, create them with the v2.7 helper scripts:
For a new dedicated cluster, define the same objects in its inventory and run:
The helpers correspond to
pgsql-user.yml,
pgsql-db.yml, and
pgsql.yml.
Configure Grafana
Back up the existing Grafana metadata before changing backends. Then edit the
[database] section of /etc/grafana/grafana.ini:
Restart Grafana after the connection has been verified:
Grafana performs its own metadata migrations when it starts. Pointing it at a new empty database does not copy dashboards or data sources from the previous SQLite database.
Restore dashboards and data sources
Pigsty v2.7 keeps dashboard definitions and the loader in
files/grafana:
The loader reads GRAFANA_ENDPOINT, GRAFANA_USERNAME, and
GRAFANA_PASSWORD when non-default credentials are required.
Register the databases declared in pg_databases as Grafana PostgreSQL data
sources with the v2.7 task:
This calls
roles/pgsql/tasks/register_grafana.yml,
which uses the monitor user and skips a database only when its
register_datasource flag is false.