Grafana Installation & Configuration

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

Checked on 2026-11-09 against Grafana 13.3.x. Tested with Grafana Enterprise 13.3.0 in the hands-on lab: the Grafana service of the lab starts from the 13.3.0 Enterprise image, with the provisioning folders mounted as described.

To do this by hand, follow First Steps in Grafana.

Grafana is easy to start and easy to misconfigure. A container with default settings answers on port 3000 within seconds, but the same container loses every dashboard when it is recreated without a volume, keeps the default admin password, and cannot be scaled to two instances because it stores everything in SQLite. This page shows how to run Grafana deliberately: which image, where state lives, how settings are layered, how secrets are passed, and how to see that the server is healthy. The Prometheus section has a short quick install; this page is the full treatment. How the pieces fit is on Architecture and Ecosystem. General Docker practice is in Docker resources, logging and monitoring.

What the server needs

The installation page lists the supported operating systems (Debian or Ubuntu, RHEL or Fedora, SUSE or openSUSE, macOS and Windows; others are "not recommended or supported"), the supported databases (SQLite 3, MySQL 8.0+ and PostgreSQL 12+) and the supported browsers (current Chrome/Chromium, Firefox, Safari and Edge, with JavaScript enabled). The stated minimum is 512 MB of memory and 1 CPU core, which the page presents as a floor for evaluation and not a production size; its "Sizing your deployment" section gives Small, Medium and Large tiers.

Source: Install Grafana.

Docker and Docker Compose

Two images exist: grafana/grafana-enterprise, which the official guide recommends as the default (it is free and includes all OSS features, and runs without a licence), and grafana/grafana, the open source image. Both are built on Alpine Linux. For anything beyond a throwaway test, pin a version tag instead of using latest (13.3.0 exists for both images, see the tags on Docker Hub), so that an unplanned pull never performs the 13.x storage migration for you.

The smallest run command and the volume that keeps state:

docker volume create grafana-storage
docker run -d -p 3000:3000 --name=grafana \
  --volume grafana-storage:/var/lib/grafana \
  -e "GF_SERVER_ROOT_URL=http://localhost:3000/" \
  -e "GF_PLUGINS_PREINSTALL=grafana-clock-panel" \
  grafana/grafana-enterprise:13.3.0

/var/lib/grafana holds the SQLite database, plugins and other data. A named volume is the recommended form; a bind mount works too, but the container user must be able to write to it (the guide shows --user "$(id -u)" or user: '0' in Compose).

The same thing as a Compose file, extended with what a monitored service needs: a pinned image, an admin password from a file instead of an environment value, internal metrics enabled, and a health check.

services:
  grafana:
    image: grafana/grafana-enterprise:13.3.0
    container_name: grafana
    restart: unless-stopped
    ports:
      - '3000:3000'
    environment:
      - GF_SERVER_ROOT_URL=http://localhost:3000/
      - GF_SECURITY_ADMIN_PASSWORD__FILE=/run/secrets/grafana_admin_password
      - GF_PLUGINS_PREINSTALL=grafana-clock-panel
      - GF_METRICS_ENABLED=true
      - GF_LOG_LEVEL=info
    secrets:
      - grafana_admin_password
    volumes:
      - grafana-storage:/var/lib/grafana
secrets:
  grafana_admin_password:
    file: ./secrets/grafana_admin_password.txt
volumes:
  grafana-storage: {}

Reference: Run Grafana Docker image (Compose with a named volume and plugin preinstall), Configure a Grafana Docker image (the __FILE suffix) and Compose secrets.

Things to know about this file:

  • GF_PLUGINS_PREINSTALL takes a comma-separated list of plugin IDs. Each entry can pin a version (grafana-clock-panel@1.0.1) or give a download URL with the form plugin-id@version@url, where an empty version is written as a double @. Plugins install in the background while Grafana starts (the preinstall_sync setting installs them before start). Preinstalled plugins without a pinned version update themselves at startup, except across new major versions; this is the preinstall_auto_update setting.

  • The __FILE suffix makes Grafana read a setting from a file. Docker and Compose secrets are mounted under /run/secrets/. The admin user is admin, and admin_password defaults to admin; it is applied only on the first run, when the database is created. Changing the variable later does not change an existing password: change it in the UI, or recreate the volume in a lab.

  • A custom image can bake plugins in at build time: the Dockerfile in packaging/docker/custom/ of the Grafana repository accepts the build arguments GRAFANA_VERSION (append -ubuntu for an Ubuntu base) and GF_INSTALL_PLUGINS.

  • Paths inside the image are set by GF_PATHS_* variables: GF_PATHS_CONFIG=/etc/grafana/grafana.ini, GF_PATHS_DATA=/var/lib/grafana, GF_PATHS_LOGS=/var/log/grafana, GF_PATHS_PLUGINS=/var/lib/grafana/plugins and GF_PATHS_PROVISIONING=/etc/grafana/provisioning. The last one is where data source, dashboard and alerting provisioning files are mounted (Data Sources and Provisioning Alerting Resources).

  • The Docker configuration guide says settings in a container are changed with environment variables, not by editing conf/grafana.ini.

Other ways to run it

Packages exist for Debian and Ubuntu, RHEL and Fedora and SUSE and openSUSE, plus guides for macOS, Windows, Kubernetes and the Grafana Helm chart. For Kubernetes workloads see also Kubernetes observability: logging and metrics. On a package install the service is still named grafana-server (systemctl start grafana-server, systemctl status grafana-server); only the binary command was renamed in 13.0. From a .tar.gz, start it from the install root with ./bin/grafana server (on Windows, grafana.exe server).

The grafana server and grafana cli commands

Grafana 13.0 removed the binaries grafana-server and grafana-cli. Their replacements are subcommands of one binary: grafana server and grafana cli. Anything that still calls the old names breaks on upgrade: systemd units that use ExecStart= with the old binary, Docker entrypoints, CI scripts and Ansible roles. The upgrade guide asks you to update all of them, and after upgrading to run grafana cli plugins update-all, because older plugins may stop working. The plugin installer (grafana cli plugins install) checks the grafanaDependency compatibility of each plugin since 12.0.

How configuration is layered

Grafana reads its settings in layers, and the last layer wins:

flowchart LR D["defaults.ini (never edit)"] --> C["custom.ini or grafana.ini"] C --> E["GF_ environment variables"] E --> R["Effective settings"] S["Settings stored in the database (SAML, OAuth, LDAP)"] -.-> R
  • conf/defaults.ini ships with Grafana and must not be edited.

  • The custom file overrides it: conf/custom.ini in the working directory (or /usr/local/etc/grafana/grafana.ini on some systems), /etc/grafana/grafana.ini on Linux packages, custom.ini copied from sample.ini on Windows, and /etc/grafana/grafana.ini inside the Docker image. A different path is set with the --config option. Lines that begin with a semicolon are ignored, so enabling a setting means removing the ;. Changes need a restart.

  • Environment variables override existing options. The pattern is GF_<SECTION NAME>_<KEY>, upper case, with periods and dashes replaced by underscores; use them to override existing options, not to add new ones.

  • One more source exists: the authentication settings for SAML, OAuth and LDAP stored in the database override the config file. If a change to the file "does nothing", look for stored settings.

  • On Grafana Cloud there is no file; changes go through a support request.

export GF_DEFAULT_INSTANCE_NAME=my-instance
export GF_SECURITY_ADMIN_USER=owner
export GF_AUTH_GOOGLE_CLIENT_SECRET=newS3cretKey
export GF_FEATURE_TOGGLES_newNavigation=true

Values that come from the environment, files or Vault

Inside the ini file, a value can be a reference that Grafana expands when it starts. The syntax is $__<PROVIDER>{<ARGUMENT>}, or ${<ENVIRONMENT VARIABLE>}, with three providers:

Provider Meaning Example

env

Replace with the value of an environment variable.

logs = $__env{LOGDIR}/grafana in [paths]

file

Replace with the content of a file, with leading and trailing whitespace trimmed.

password = $__file{/etc/secrets/gf_sql_password} in [database]

vault

Read from HashiCorp Vault. Grafana Enterprise only.

see the Vault integration guide linked from the configuration page

Use file (or the Docker __FILE suffix) for every password, token and secret key, so that none of them appears in the config file, in docker inspect output or in a repository. A password that contains # or ; must be wrapped in triple quotes in the ini file.

Reference: Variable expansion.

Sections you will touch first

Section Settings and defaults that matter for monitoring

[paths]

data, logs, plugins, provisioning; temp_data_lifetime defaults to 24h.

[server]

http_port (3000), http_addr, protocol, root_url (must include the sub-path if Grafana is served under one, and is what alert notifications link back to), enable_gzip (now true by default).

[database]

type is sqlite3 (default, not recommended for production), mysql or postgres.

[security]

admin_user and admin_password (both admin, first run only), cookie_secure (false by default; set true behind HTTPS), allow_embedding (false).

[auth]

login_maximum_lifetime_duration (30d), token_rotation_interval_minutes (10).

[unified_alerting]

enabled (true), evaluation_timeout (30s), min_interval (10s: the shortest evaluation interval a rule may use).

[unified_alerting.state_history]

Alert state history; needs Loki (or a Prometheus target data source) on OSS and Enterprise (Monitoring Alerts and State History).

[recording_rules]

default_datasource_uid is the fallback target of Grafana-managed recording rules (Recording Rules).

[log]

mode (console file), level (info), and per-logger levels with filters, for example filters = sqlstore:debug,plugins:info.

[metrics]

Internal metrics; see below.

SQLite is the default database but the docs advise against it in production; for a shared or HA setup use MySQL or PostgreSQL (the Bookshelf PostgreSQL can host Grafana’s database too, in a separate database).

Source: Configure Grafana (each section is a heading on that page, for example #database, #security, #unified_alerting, #log).

Feature toggles

Some capabilities are switched by feature toggles. In the file they are individual entries in [feature_toggles] with the form FEATURE_NAME = value (the older enable = a b c list is deprecated and will be removed in a later major release); as an environment variable they look like GF_FEATURE_TOGGLES_newNavigation=true. Each toggle has a stage: generally available (usually enabled by default and can be disabled), public preview (supported, with possibly limited help), or a development stage (needs the application mode set to development first). Experimental toggles are listed only on the page of the feature they affect. Treat preview and experimental features as changeable: do not build production alerts on a feature that is documented as experimental, and record which toggles you set, because they are part of the configuration that must be reproduced in every environment. Grafana 13 removed the toggle that disabled the Scenes-based dashboards, so dashboards always use the new architecture.

[feature_toggles]
; explicitly turn off a toggle that is on by default
exploreMixedDatasource = false

Source: Feature toggles and the [feature_toggles section].

High availability basics

Running two or more Grafana servers behind a load balancer needs:

  • A shared MySQL or PostgreSQL database. SQLite cannot be shared; all nodes point at the same database in the [database] section.

  • A load balancer with one hostname for the cluster. SSL termination is recommended; session affinity is not required, because sessions are stored with the default database-backed token strategy. On Enterprise, the licence token is issued for the shared hostname and root_url is set to it on every node.

  • Alerting HA. Grafana Alerting runs every rule on every server and sends each notification once; it does not spread the evaluation load across servers. Nodes find each other with the gossip settings in [unified_alerting], with port 9094 open over both TCP and UDP:

[unified_alerting]
enabled = true
ha_listen_address = "${POD_IP}:9094"
ha_peers = "grafana-alerting.grafana:9094"
ha_advertise_address = "${POD_IP}:9094"
ha_peer_timeout = 15s
ha_reconnect_timeout = 2m

Reference: Configure alerting high availability (this example is for Kubernetes, where POD_IP is exposed from status.podIP and ha_peers points at a headless Service). Redis is the alternative transport only when servers cannot reach each other directly (ha_redis_address and related settings). Verify with the metrics grafana_alertmanager_cluster_members (member count) and grafana_alertmanager_peer_position (numbered from zero); before 12.4 these had no grafana_ prefix. The detailed alerting side is on Alerting HA and Operations.

Monitoring Grafana itself

A monitoring system that nobody monitors fails silently, so scrape Grafana. Internal metrics are served at /metrics (and backend plugin metrics at /metrics/plugins/<plugin id>). The [metrics] section has enabled (documented default true), interval_seconds (default 10), disable_total_stats, and basic_auth_username and basic_auth_password (basic auth applies only when both are set). The exposed metrics include counts of dashboards, users and playlists, HTTP status codes and request durations, active alerts and performance. HTTP request metrics are exposed as native and classic histograms; set classic_http_histogram_enabled = false to keep only native histograms and reduce cardinality.

scrape_configs:
  - job_name: 'grafana_metrics'
    scrape_interval: 15s
    scrape_timeout: 5s
    static_configs:
      - targets: ['grafana:3000']

Reference: Set up Grafana monitoring (the page shows the target as localhost:3000; in Compose use the service name). If basic auth is enabled on /metrics, add the credentials to the Prometheus job as described in the Prometheus scrape_config reference. Grafana can also emit Jaeger or OTLP traces for its own HTTP API and propagate trace context to data sources (see the OpenTelemetry section of the configuration reference), and logs go to the console and the file under GF_PATHS_LOGS.

The go_sql_stats_* and grafana_database_conn_* metrics are deprecated in 13.0 (use go_sql_max_open_connections and go_sql_open_connections), and grafana_caching_items and grafana_caching_size were removed, so dashboards copied from older articles may show gaps. Alert on Grafana being down (the up series of this job) and on alert rule evaluation failures; the alerting side of self-monitoring is on Monitoring Alerts and State History and on Meta monitoring.

Source: What’s new in 13.0 (metric changes).

What can go wrong

  • State lost on recreate. No volume on /var/lib/grafana (or a different database) means a new empty Grafana after every docker compose down -v or image change. Use the named volume, or better a PostgreSQL database plus provisioning.

  • A secret in the environment. Plain GF_SECURITY_ADMIN_PASSWORD=... shows in docker inspect and in process listings; use the file form.

  • The password "did not change". admin_password is first-run only.

  • Unpinned image tag. An unplanned pull upgrades across a major version and runs the storage migration.

  • Old binary names. grafana-server and grafana-cli calls fail after 13.0; the systemd service name does not change.

  • root_url wrong. Notification links and OAuth redirects use it; behind a proxy it must be the external URL.

  • Unreadable provisioning files. If the container user cannot read the mounted files, the data source or alert rule does not appear; check docker logs grafana first.

  • The image renderer. The Image Renderer plugin is no longer supported since 13.0; screenshots and scheduled reports need the separate renderer service, with the same renderer_token on both sides (see Set up image rendering).

Verify it in the lab

  1. Create secrets/grafana_admin_password.txt with a test password (write it with printf so that no trailing newline is added), then run docker compose up -d with the Compose file above, or start the lab with docker compose --profile grafana up -d from Hands-on Lab.

  2. curl -s http://localhost:3000/api/health returns "database": "ok" and the version 13.3.0.

  3. Sign in as admin with the password from the file. Open Administration > Plugins and data > Plugins and confirm that the clock panel was preinstalled.

  4. curl -s http://localhost:3000/metrics | grep -c '^grafana_' returns a non-zero count.

  5. docker compose down then docker compose up -d again: the user, dashboards and plugin are still there because of the volume.

  6. Add GF_LOG_LEVEL=debug, recreate the container and watch docker logs grafana: the setting took effect without touching a file.

In the books

McCollam (Getting Started with Grafana, chapter 3 "Deploying Grafana Locally", chapter 12 "Advanced Deployment and Management", Grafana 8.2/8.3) and Salituro (Learn Grafana 10.x, chapter 1 "Installing Grafana", Grafana 10) explain installation per platform and the same ini layering, which is unchanged. What differs now: the commands grafana-server and grafana-cli are replaced by grafana server and grafana cli; Docker is the documented default and grafana/grafana-enterprise is the recommended image; the official Docker examples install plugins with GF_PLUGINS_PREINSTALL (the GF_INSTALL_PLUGINS build argument remains for custom images); alerting HA is the unified alerting memberlist, not legacy alert deduplication; and dashboards live in unified storage, not in the old SQL tables the books describe. See the bibliography for the publisher pages.