Skip to content

Service Gateway

The KxInsights Service Gateway is a data access service, that enables querying distributed databases.

Data may be retrieved using the Client Library or from the REST Server

Setting up Sample Data

Deploy the Demo Cluster

Run the following

tar -xvzf kxinsights.tgz kxinsights
cd kxinsights/service-gateway
docker-compose up

Querying with the Client Library

Querying the REST Server

Command Line Querying with Curl

Export the Server URL (for convience)

export URL="localhost:5040"

Making a GET request to execute Q-SQL select from sensor where sensorID = 3

curl "http://${url}/query?query=select%20from%20sensor%20where%20sensorid%3d3"

Making a POST request to execute Q-SQL select from sensor where sensorID = 3

curl -X POST\
    --header "Content-Type: application/json"\
    --data '{"query":"select from sensor where sensorID = 3"}'\
    "http://${URL}/query"

Making a GET request to save the binary result for select from sensor where sensorID = 3

curl --header "Accept: application/binary" -o sensor.dat\
    "http://${URL}/query?query=select%20from%20sensor%20where%20sensorID%3d3"

Making a POST request to save the binary result for select from sensor where sensorID = 3

curl -X POST\
    -o sensor.dat\
    --header "Accept: application/binary"\
    --header "Content-Type: application/json"\
    --data '{"query":"select from sensor where sensorID = 3"}'\
    "http://${URL}/query"

Querying with functional API

Export the Server URL (for convience)

export URL="localhost:5040"

See getData for full options.

The /data endpoint allows you to query functionally, providing temporal start and end timestamps, sort columns, and table names.

curl -X POST\
    --header "Content-Type: application/json"\
    --data '{"table":"trace", "startTS":"2021.05.09", "endTS":"2021.05.09D:16:40", "opts": {"sortCols": ["qual", "valFloat"]}, "columns":["valFloat"]}'
    "http://${URL}/data"

Querying with the Browser

Get JSON data

http://localhost:5040/query?query=select%20from%20sensor%20where%20sensorID%3d3

Download Binary data with xtype=bin

http://localhost:5040/query?xtype=bin&query=select%20from%20sensor%20where%20sensorID%3d3