Analytics REST API

Analytics REST API

Analytics provides REST APIs that a client application can use to invoke services using simple HTTP methods. A catalogue of available REST resources and requests is provided below.

By default, the Analytics REST endpoints below listen on the port 8195.
Note: The REST APIs for Analytics are volatile in the Developer Preview. They may change significantly in the future.

GET /analytics/version

Description: Displays version information.

Parameters:
  • None
Command
$ curl -v http://localhost:8095/analytics/version
Sample response

* Trying ::1...
* Connected to localhost (::1) port 8095 (#0)
> GET /analytics/version HTTP/1.1
> Host: localhost:8095
> User-Agent: curl/7.43.0
> Accept: */*
>
> HTTP/1.1 200 OK
> Date: Tue, 11 Oct 2016 18:23:20 GMT
> Transfer-Encoding: chunked
> Server: Jetty(9.3.11.v20160721)
>
{
    "build.date": "Tue Oct 11 01:04:44 PDT 2016",
    "build.number": "254",
    "build.version": "1.0.0-SNAPSHOT",
    "projects": [
        {
            "name": "build",
            "revision": "3786d35acef4291e4b1044b4cfdcd6b579e87a71",
            "upstream": "master"
        },
        {
            "name": "asterixdb",
            "revision": "db1c115ec5270fbaf0556a9f9abd6c40978e67a4",
            "upstream": "master"
        },
        {
            "name": "asterix-opt",
            "revision": "bc632fd11eb50617262e74e6b36edd7febbe8feb",
            "upstream": "master"
        }
    ]
}
       

POST /analytics/shutdown

Description: Shuts down the analytics service.

Parameters:
  • all: If the parameter all is given with the value true all processes (CCDriver, NCDriver, NCService) will be shut down. Otherwise NCService will not shut down.
Command
$ curl -v http://localhost:8095/analytics/shutdown?all=true 
Sample response

* Trying ::1...
* Connected to localhost (::1) port 8095 (#0)
> POST /analytics/shutdown?all=true HTTP/1.1
> Host: localhost:8095
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Length: 3
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 3 out of 3 bytes
> HTTP/1.1 202 Accepted
> Date: Tue, 11 Oct 2016 18:32:53 GMT
> Content-Type: application/json;charset=utf-8
> Content-Length: 799
> Server: Jetty(9.3.11.v20160721)
>
{
    "cluster": {
        "metadata_node": "red",
        "ncs": [
            {
                "ncservice_pid": 95082,
                "node_id": "red",
                "partitions": [{
                    "active": true,
                    "partition_id": "partition_0"
                }],
                "pid": 95616,
                "state": "ACTIVE"
            },
            {
                "ncservice_pid": 95081,
                "node_id": "blue",
                "partitions": [{
                    "active": true,
                    "partition_id": "partition_1"
                }],
                "pid": 95615,
                "state": "ACTIVE"
            }
        ],
        "state": "ACTIVE"
    },
    "date": "Tue Oct 11 11:32:53 PDT 2016",
    "status": "SHUTTING_DOWN"
}

GET /analytics/cluster

Description: Returns the cluster information.

Parameters:
  • None
Command
 $ curl -v http://localhost:8095/analytics/cluster
Sample response

* Trying ::1...
* Connected to localhost (::1) port 8095 (#0)
> GET /analytics/cluster HTTP/1.1
> Host: localhost:8095
> User-Agent: curl/7.43.0
> Accept: */*
>
> HTTP/1.1 200 OK
> Date: Tue, 11 Oct 2016 18:24:57 GMT
> Content-Type: application/json;charset=utf-8
> Transfer-Encoding: chunked
> Server: Jetty(9.3.11.v20160721)
>
{
    "cc": {
        "configUri": "http://localhost:8095/analytics/cluster/cc/config",
        "statsUri": "http://localhost:8095/analytics/cluster/cc/stats",
        "threadDumpUri": "http://localhost:8095/analytics/cluster/cc/threaddump"
    },
    "config": {
        "cbas.http.port": 8095,
        "cc.java.opts": "-Xmx1024m",
        "cluster.partitions": {
            "0": "ID:0, Original Node: red, IODevice: 0, Active Node: red",
            "1": "ID:1, Original Node: blue, IODevice: 0, Active Node: blue"
        },
        "compiler.framesize": 32768,
        "compiler.groupmemory": 33554432,
        "compiler.joinmemory": 33554432,
        "compiler.sortmemory": 33554432,
        "core.dump.paths": {
            "blue": "data/blue/coredump",
            "red": "data/red/coredump"
        },
        "instance.name": "DEFAULT_INSTANCE",
        "log.level": "INFO",
        "max.wait.active.cluster": 60,
        "metadata.callback.port": 0,
        "metadata.node": "red",
        "metadata.partition": "ID:0, Original Node: red, IODevice: 0, Active Node: red",
        "metadata.port": 0,
        "metadata.registration.timeout.secs": 60,
        "nc.java.opts": "-Xmx1024m",
        "node.partitions": {
            "blue": ["ID:1, Original Node: blue, IODevice: 0, Active Node: blue"],
            "red": ["ID:0, Original Node: red, IODevice: 0, Active Node: red"]
        },
        "node.stores": {
            "blue": ["data/blue/storage"],
            "red": ["data/red/storage"]
        },
        "plot.activate": false,
        "replication.enabled": false,
        "replication.factor": 2,
        "replication.log.batchsize": 4096,
        "replication.log.buffer.numpages": 8,
        "replication.log.buffer.pagesize": 131072,
        "replication.max.remote.recovery.attempts": 5,
        "replication.timeout": 30,
        "storage.buffercache.maxopenfiles": 2147483647,
        "storage.buffercache.pagesize": 131072,
        "storage.buffercache.size": 536870912,
        "storage.lsm.bloomfilter.falsepositiverate": 0.01,
        "storage.memorycomponent.globalbudget": 536870912,
        "storage.memorycomponent.numcomponents": 2,
        "storage.memorycomponent.numpages": 256,
        "storage.memorycomponent.pagesize": 131072,
        "storage.metadata.memorycomponent.numpages": 256,
        "transaction.log.dirs": {
            "blue": "data/blue/txnlog",
            "red": "data/red/txnlog"
        },
        "txn.commitprofiler.reportinterval": 5,
        "txn.job.recovery.memorysize": 67108864,
        "txn.lock.escalationthreshold": 1000,
        "txn.lock.shrinktimer": 5000,
        "txn.lock.timeout.sweepthreshold": 10000,
        "txn.lock.timeout.waitthreshold": 60000,
        "txn.log.buffer.numpages": 8,
        "txn.log.buffer.pagesize": 131072,
        "txn.log.checkpoint.history": 0,
        "txn.log.checkpoint.lsnthreshold": 67108864,
        "txn.log.checkpoint.pollfrequency": 120,
        "txn.log.partitionsize": 268435456
    },
    "fullShutdownUri": "http://localhost:8095/analytics/shutdown?all=true",
    "metadata_node": "red",
    "ncs": [
        {
            "configUri": "http://localhost:8095/analytics/cluster/node/red/config",
            "node_id": "red",
            "partitions": [{
                "active": true,
                "partition_id": "partition_0"
            }],
            "state": "ACTIVE",
            "statsUri": "http://localhost:8095/analytics/cluster/node/red/stats",
            "threadDumpUri": "http://localhost:8095/analytics/cluster/node/red/threaddump"
        },
        {
            "configUri": "http://localhost:8095/analytics/cluster/node/blue/config",
            "node_id": "blue",
            "partitions": [{
                "active": true,
                "partition_id": "partition_1"
            }],
            "state": "ACTIVE",
            "statsUri": "http://localhost:8095/analytics/cluster/node/blue/stats",
            "threadDumpUri": "http://localhost:8095/analytics/cluster/node/blue/threaddump"
        }
    ],
    "shutdownUri": "http://localhost:8095/analytics/shutdown",
    "state": "ACTIVE",
    "versionUri": "http://localhost:8095/analytics/version"
}

POST /analytics/service or /query/service

Description: Returns result for query as JSON. The alternative /query/service is offered for tools compatibility.

Parameters:
  • statement: Specifies at least one valid SQL++ statement to run. Required.
  • pretty: If the parameter pretty is given with the value true, the result will be indented. (Optional)
  • creds: Array of credentials such as bucket user and password combinations. For each credential, you must specify an object that contains name value pairs for user and pass. (Optional)
  • client_context_id: Identifier passed by the client that is returned verbatim in the query response. Useful for matching a particular query to a specific caller. (Optional)
Command
Example 1: uses URL encoded data
 
$ curl -v --data-urlencode "statement=select 1;" http://localhost:8095/query/service
Example 2: posts the query statement as data of type application/json. 
Be sure to escape embedded JSON characters such as double quotes with backslashes.

curl -X POST -H "Content-Type: application/json"  -d '{
	"statement":"SELECT \"Hello, beer!\" AS greeting;",
	"pretty":true,
}' "http://localhost:8095/analytics/service"            
Sample Response 

*   Trying ::1...
* Connected to localhost (::1) port 8095 (#0)
> POST /query/service HTTP/1.1
> Host: localhost:8095
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Length: 23
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 23 out of 23 bytes
< HTTP/1.1 200 OK
< Date: Tue, 11 Oct 2016 18:44:46 GMT
< Content-Type: application/json;charset=utf-8
< Transfer-Encoding: chunked
< Server: Jetty(9.3.11.v20160721)
<
{
    "requestID": "b8bcb920-afdc-4b6f-9af9-5bddda6bb18f",
    "signature": "*",
    "results": [ { "$1": 1 }
 ]
    ,
    "status": "success",
    "metrics": {
        "elapsedTime": "762.014308ms",
        "executionTime": "695.582911ms",
        "resultCount": "1",
        "resultSize": "12"
    }
}