Skip to content

Instantly share code, notes, and snippets.

@EastArctica
Last active January 9, 2026 19:40
Show Gist options
  • Select an option

  • Save EastArctica/8aeaff89d7cf8ffca1fde950c8496c2b to your computer and use it in GitHub Desktop.

Select an option

Save EastArctica/8aeaff89d7cf8ffca1fde950c8496c2b to your computer and use it in GitHub Desktop.
Home Assistant grafana + ltss setup

TLDR: Not on your home assistant server (or on it ig, you're running it like in a vm with a container or something iirc, idfk just put it off the server, you'll need a decent bit of space depending how much you're logging and how long, also set up compression or you'll find it one day with a 150GB database, totally didn't happen to me)

  1. Start this docker compose
services:
  timescale:
    container_name: timescale-ha
    image: timescale/timescaledb-ha:pg16
    restart: always # I think this is my only container marked as always on my entire system lol
    ports:
      - 5433:5432 # Pick whatever port you want, 5432 was in use by another postgres container
    environment:
      POSTGRES_PASSWORD: postgress_password_here
    volumes:
      - ./data/:/home/postgres/pgdata/data/
  grafana:
    container_name: grafana-ha
    image: grafana/grafana
    restart: unless-stopped
    user: 1000:1000
    ports:
      - 3012:3000 # This is the one you'll be using for grafana (attached screenshot)
    volumes:
      - ./grafana/:/var/lib/grafana/
  pgadmin:
    container_name: pgadmin-ha
    image: dpage/pgadmin4
    restart: unless-stopped
    ports:
      - 3016:80 # This is your admin interface for the database, basically just whenever you need to do work on it.
    environment:
      PGADMIN_DEFAULT_EMAIL: example@example.com
      PGADMIN_DEFAULT_PASSWORD: your_pgadmin_password_here_not_postgress_password
    volumes:
      - ./pgadmin:/var/lib/pgadmin
  • Note: To use pgadmin, you'll need to add your postgres server in it
  • Right click servers, Register->Server, give it a name (ex. timescale-ha), go to connection, set host name to timescale, leave port 5432 since we're connecting internally, hit save. Once this is done, or not done, just leave it, you'll know when you need it (aka things are going terribly terribly wrong)
  1. Now, your timescaledb should be set up and running, if docker logs show otherwise, idk fix it nerd. Head over to your HA install now
  2. Install LTSS from HACS
  3. Add this to your HA configuration.yaml
ltss:
  db_url: postgresql://postgres:postgress_password_here@your-server-ip:5433/homeassistant
# idk these were on the github, I don't use any of them
  chunk_time_interval: 2592000000000 # The time interval to be used for chunking in TimescaleDB in microseconds. Defaults to 2592000000000 (30 days).
# you can also specifically include and exclude, just read the docs it's easy
  1. Now, head over to your grafana instance
  2. Login, set it up, do whatever it needs
  3. Go to dashboards New -> Import -> Upload dashboard JSON file, then toss in the attached dashboard
  4. It should show grafana-postgresql-datasource with No data sources of type PostgreSQL found, click it, then Configure a new data source
  5. Click PostgreSQL
  6. Name it whatever you want, or just leave it who cares, set up the host url as timescale-ha, database name homeassistant, username postgres, password as whatever you selected, disable TLS (I guess? idk mine is disabled), set version to 15, check TimescaleDB, hit Save & test
  7. Everything good? Head back to Dashboards, then select the newly made dashboard, should be good?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment