Skip to content

Latest commit

 

History

History
59 lines (51 loc) · 1.58 KB

File metadata and controls

59 lines (51 loc) · 1.58 KB

WriteData

This is an example how to write data with Data Point structure.

Prerequisites:

  • Docker
  • Cloned examples:
    git clone [email protected]:influxdata/influxdb-client-swift.git
    cd Examples/WriteData

Sources:

How to test:

  1. Start InfluxDB:
    docker run --rm \
      --name influxdb_v2 \
      --detach \
      --publish 8086:8086 \
      influxdb:latest
  2. Configure your username, password, organization, bucket and token:
    docker run --rm \
       --link influxdb_v2 \
       curlimages/curl -s -i -X POST http://influxdb_v2:8086/api/v2/setup \
          -H 'accept: application/json' \
          -d '{"username": "my-user", "password": "my-password", "org": "my-org", "bucket": "my-bucket", "token": "my-token"}'
  3. Start SwiftCLI by:
     docker run --rm \
       --link influxdb_v2 \
       --privileged \
       --interactive \
       --tty \
       --volume $PWD/../..:/client \
       --workdir /client/Examples/WriteData \
       swift:5.7 /bin/bash
  4. Write data by:
    swift run write-data --bucket my-bucket --org my-org --token my-token --url http://influxdb_v2:8086

Expected output

Written data:

        - Point: measurement:demo, tags:["type": Optional("point")], fields:["value": Optional(2)], time:nil
        - Point: measurement:demo, tags:["type": Optional("point-timestamp")], fields:["value": Optional(2)], time:2020-12-10 11:16:29 +0000

Success!