Aiven services are managed from Aiven web console. First login to the console with your email address and password and you will be automatically taken to the "Services" view that shows all the services of the currently selected project.

Projects allow organizing groups of services under different topics and each project can for example have different billing settings. An empty project is created for you automatically when you sign-up and the free credits are attached to this project. You can create new projects by clicking the project name in the left side-bar and selecting "Create a new project". The same menu can also be used to switch between projects.

To get started with InfluxDB, first click the "Create a new service" button.

The dialog that opens allows you to specify the main service properties:

  • Service name: A short name for the service used to distinguish it from other services. A random name is provided, but you can type in a more friendly name.
  • Service type: Select "InfluxDB".
  • Plan: What kind of memory/CPU/disk resources will be allocated to run your service.
  • Cloud: Which cloud and region to run the service on. Note that the pricing of the same service may differ between cloud providers and their regions.

After making the selections, click the "Create" button and you will be taken back to the service list view and the newly created service is shown with an indicator that it is being created.

Click the service name in the list and the "Overview" information page for the service opens. This view shows the connection parameters for your service, its current status and allows making changes to the service.

The "Status" indicator will say "Rebuilding" while the service is being created for you. Once the service is up and running, the light will change to green and it will say "Running". Note that while typically services start in a couple of minutes, the performance between clouds varies and it can take longer under some circumstances.

Backups

InfluxDB backups are taken every twelve hours and are encrypted and stored securely in object storage.

InfluxDB command-line example

There are multiple ways you can try out your new InfluxDB service, you can copy-paste the connection parameters from the overview page to use in the following examples.

influx -host influx-23ee4d7e.demoprj.aivencloud.com -port 20188 \
       -database 'defaultdb' -username 'avnadmin' \
       -password 'krx4mpjiz498m7zc' \
       -ssl -unsafeSsl

Python example


You can also try to connect to InfluxDB programmatically, here's a short Python example using the python-influxdb  library, this example uses the Service URI you can copy-paste from the service overview page.

from influxdb import InfluxDBClient
import datetime

# Copy the service URI from the console here

uri = "https+influxdb://avnadmin:krx4mpjiz498m7zc@influx-23ee4d7e.demoprj.aivencloud.com:20188/defaultdb"

# If you get an AttributeError, please use the older .from_DSN() method
# naming. Python-InfluxDB unfortunately renamed this method without
# providing any backwards compatibility
influxdb_client = InfluxDBClient.from_dsn(uri, timeout=3.0, ssl=True)

json_body = [
    {
        "measurement": "cpu_load_short",
        "tags": {
            "host": "testnode",
        },
        "time": datetime.datetime.now().isoformat(),
        "fields": {
            "value": 0.95,
        },
    }
]
influxdb_client.write_points(json_body)

Node.js example

For a secured Node.js you can download the CA certificate ca.pem  from the Aiven web console by clicking the "Show CA Certificate" button. The library used in the this example is node-influx, of which the version 5.0.7 or newer is required as older versions do not support specifying a custom CA certificate for the client connection.

var Influx = require('influx');
var fs = require('fs');
var https = require('https');

/* Open a TLS-secured connection to InfluxDB */
var ca = fs.readFileSync('ca.pem');
var i = new Influx.InfluxDB({
  protocol: 'https',
  host: 'YOURSERVICE.YOURPROJECT.aivencloud.com',
  database: 'defaultdb',
  port: YOURPORT,
  username: 'avnadmin',
  password: 'YOURPASSWORD',
  options: { ca: ca },
});

i.writePoints([
  {
    measurement: 'meas',
    tags: { host: 'foo' },
    fields: { duration: 10, path: 'bar' },
  }
]).catch(function(err) {
  console.error('Error saving data to InfluxDB!')
});

i.query(
  'select "duration", time from meas where time > now() - 1h'
).then(function(result) {
  console.log(result);
});

Did this answer your question?