Skip to main content

InfluxDB

InfluxDB is an open source time series database that allows you to store, index and search time series data.

Set up the service

Set up an InfluxDB service

  1. List the plans available for InfluxDB by running:

    cf marketplace -s influxdb
    

    Here is an example of the output you will see:

    service plan   description                                                                            free or paid
    tiny-1.x       NOT Highly Available, 1 dedicated VM, 2 CPU per VM, 4GB RAM per VM, 16GB disk space.   free
    

    Currently, there is only one plan available for InfluxDB: tiny-1.x.

  2. Create a service instance:

    cf create-service influxdb tiny-1.x SERVICE_NAME
    

    where SERVICE_NAME is a unique descriptive name for this service instance. For example:

    cf create-service influxdb tiny-1.x my-influxdb-service
    

    It will take between 5 and 10 minutes to set up the service instance. To check its progress, run:

    cf service SERVICE_NAME
    

    for example:

    cf service my-influxdb-service
    

    When cf service SERVICE_NAME returns a create succeeded status, you have set up the service instance. An example output could be:

    name:            my-influxdb-service
    service:         influxdb
    tags:
    plan:            tiny-1.x
    description:     InfluxDB instances provisioned via Aiven
    documentation:
    dashboard:
    
    There are no bound apps for this service.
    
    Showing status of last operation from service my-influxdb-service...
    
    status:    create succeeded
    message:   Last operation succeeded
    started:   2019-11-18T10:17:30Z
    updated:   2019-11-18T10:21:35Z
    

Bind an InfluxDB service to your apps using an app manifest

You must bind your app to the InfluxDB service to access the InfluxDB database from your app.

  1. Use the app’s manifest to bind the app to the service instance. It will bind automatically when you next deploy your app.

  2. Deploy your app in line with your normal deployment process.

Refer to the Cloud Foundry documentation on deploying with app manifests for more information.

Bind an InfluxDB service to your apps using cf bind-service

If your app does not have a manifest file, you can manually bind your service instance to your app.

  1. Run the following:

    cf bind-service APP_NAME SERVICE_NAME
    

    where:

    • APP_NAME is the exact name of a deployed instance of your app
    • SERVICE_NAME is the name of the service instance you created

    For example:

    cf bind-service my-app my-influxdb-service
    
  2. Deploy your app in line with your normal deployment process.

Use the service

Read and write data to InfluxDB

When you create an InfluxDB service instance, the service broker automatically creates a database called defaultdb.

defaultdb is the only database within the InfluxDB service instance you have permissions to use. If you try to read or write data to another database, you will get an error message.

When reading from and writing to InfluxDB you must specify the database as defaultdb.

If you’re using the InfluxDB HTTP API directly, you must specify the database using the db query parameter. For example, db=defaultdb.

If you’re using an API client library, you must specify the database as defaultdb using your library’s configuration.

Using InfluxDB with Prometheus

Prometheus is an open source tool for collecting metrics.

Prometheus is, by default, a stateful app that relies on local storage. You cannot run stateful apps using local storage on GOV.UK PaaS.

Without local storage, Prometheus metrics will not persist after the Prometheus app restarts. To store Prometheus metrics for longer, you configure Prometheus to send metrics to InfluxDB for storage.

  1. Run Prometheus as an app on GOV.UK PaaS and bind that app to an InfluxDB service instance.

  2. the prometheus.yml configuration file, make sure the remote_read and remote_write sections match the same sections in the VCAP_SERVICES environment variable.

Remove the service

Unbind an InfluxDB service from your app

You must unbind the InfluxDB service before you can delete it:

cf unbind-service APP_NAME SERVICE_NAME

where:

  • APP_NAME is your app’s deployed instance name as specified in your app’s manifest.yml or push command
  • SERVICE_NAME is a unique descriptive name for this service instance

For example:

cf unbind-service my-app my-influxdb-service

If you unbind your service from your app but do not delete it, the service will persist even after you have deleted your app. You can re-bind or re-connect to it in future.

Delete an InfluxDB service

Once you have unbound the InfluxDB service from your app, you can delete the service:

cf delete-service SERVICE_NAME

where SERVICE_NAME is a unique descriptive name for this service instance. For example:

cf delete-service my-influxdb-service
Warning Deleting the InfluxDB service also deletes your InfluxDB data. This includes any backups that Aiven has taken.

IP Restrictions for InfluxDB

You can add or remove IP restrictions for an InfluxDB service instance when:

  • creating a new service instance
  • updating an existing service instance

Add IP restrictions when creating a service instance

You create a new InfluxDB service instance by running cf create-service. You can enable optional IP restrictions in this new service instance by running:

cf create-service SERVICE_NAME -c '{"ip_filter": "IPADDRESS_1,IPADDRESS_2"}'

where:

  • SERVICE_NAME is a unique descriptive name for this service instance
  • IPADDRESS_1...N are the IP addresses you wish to add to the new service

Add IP restrictions on an existing service instance

Run the following to enable optional extensions in an existing service instance:

cf update-service SERVICE_NAME -c '{"ip_filter": "IPADDRESS_1,IPADDRESS_2"}'

where:

  • SERVICE_NAME is a unique descriptive name for this service instance
  • IPADDRESS_1...N are the IP addresses you wish to add to the existing service

For example, your InfluxDB service instance is named my-influx-service and you wish to add the IP address 1.2.3.4 to the IP restrictions list. Run the following to add 1.2.3.4:

cf update-service my-influx-service -c '{"ip_filter": "1.2.3.4"}'

Removing IP addresses from an existing service

To remove all IP addresses except the mandatory PaaS ones, pass an empty value in for the ip_filter key:

cf update-service my-influx-service -c '{"ip_filter": ""}'

To remove one IP addresses from a list while keeping the mandatory PaaS ones, pass in the list without the IP address you wish to remove for the ip_filter key, for example removing 5.6.7.8 from the list of 1.2.3.4, 5.6.7.8, 9.10.11.12:

cf update-service my-influx-service -c '{"ip_filter": "1.2.3.4,9.10.11.12"}'

Maintaining the service

Data classification

You can store data classified up to Official on the GOV.UK PaaS. Refer to the data security classification documentation for more information.

InfluxDB backups

Aiven automatically backs up all data stored within any InfluxDB service you create.

Aiven takes backups every 12 hours and keeps 2 backups at a time.

To restore data to an earlier state, contact us at gov-uk-paas-support@digital.cabinet-office.gov.uk.