# Self-host Grafana

> Dashboard and alerting server that queries metrics, logs and traces from many data sources and visualizes them. Run your own Grafana on an always-on EnvHaven workspace by asking its coding agent: one request installs it, puts it on an HTTPS address and locks it down. What the agent takes care of, and the manual route.

_Updated November 23, 2026_

Running your own Grafana usually means a list of server chores: a machine that stays on, Docker or a runtime, a reverse proxy with certificates, a domain, and the settings that make Grafana behave behind all of it. On an EnvHaven workspace you skip the list. You ask the coding agent, and it does the work while you watch.

## Just ask your agent

Open a Plus workspace (Grafana runs in Docker, which Plus and Pro include), tap **Launch** to start any coding agent (Claude Code, Codex, OpenCode or another), and ask it:

```text
Set up Grafana on this workspace and give me the link. Follow https://envhaven.com/self-host/grafana.md
```

Then open the link it sends and create your Grafana account straight away, before anyone else finds the address. That is the whole request: the address in it is this page's Markdown copy, and the agent follows the instructions for it further down, with every setting Grafana's docs require.

## Or keep it private with Tailscale

The preview URL puts Grafana on the public internet, which suits something other people need to reach. For an app only you and your household use, your tailnet is the better home: Tailscale gives Grafana an HTTPS address that only your own devices, signed in to your Tailscale account, can open. Save a Tailscale auth key in the workspace's **Vars** pane as `TS_AUTHKEY`, and ask the agent:

```text
Set up Grafana on my tailnet instead of the preview URL. Follow https://envhaven.com/self-host/grafana.md and https://envhaven.com/guides/self-host-privately-with-tailscale.md
```

- A Tailscale container runs beside Grafana, so it keeps its private address through workspace restarts and updates, and every app you set up this way gets an address of its own.
- Anything other services have to reach, such as a webhook, still needs a public address. [Keep self-hosted apps private with Tailscale](https://envhaven.com/guides/self-host-privately-with-tailscale) covers both, and what Tailscale's free plan includes.

| At a glance |  |
| --- | --- |
| What it is | Developer tools and monitoring |
| License | AGPL-3.0-only |
| Runs as | Docker (`grafana/grafana`) |
| Memory | 512 MB minimum (evaluation floor); 2-4 GB for a small deployment ([docs](https://grafana.com/docs/grafana/latest/setup-grafana/installation/)) |
| Plan that fits | Plus or larger |
| Web port | 3000 |
| Documentation | [grafana.com/docs/grafana/latest/setup-grafana/installation/](https://grafana.com/docs/grafana/latest/setup-grafana/installation/) |

## What your agent takes care of

- **Installing it.** Grafana runs from the official image, `grafana/grafana`, with its data in folders under `~/apps/grafana`.
- **Putting it on an HTTPS address.** The workspace's preview URL serves it, and your own domain can too.
- **Locking it down first.** What Grafana's docs say to set before it faces the internet, below.
- **Telling you what to back up**: /var/lib/grafana (Docker GF_PATHS_DATA; grafana.db SQLite, plugins), /etc/grafana/grafana.ini and /etc/grafana/provisioning, $WORKING_DIR/data/grafana.db (binary install) and external MySQL/PostgreSQL if configured ([docs](https://grafana.com/docs/grafana/latest/administration/back-up-grafana/)).

### The settings it needs behind a proxy

- [server] root_url (env `GF_SERVER_ROOT_URL`): Full public URL used to reach Grafana; needed for OAuth callbacks and when a reverse proxy serves it on a sub-path. ([docs](https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/))
- [server] domain (env `GF_SERVER_DOMAIN`): Only feeds root_url; matters for GitHub or Google OAuth. ([docs](https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/))
- [server] serve_from_sub_path (env `GF_SERVER_SERVE_FROM_SUB_PATH`): Serve under the sub-path in root_url; default false. ([docs](https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/))
- [server] enforce_domain: Redirects when the Host header does not match domain; default false. ([docs](https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/))
- [security] cookie_secure (env `GF_SECURITY_COOKIE_SECURE`): Marks the session cookie Secure; default false, set true behind HTTPS. ([docs](https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/))
- [security] csrf_trusted_origins and csrf_additional_headers: Extra origins and headers the CSRF check accepts when authentication happens behind a reverse proxy or IdP. ([docs](https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/))
- WebSocket (Grafana Live) Upgrade and Connection headers: Proxy must forward them; the docs give an nginx map $http_upgrade example. ([docs](https://grafana.com/docs/grafana/latest/setup-grafana/set-up-grafana-live/))
- GF_<SECTION NAME>_<KEY> environment variables: Override any grafana.ini option; uppercase, dots and dashes become underscores. ([docs](https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/))

### Before it faces the internet

- Default login is admin with password admin, set on first run; change it immediately. ([docs](https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/))
- Sign-in guide says to change the default administrator password. ([docs](https://grafana.com/docs/grafana/latest/setup-grafana/sign-in-to-grafana/))
- Initial admin creation can be disabled entirely. ([docs](https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/))
- Self sign-up is off by default; only an admin can create users. ([docs](https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/))
- secret_key encrypts data source secrets and cannot be changed without re-encoding them; keep it stable and back it up. ([docs](https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/))
- Embedding in iframes is blocked by default. ([docs](https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/))

## Things to ask next

Everything after the install is one more sentence to the agent. Some that come up:

- "Add a check for every site I run, and alert me on Telegram when one goes down."
- "Put it behind a login before anyone else finds the address."
- "Move Grafana to app.example.com." Add the domain on the dashboard's Domains page with a CNAME to `domains.envhaven.app`, and the agent changes Grafana's address settings to match.
- "Update Grafana to the latest release." It pulls the new image and recreates the container, data kept.

## Instructions for the agent

The agent reads these from the page's Markdown copy. They also work pasted on their own, if you would rather give them in your own words.

```text
Set up Grafana on this workspace and serve it at my preview URL.
- Use Docker Compose with the official image, grafana/grafana, starting from the docs' compose file: https://grafana.com/docs/grafana/latest/setup-grafana/installation/docker/. If `docker compose` is missing, install the Compose plugin into ~/.docker/cli-plugins first.
- Keep the compose file in ~/apps/grafana and all of its data in folders there (bind mounts, not named volumes), with restart: unless-stopped on every service.
- This server has no firewall, so publish no port on its public IP, and drop host networking and privileged mode from the docs' compose file. Docker runs on the host: connect this workspace to the compose network and relay my preview URL's port to Grafana's port 3000.
- The preview URL terminates HTTPS in front of Grafana: serve plain HTTP on its port, and trust the forwarded headers the relay passes on.
- Set what "The settings it needs behind a proxy" lists on https://envhaven.com/self-host/grafana.md for the preview URL, as Grafana's docs describe for running behind a proxy; skip any that apply only when Grafana serves HTTPS itself.
- Before the preview URL serves it, apply what "Before it faces the internet" lists on https://envhaven.com/self-host/grafana.md.
- When it answers at the preview URL, send me the link and tell me what to back up.
- If I asked for my tailnet instead of the preview URL, set Grafana up the same way but follow https://envhaven.com/guides/self-host-privately-with-tailscale.md for the network: no preview URL, no relay.
```

## What to know

- In Docker, Grafana's containers keep running when the workspace restarts or updates. The relay from the preview URL is a process in the workspace, so after a restart or an update, ask the agent to restore it.
- Image rendering is optional (small installs may run it on the same host) but each renderer worker uses about 1 GB of memory, which is heavy for a small VPS. ([docs](https://grafana.com/docs/grafana/latest/setup-grafana/installation/))
- Email is off until [smtp] is configured; the default SMTP host is localhost:25 and implicit TLS uses port 465. ([docs](https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/))
- Without a volume the Docker container loses all dashboards and users when removed. ([docs](https://grafana.com/docs/grafana/latest/setup-grafana/installation/docker/))
- SQLite is not recommended for production; use external MySQL or PostgreSQL for anything past a small instance. ([docs](https://grafana.com/docs/grafana/latest/setup-grafana/installation/))
- Live streaming and notifications use WebSocket; an HTTP-only tunnel must pass Upgrade headers or Live features break. ([docs](https://grafana.com/docs/grafana/latest/setup-grafana/set-up-grafana-live/))
- A workspace has one preview URL and one custom domain, both serving the same port, so it puts one app on a public address at a time.

## Without a workspace

The manual route, on a server you run:

1. Rent a Linux VPS, secure SSH, and create a user for the app.
2. Install Docker and write a compose file from the official image.
3. Put a reverse proxy in front (Caddy, nginx or Traefik), get certificates, and point a domain at the server.
4. Set the proxy settings listed above for that domain, and pass WebSocket upgrades through the proxy if the app uses them.
5. Keep the firewall closed except for the proxy, and schedule backups and updates.

Grafana's own [documentation](https://grafana.com/docs/grafana/latest/setup-grafana/installation/) covers each step for its install methods.

## Sources

Facts about Grafana come from its own documentation, checked on 2026-11-23:

- [grafana.com/docs/grafana/latest/setup-grafana/installation](https://grafana.com/docs/grafana/latest/setup-grafana/installation/)
- [grafana.com/docs/grafana/latest/setup-grafana/installation/docker](https://grafana.com/docs/grafana/latest/setup-grafana/installation/docker/)
- [grafana.com/docs/grafana/latest/setup-grafana/configure-grafana](https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/)
- [grafana.com/docs/grafana/latest/setup-grafana/set-up-grafana-live](https://grafana.com/docs/grafana/latest/setup-grafana/set-up-grafana-live/)
- [grafana.com/docs/grafana/latest/administration/back-up-grafana](https://grafana.com/docs/grafana/latest/administration/back-up-grafana/)
- [grafana.com/docs/grafana/latest/setup-grafana/sign-in-to-grafana](https://grafana.com/docs/grafana/latest/setup-grafana/sign-in-to-grafana/)

## Keep reading

- [Self-host any app with your agent](https://envhaven.com/self-host)
- [Self-host Gitea](https://envhaven.com/self-host/gitea)
- [Self-host Forgejo](https://envhaven.com/self-host/forgejo)
- [Self-host Uptime Kuma](https://envhaven.com/self-host/uptime-kuma)
- [Self-host Gatus](https://envhaven.com/self-host/gatus)
- [AI agent hosting](https://envhaven.com/guides/ai-agent-hosting)

Source: https://envhaven.com/self-host/grafana
