Skip to content

Instantly share code, notes, and snippets.

@esemeniuc
Last active June 16, 2025 06:29
Show Gist options
  • Save esemeniuc/87e738c27e5ddfae343eff934ba03bf0 to your computer and use it in GitHub Desktop.
Save esemeniuc/87e738c27e5ddfae343eff934ba03bf0 to your computer and use it in GitHub Desktop.
How to use Influx v3

see https://github.com/esemeniuc/influxdb/pull/1/files Build with docker build -t influxdb:3-core-test --build-arg PBS_DATE=20250106 --build-arg PBS_VERSION=3.11.11 --build-arg PBS_TARGET=x86_64-unknown-linux-gnu .

tags and fields compatibility with v1:

  • you can add and omit tags like before, all tags are strings (no need to worry about type change)
  • you can add and omit fields like before, but cannot change a field type (ie string to i64)
  • you cannot convert tag to field and vice-versa

Setup:

~/.influxdb/influxdb3 serve --node-id host01 --object-store memory
~/.influxdb/influxdb3 create token --admin --token apiv3_76Ch4tKrO7vuOZdYtewX-4pVdfSqjqTyyFmzuMzyoPN-n1kYKHXLIn7uvKC99TAL2dCjiJsSJj9pqFJL67TXMg # fixme: this only auths you to existing token, doesn't let you set your desired token

Output:

New token created successfully!

Token: apiv3_76Ch4tKrO7vuOZdYtewX-4pVdfSqjqTyyFmzuMzyoPN-n1kYKHXLIn7uvKC99TAL2dCjiJsSJj9pqFJL67TXMg
HTTP Requests Header: Authorization: Bearer apiv3_76Ch4tKrO7vuOZdYtewX-4pVdfSqjqTyyFmzuMzyoPN-n1kYKHXLIn7uvKC99TAL2dCjiJsSJj9pqFJL67TXMg

Start Explorer UI

docker run --publish 8888:80 --publish 8889:8888 quay.io/influxdb/influxdb3-explorer:latest --mode=admin

insert record using CLI

~/.influxdb/influxdb3 write \
            --database demodb --token apiv3_76Ch4tKrO7vuOZdYtewX-4pVdfSqjqTyyFmzuMzyoPN-n1kYKHXLIn7uvKC99TAL2dCjiJsSJj9pqFJL67TXMg \
            --precision ns \
            --accept-partial \
          'cpu,host=Alpha,region=us-west,application=webserver usage_percent=20.5,status="OK"'

curl insert with v3 API

curl "http://localhost:8181/api/v3/write_lp?db=demodb&precision=auto&no_sync=true" \
  --header 'Authorization: Bearer apiv3_76Ch4tKrO7vuOZdYtewX-4pVdfSqjqTyyFmzuMzyoPN-n1kYKHXLIn7uvKC99TAL2dCjiJsSJj9pqFJL67TXMg' \
  --data-raw "home,room=Sunroom temp=96"

curl insert with v1 API (Bearer token)

curl -v "http://localhost:8181/write?db=demodb&precision=ns" \
  --header 'Authorization: Basic ZXJpYzphcGl2M183NkNoNHRLck83dnVPWmRZdGV3WC00cFZkZlNxanFUeXlGbXp1TXp5b1BOLW4xa1lLSFhMSW43dXZLQzk5VEFMMmRDamlKc1NKajlwcUZKTDY3VFhNZw==' \
  --data-raw "home,room=Sunroom temp=96"

curl insert with v1 API (URL parameter)

curl -v "http://localhost:8181/write?u=null&p=apiv3_76Ch4tKrO7vuOZdYtewX-4pVdfSqjqTyyFmzuMzyoPN-n1kYKHXLIn7uvKC99TAL2dCjiJsSJj9pqFJL67TXMg&db=demodb&precision=ns" \
  --data-raw "home,room=Sunroom temp=96"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment