[Docker] - Can't provision datasource using docker 11.3.0

Hello Everyone,

I can’t put my head around it… it seems I am doing something wrong…

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

11.3.0 on docker

  • What are you trying to achieve?

Up and run a grafana container with a pre-registrered datasource

  • How are you trying to achieve it?
docker compose up grafana --build

with docker-compose.yml

services:
  postgres:
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U grafana -d grafana"]
      interval: 10s
      timeout: 5s
      retries: 5
    image: postgres:latest
    container_name: postgres-db
    environment:
      POSTGRES_USER: grafana
      POSTGRES_PASSWORD: grafana
      POSTGRES_DB: grafana
    ports:
      - "5433:5432"
    volumes:
      - ./input/import.sql:/docker-entrypoint-initdb.d/import.sql
    restart: unless-stopped

  grafana:
#    image: grafana/grafana:latest
    build:
      context: .
      dockerfile: Dockerfile
    container_name: grafana
    depends_on:
      postgres:
        condition: service_healthy
    environment:
      - GF_DATABASE_TYPE=postgres
      - GF_DATABASE_HOST=postgres:5432
      - GF_DATABASE_NAME=grafana
      - GF_DATABASE_USER=grafana
      - GF_DATABASE_PASSWORD=grafana
      - GF_AUTH_ANONYMOUS_ENABLED=true
      - GF_FEATURE_TOGGLES_ENABLE=accessControl
      - GF_RBAC_PERMISSION_VALIDATION_ENABLED=false
      - GF_LOG_LEVEL=debug
      - GF_PROVISIONING_LOGS=trace
    ports:
      - "3000:3000"
    restart: unless-stopped
    volumes:
      - ./input/grafana.json:/home/grafana/dashboards/grafana.json
      - ./input/datasource.yaml:/usr/share/grafana/conf/provisioning/datasources/datasource.yaml

With this datasource.yaml :

apiVersion: 1
datasources:
  - name: Simple PostgreSQL
    type: postgres
    url: postgres:5432
    database: grafana
    user: grafana
    secureJsonData:
      password: grafana

  • What happened?

Nothing, the container is up and running but there is no datasources.

  • What did you expect to happen?

A datasource would be provisionned

  • 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.

Yes but not related directly to the datasource

logger=migrator t=2024-11-20T17:44:11.468343114Z level=debug msg="Executing sql migration" id="create migration_log table" sql="CREATE TABLE IF NOT EXISTS \"migration_log\" (\n\"id\" SERIAL PRIMARY KEY  NOT NULL\n, \"migration_id\" VARCHAR(255) NOT NULL\n, \"sql\" TEXT NOT NULL\n, \"success\" BOOL NOT NULL\n, \"error\" TEXT NOT NULL\n, \"timestamp\" TIMESTAMP NOT NULL\n);"
logger=migrator t=2024-11-20T17:44:12.2446933Z level=debug msg="Executing sql migration" id="create alert table v1" sql="CREATE TABLE IF NOT EXISTS \"alert\" (\n\"id\" SERIAL PRIMARY KEY  NOT NULL\n, \"version\" BIGINT NOT NULL\n, \"dashboard_id\" BIGINT NOT NULL\n, \"panel_id\" BIGINT NOT NULL\n, \"org_id\" BIGINT NOT NULL\n, \"name\" VARCHAR(255) NOT NULL\n, \"message\" TEXT NOT NULL\n, \"state\" VARCHAR(190) NOT NULL\n, \"settings\" TEXT NOT NULL\n, \"frequency\" BIGINT NOT NULL\n, \"handler\" BIGINT NOT NULL\n, \"severity\" TEXT NOT NULL\n, \"silenced\" BOOL NOT NULL\n, \"execution_error\" TEXT NOT NULL\n, \"eval_data\" TEXT NULL\n, \"eval_date\" TIMESTAMP NULL\n, \"new_state_date\" TIMESTAMP NOT NULL\n, \"state_changes\" INTEGER NOT NULL\n, \"created\" TIMESTAMP NOT NULL\n, \"updated\" TIMESTAMP NOT NULL\n);"
logger=migrator t=2024-11-20T17:44:12.326048422Z level=debug msg="Executing sql migration" id="Update alert table charset" sql="ALTER TABLE \"alert\" ALTER \"name\" TYPE VARCHAR(255), ALTER \"message\" TYPE TEXT, ALTER \"state\" TYPE VARCHAR(190), ALTER \"settings\" TYPE TEXT, ALTER \"severity\" TYPE TEXT, ALTER \"execution_error\" TYPE TEXT, ALTER \"eval_data\" TYPE TEXT;"
logger=migrator t=2024-11-20T17:44:14.058576744Z level=info msg="Executing migration" id="add snapshot error_string column"
logger=migrator t=2024-11-20T17:44:14.058618088Z level=debug msg="Executing sql migration" id="add snapshot error_string column" sql="alter table \"cloud_migration_snapshot\" ADD COLUMN \"error_string\" TEXT NULL "
logger=migrator t=2024-11-20T17:44:14.058999134Z level=info msg="Migration successfully executed" id="add snapshot error_string column" duration=424.313µs
logger=migrator t=2024-11-20T17:44:14.061908062Z level=debug msg="Executing sql migration" id="create cloud_migration_resource table v1" sql="CREATE TABLE IF NOT EXISTS \"cloud_migration_resource\" (\n\"id\" SERIAL PRIMARY KEY  NOT NULL\n, \"uid\" VARCHAR(40) NOT NULL\n, \"resource_type\" VARCHAR(40) NOT NULL\n, \"resource_uid\" VARCHAR(40) NOT NULL\n, \"status\" VARCHAR(20) NOT NULL\n, \"error_string\" TEXT NULL\n, \"snapshot_uid\" VARCHAR(40) NOT NULL\n);"
logger=plugins.registration t=2024-11-20T17:44:14.265344258Z level=error msg="Could not register plugin" pluginId=xychart error="plugin xychart is already registered"
logger=plugins.initialization t=2024-11-20T17:44:14.26535075Z level=error msg="Could not initialize plugin" pluginId=xychart error="plugin xychart is already registered"
logger=authn.service t=2024-11-20T17:44:23.956251311Z level=warn msg="Failed to authenticate request" client=auth.client.session error="user token not found"
logger=authn.service t=2024-11-20T17:45:21.607470778Z level=warn msg="Failed to authenticate request" client=auth.client.session error="user token not found"
logger=authn.service t=2024-11-20T17:45:21.632449431Z level=warn msg="Failed to authenticate request" client=auth.client.session error="user token not found"
logger=context userId=0 orgId=1 uname= t=2024-11-20T17:45:21.649060146Z level=debug msg="Failed to authenticate user in global scope" error="[anonymous.invalid-org] anonymous user cannot authenticate in org 1"
logger=authn.service t=2024-11-20T17:45:21.974414658Z level=warn msg="Failed to authenticate request" client=auth.client.session error="user token not found"
logger=authn.service t=2024-11-20T17:45:22.054824219Z level=warn msg="Failed to authenticate request" client=auth.client.session error="user token not found"
logger=authn.service t=2024-11-20T17:45:22.107860638Z level=warn msg="Failed to authenticate request" client=auth.client.session error="user token not found"
logger=authn.service t=2024-11-20T17:45:22.298912668Z level=warn msg="Failed to authenticate request" client=auth.client.session error="user token not found"
logger=authn.service t=2024-11-20T17:45:22.360382466Z level=warn msg="Failed to authenticate request" client=auth.client.session error="user token not found"
logger=authn.service t=2024-11-20T17:45:22.364504964Z level=warn msg="Failed to authenticate request" client=auth.client.session error="user token not found"
logger=authn.service t=2024-11-20T17:45:22.827979768Z level=warn msg="Failed to authenticate request" client=auth.client.session error="user token not found"
logger=authn.service t=2024-11-20T17:45:22.850616366Z level=warn msg="Failed to authenticate request" client=auth.client.session error="user token not found"
logger=context userId=0 orgId=1 uname= t=2024-11-20T17:45:22.86676849Z level=debug msg="Failed to authenticate user in global scope" error="[anonymous.invalid-org] anonymous user cannot authenticate in org 1"
logger=authn.service t=2024-11-20T17:45:23.167151889Z level=warn msg="Failed to authenticate request" client=auth.client.session error="user token not found"
logger=authn.service t=2024-11-20T17:45:23.259392958Z level=warn msg="Failed to authenticate request" client=auth.client.session error="user token not found"
logger=authn.service t=2024-11-20T17:45:27.941863168Z level=warn msg="Failed to authenticate request" client=auth.client.session error="user token not found"
  • Did you follow any online instructions? If so, what is the URL?

Robin,

where is grafana itself running?

Hello,

On my laptop on a docker run with with docker compose up --detach grafana

Changed :

    volumes:
      - ./input/grafana.json:/home/grafana/dashboards/grafana.json
      - ./input/datasource.yaml:/usr/share/grafana/conf/provisioning/datasources/datasource.yaml

To :

    volumes:
      - ./input/grafana.json:/var/lib/grafana/dashboards/grafana.json
      - ./input/dashboard.yaml:/etc/grafana/provisioning/dashboards/dashboard.yaml
      - ./input/datasource.yaml:/etc/grafana/provisioning/datasources/datasource.yaml

And dashboard.yaml :

apiVersion: 1

providers:
  # <string> an unique provider name. Required
  - name: 'a unique provider name'
    # <int> Org id. Default to 1
    orgId: 1
    # <string> name of the dashboard folder.
    folder: ''
    # <string> folder UID. will be automatically generated if not specified
    folderUid: ''
    # <string> provider type. Default to 'file'
    type: file
    # <bool> disable dashboard deletion
    disableDeletion: false
    # <int> how often Grafana will scan for changed dashboards
    updateIntervalSeconds: 10
    # <bool> allow updating provisioned dashboards from the UI
    allowUiUpdates: false
    options:
      # <string, required> path to dashboard files on disk. Required when using the 'file' type
      path: /var/lib/grafana/dashboards
      # <bool> use folder names from filesystem to create folders in Grafana
      foldersFromFilesStructure: true
1 Like