Now, the moment we have all been waiting for; we can see average stock prices over time by using the REST API that Druid provides. To use the REST API, it is not necessary to run a full-blown Druid cluster. You will only be able to query the data seen by the singular embedded real-time node, but each node is capable of servicing requests and this makes testing easier. Using curl, you can issue a query of a real-time node using the following command:
curl -sX POST "http://localhost:7070/druid/v2/?pretty=true" -H 'content-type: application/json' -d @storm_query
The final parameter of the curl
statement references a file, the contents of which will be included as the body of the POST
request. The file contains the following details:
{"
queryType"
:"
groupBy"
,"
dataSource"
:"
stockinfo"
,"
granularity"
:"
minute"
,"
dimensions"
: ["
symbol"
],"
aggregations"
:[ {"
type"
:"
longSum"
,"
fieldName"
:"
orders"
,"
name"
:"
cumulativeCount"
}, ...