influxdbplatform.sh

Accessing InfluxDB on Platfrom.sh


Currently I'm trying to connect to a InfluxDB hosted on Platform.sh without any luck.

I followed the setup instruction described on https://docs.platform.sh/configuration/services/influxdb.html. After these steps the service was available on Platform.sh.

After that I used Platform.sh's community guide (https://community.platform.sh/t/how-to-access-influxdb-credentials-on-platform-sh/148) to connect to the database.

I then ran the following command and selected the application (Grafana) that is connected to the InfluxDB-service

platform tunnel:single && export PLATFORM_RELATIONSHIPS="$(platform tunnel:info --encode)"

Enter a number to choose an app:
[0] app
[1] grafana
> 1

Enter a number to choose a relationship:
[0] datadb
[1] confdb (main@confdb.internal)
> 0

SSH tunnel opened to datadb at: http://127.0.0.1:30000

Then I connected to the InfluxDB and tried to create a database:

influx -host '127.0.0.1' -port '30000'

Connected to http://127.0.0.1:30000 version 1.7.10
InfluxDB shell version: v1.7.9

> CREATE DATABASE test

ERR: error authorizing query: create admin user first or disable authentication
Warning: It is possible this error is due to not setting a database.
Please set a database with the command "use <database>".

Unfortunately the relationship JSON does not include any user or default database information:

datadb:
    -
        service: timedb
        ip: 169.254.1.23
        hostname: abcd.timedb.service._.eu-4.platformsh.site
        cluster: abcdg-feature-platform-test-1234
        host: datadb.internal
        rel: influxdb
        scheme: http
        type: 'influxdb:1.7'
        port: 8086
        url: 'http://datadb.internal:8086'

How can I connect to the database? Is there a default user or a default database? Or is it possible to define some settings in the services.yaml?

Thanks!


Solution

  • As I learned on the Platform.sh forums I had to create an admin user. After the tunnel was open I had to run:

    influx -host 127.0.0.1 -port 30000                                                                                                                                                              
    Connected to http://127.0.0.1:30000 version 1.7.10
    InfluxDB shell version: v1.7.9
    > CREATE USER admin WITH PASSWORD 'admin' WITH ALL PRIVILEGES
    

    after that I reconncted to the database using the newly created user

    influx -host 127.0.0.1 -port 30000 -username admin -password ''