Alert migration failure: could not get migration log error=failed to check table existence: pq: role \"test\" does not exist

  • What Grafana version and what operating system are you using?

grafana/grafana:latest

  • What are you trying to achieve?

Installing Grafana with Postgres as a database backend (not sqlite or mysql)

  • How are you trying to achieve it?

docker-compose.yml:

  postgres:
    image: postgres:latest # tried :14 and :13
    hostname: postgres
    restart: unless-stopped
    environment:
      - POSTGRES_DB
      - POSTGRES_USER
      - POSTGRES_PASSWORD
    volumes:
      - postgres:/var/lib/postgresql/data

  grafana:
    image: grafana/grafana-enterprise
    hostname: grafana
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    user: 1000
    environment:
      - TZ
      - GF_INSTALL_PLUGINS
      - GF_SECURITY_DISABLE_INITIAL_ADMIN_CREATION
      - GF_DATABASE_TYPE
      - GF_DATABASE_HOST
      - GF_DATABASE_NAME
      - GF_DATABASE_USER
      - GF_DATABASE_PASSWORD
      - GF_DATABASE_SSL_MODE
    depends_on:
      - postgres
    volumes:
      - grafana:/var/lib/grafana
    labels:
      traefik.enable: true
      ...
    networks:
      default:
      traefik:
  • What happened?

Grafana does not populate the database:

logger=migrator t=2023-07-04T12:11:36.382013641+02:00 level=error msg="alert migration failure: could not get migration log" error="failed to check table existence: pq: role \"test\" does not exist"

I can successfully connet to the database:

docker compose exec postgres psql -h localhost -U grafana grafana
  • What did you expect to happen?

Grafana should populate the database with its database scheme.

  • Can you copy/paste the configuration(s) that you are having problems with?

See above

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

Do not reach the UI. Successfully tested with default sqlite database.

  • Did you follow any online instructions? If so, what is the URL?

Deep research without any luck. Not much findings about Grafana and Postgres in Docker environment.

We have some applications running with Docker an Postgres without any problems.

1 Like