Skip to content

HTTP Endpoints v2.4.7

chengshiwen edited this page Aug 24, 2020 · 1 revision

HTTP Endpoints v2.4.7

The Influx Proxy API provides a simple way to interact with the influx proxy server. It uses HTTP response codes, HTTP authentication, and basic authentication, and responses are returned in JSON.

HTTP Endpoints

Endpoint Description
/ping Use /ping to check the status of your InfluxDB Proxy instance and your version of InfluxDB Proxy.
/query Use /query to query data and manage databases and measurements.
/write Use /write to write data to a pre-existing database.
/health Use /health to view health status of all influxdb backends.
/replica Use /replica to query replica backends with database and measurement.
/encrypt Use /encrypt to encrypt plain username and password.
/decrypt Use /decrypt to decrypt ciphered username and password.
/migrate/state Use /migrate/state to get or set migration state.
/migrate/stats Use /migrate/stats to query migration stats when migrating.
/rebalance Use /rebalance to rebalance measurements of specific circle.
/recovery Use /recovery to recovery measurements from one circle to another circle.
/resync Use /resync to resync measurements with each other.
/clear Use /clear to clear misplaced measurements of specific circle.
/debug/pprof Use /debug/pprof to generate profiles for troubleshooting.

The following sections assume your InfluxDB Proxy instance is running on 127.0.0.1:7076 and HTTPS is not enabled.

/ping HTTP endpoint

official reference:

/query HTTP endpoint

official reference:

/write HTTP endpoint

official reference:

/health HTTP endpoint

Definition

GET https://127.0.0.1:7076/health

Query string parameters

Query String Parameter Optional/Required Description
pretty=true Optional Enables pretty-printed JSON output.
u=<username> Optional if you haven't enabled authentication Set the username for authentication if you've enabled authentication.
p=<password> Optional if you haven't enabled authentication Set the password for authentication if you've enabled authentication.

Example

$ curl 'https://127.0.0.1:7076/health?pretty=true'

[
    {
        "backends": [
            {
                "active": true,
                "backlog": false,
                "load": {
                    "db1": {
                        "incorrect": 0,
                        "inplace": 2,
                        "measurements": 2
                    },
                    "db2": {
                        "incorrect": 0,
                        "inplace": 1,
                        "measurements": 1
                    }
                },
                "name": "influxdb-1-1",
                "rewrite": false,
                "url": "https://127.0.0.1:8086"
            }
        ],
        "circle": "circle-1"
    }
]

Field description:

  • name: influxdb name
  • url: influxdb url
  • active: whether the influxdb is running
  • backlog: is there failed data in the cache file to influxdb
  • rewrite: whether the cache data is being rewritten to influxdb
  • load: influxdb load status
    • db: influxdb database
      • incorrect: number of measurements which should not be stored on this influxdb
        • it's healthy when incorrect equals 0
      • inplace: number of measurements which should be stored on this influxdb
        • it's healthy when inplace equals the number of measurements in this database
      • measurements: number of measurements in this database
        • measurements = incorrect + inplace
        • the number of measurements in each influxdb instance is roughly the same, indicating that the data store is load balanced

/replica HTTP endpoint

Definition

GET https://127.0.0.1:7076/replica

Query string parameters

Query String Parameter Optional/Required Description
db=<database> Required Database name for replica backends query.
meas=<measurement> Required Measurement name for replica backends query.
pretty=true Optional Enables pretty-printed JSON output.
u=<username> Optional if you haven't enabled authentication Set the username for authentication if you've enabled authentication.
p=<password> Optional if you haven't enabled authentication Set the password for authentication if you've enabled authentication.

Example

$ curl 'https://127.0.0.1:7076/replica?db=db1&meas=cpu1&pretty=true'

[
    {
        "circle": "circle-1",
        "name": "influxdb-1-1",
        "url": "https://127.0.0.1:8086"
    },
    {
        "circle": "circle-2",
        "name": "influxdb-2-2",
        "url": "https://127.0.0.1:8089"
    }
]

/encrypt HTTP endpoint

Definition

GET https://127.0.0.1:7076/encrypt

Query string parameters

Query String Parameter Optional/Required Description
msg=<message> Required The plain message to encrypt.

Example

$ curl -G 'https://127.0.0.1:7076/encrypt' --data-urlencode 'msg=admin'

YgvEyuPZlDYAH8sGDkC!Ag

/decrypt HTTP endpoint

Definition

GET https://127.0.0.1:7076/decrypt

Query string parameters

Query String Parameter Optional/Required Description
key=<key> Required The key to encrypt and decrypt, default is consistentcipher.
msg=<message> Required The ciphered message to decrypt.

Example

$ curl 'https://127.0.0.1:7076/decrypt?key=consistentcipher&msg=YgvEyuPZlDYAH8sGDkC!Ag'

admin

/migrate/state HTTP endpoint

Definition

GET https://127.0.0.1:7076/migrate/state
POST https://127.0.0.1:7076/migrate/state

Query string parameters

Query String Parameter Optional/Required Description
resyncing=true Optional Set resyncing state of proxy.
circle_id=0 Optional Circle index to set migrating state, started from 0.
migrating=false Optional Set migrating state of circle specified by circle_id.
pretty=true Optional Enables pretty-printed JSON output.
u=<username> Optional if you haven't enabled authentication Set the username for authentication if you've enabled authentication.
p=<password> Optional if you haven't enabled authentication Set the password for authentication if you've enabled authentication.

Example

Get migration state

$ curl 'https://127.0.0.1:7076/migrate/state?pretty=true'

{
    "circles": [
        {
            "circle_id": 0,
            "circle_name": "circle-1",
            "is_migrating": false
        },
        {
            "circle_id": 1,
            "circle_name": "circle-2",
            "is_migrating": false
        }
    ],
    "is_resyncing": false
}

Set resyncing state of proxy

$ curl -X POST 'https://127.0.0.1:7076/migrate/state?resyncing=true&pretty=true'

{
    "resyncing": true
}

Set migrating state of circle 0

$ curl -X POST 'https://127.0.0.1:7076/migrate/state?circle_id=0&migrating=true&pretty=true'

{
    "circle": {
        "circle_id": 0,
        "circle_name": "circle-1",
        "is_migrating": true
    }
}

/migrate/stats HTTP endpoint

Definition

GET https://127.0.0.1:7076/migrate/stats

Query string parameters

Query String Parameter Optional/Required Description
circle_id=0 Required Circle index started from 0.
type=<type> Required Stats type, valid options are rebalance, recovery, resync or clear.
pretty=true Optional Enables pretty-printed JSON output.
u=<username> Optional if you haven't enabled authentication Set the username for authentication if you've enabled authentication.
p=<password> Optional if you haven't enabled authentication Set the password for authentication if you've enabled authentication.

Example

$ curl 'https://127.0.0.1:7076/migrate/stats?circle_id=0&type=rebalance&pretty=true'

{
    "https://127.0.0.1:8086": {
        "database_total": 0,
        "database_done": 0,
        "measurement_total": 0,
        "measurement_done": 0,
        "migrate_count": 0,
        "inplace_count": 0
    },
    "https://127.0.0.1:8087": {
        "database_total": 0,
        "database_done": 0,
        "measurement_total": 0,
        "measurement_done": 0,
        "migrate_count": 0,
        "inplace_count": 0
    }
}

/rebalance HTTP endpoint

Definition

POST https://127.0.0.1:7076/rebalance

Query string parameters

Query String Parameter Optional/Required Description
circle_id=0 Required Circle index started from 0.
operation=<operation> Required Operation type, valid options are add or rm.
db=<db_list> Optional database list split by ',' while using all databases if empty.
cpus=1 Optional Migration max cpus, default is 1.
ha_addrs=<ha_addrs> Optional if only one InfluxDB Proxy instance is running High available addrs of all running InfluxDB Proxy for two instances at least.
u=<username> Optional if you haven't enabled authentication Set the username for authentication if you've enabled authentication.
p=<password> Optional if you haven't enabled authentication Set the password for authentication if you've enabled authentication.

Request body

Json body for describing backends to remove, required when operation is rm

{
    "backends": [
        {
            "name": "influxdb-1-2",
            "url": "https://127.0.0.1:8087",
            "username": "",
            "password": ""
        }
    ]
}

Example

Rebalance measurements of circle specified by circle_id after adding backends, while there are two running InfluxDB Proxy instances

$ curl -X POST 'https://127.0.0.1:7076/rebalance?circle_id=0&operation=add&ha_addrs=127.0.0.1:7076,127.0.0.1:7077'

accepted

Rebalance measurements of circle specified by circle_id after removing backends, if there is only one running InfluxDB Proxy instances

$ curl -X POST 'https://127.0.0.1:7076/rebalance?circle_id=0&operation=rm&cpus=2' -H 'Content-Type: application/json' -d \
'{
    "backends": [
        {
            "name": "influxdb-1-2",
            "url": "https://127.0.0.1:8087",
            "username": "",
            "password": ""
        }
    ]
}'

accepted

/recovery HTTP endpoint

Definition

POST https://127.0.0.1:7076/recovery

Query string parameters

Query String Parameter Optional/Required Description
from_circle_id=0 Required From circle index started from 0.
to_circle_id=1 Required To circle index started from 0.
backend_urls=<backend_urls> Optional backend urls to recovery split by ',' while using all backends of circle specified by to_circle_id if empty.
db=<db_list> Optional database list split by ',' while using all databases if empty.
cpus=1 Optional Migration max cpus, default is 1.
ha_addrs=<ha_addrs> Optional if only one InfluxDB Proxy instance is running High available addrs of all running InfluxDB Proxy for two instances at least.
u=<username> Optional if you haven't enabled authentication Set the username for authentication if you've enabled authentication.
p=<password> Optional if you haven't enabled authentication Set the password for authentication if you've enabled authentication.

Example

Recovery all backends of circle 1 from circle 0

$ curl -X POST 'https://127.0.0.1:7076/recovery?from_circle_id=0&to_circle_id=1'

accepted

Only recovery backend https://127.0.0.1:8089 in circle 1 from circle 0

$ curl -X POST 'https://127.0.0.1:7076/recovery?from_circle_id=0&to_circle_id=1&backend_urls=https://127.0.0.1:8089'

accepted

/resync HTTP endpoint

Definition

POST https://127.0.0.1:7076/resync

Query string parameters

Query String Parameter Optional/Required Description
seconds=<seconds> Optional Resync data for last seconds, default is 0 for all data.
db=<db_list> Optional database list split by ',' while using all databases if empty.
cpus=1 Optional Migration max cpus, default is 1.
ha_addrs=<ha_addrs> Optional if only one InfluxDB Proxy instance is running High available addrs of all running InfluxDB Proxy for two instances at least.
u=<username> Optional if you haven't enabled authentication Set the username for authentication if you've enabled authentication.
p=<password> Optional if you haven't enabled authentication Set the password for authentication if you've enabled authentication.

Example

$ curl -X POST 'https://127.0.0.1:7076/resync?cpus=2'

accepted

/clear HTTP endpoint

Definition

POST https://127.0.0.1:7076/clear

Query string parameters

Query String Parameter Optional/Required Description
circle_id=0 Required Circle index started from 0.
cpus=1 Optional Migration max cpus, default is 1.
ha_addrs=<ha_addrs> Optional if only one InfluxDB Proxy instance is running High available addrs of all running InfluxDB Proxy for two instances at least.
u=<username> Optional if you haven't enabled authentication Set the username for authentication if you've enabled authentication.
p=<password> Optional if you haven't enabled authentication Set the password for authentication if you've enabled authentication.

Example

$ curl -X POST 'https://127.0.0.1:7076/clear?circle_id=0&cpus=2'

accepted

/debug/pprof HTTP endpoint

official reference: