InfluxDB (Database service)

InfluxDB is a time series database optimized for high-write-volume use cases such as logs, sensor data, and real-time analytics.

It exposes an HTTP API for client interaction. See the InfluxDB documentation for more information.

Supported versions 

Grid Dedicated Gen 3 Dedicated Gen 2
  • 2.3
None available None available

Relationship 

The format exposed in the $PLATFORM_RELATIONSHIPS environment variable:

{
    "service": "influxdb18",
    "ip": "169.254.244.110",
    "hostname": "duqbjfn7t4dwr2fi2o7bsvqafy.influxdb18.service._.eu-3.platformsh.site",
    "cluster": "rjify4yjcwxaa-master-7rqtwti",
    "host": "influxdb.internal",
    "rel": "influxdb",
    "scheme": "http",
    "type": "influxdb:1.8",
    "port": 8086
}

Usage example 

1. Configure the service 

Use the influxdb type to define the service:

.platform/services.yaml
<SERVICE_NAME>:
    type: influxdb:<VERSION>
    disk: 256

Note that if you later change the name, it’s treated as an entirely new service. This removes all data from your service. Always backup your data before changing the service.

2. Add the relationship 

Use the influxdb endpoint to define the relationship:

.platform.app.yaml
relationships:
    <RELATIONSHIP_NAME>: "<SERVICE_NAME>:influxdb"

You can define <SERVICE_NAME> and <RELATIONSHIP_NAME> as you like, but it’s best if they’re distinct.

Example Configuration 

Service definition

.platform/services.yaml
timedb:
    type: influxdb:2.3
    disk: 256

App configuration

.platform.app.yaml
relationships:
    influxtimedb: "timedb:influxdb"

Use in app 

Then use the service in your app with a configuration file like the following:

<?php
// This assumes a fictional application with an array named $settings.
if (getenv('PLATFORM_RELATIONSHIPS')) {
	$relationships = json_decode(base64_decode($relationships), TRUE);

	// For a relationship named 'influxtimedb' referring to one endpoint.
	if (!empty($relationships['influxtimedb'])) {
		foreach ($relationships['influxtimedb'] as $endpoint) {
			$settings['influxdb_host'] = $endpoint['host'];
			$settings['influxdb_port'] = $endpoint['port'];
			break;
		}
	}
}

Exporting data 

InfluxDB includes its own export mechanism. To gain access to the server from your local machine open an SSH tunnel with the Platform.sh CLI:

platform tunnel:open

That opens an SSH tunnel to all services on your current environment and produce output like the following:

SSH tunnel opened on port 30000 to relationship: influxtimedb

The port may vary in your case. Then run InfluxDB’s export commands as desired.

influx_inspect export -compress