Flux API

Flux API enables you to retrieve time series database data by sending REST queries using curl. You can get raw data from fluxd service in a way similar to using the Dashboard API. You have to get a token, and provide the token in the requests.

Prerequisites

Requires one of the following roles:

  • SYSTEM_ADMIN
  • SYSTEM_MONITOR
Request payload examples
json:

{
"query": "from(bucket:\"monitoring_main\") |> range(start: -30m) |> filter(fn: (r) => r._measurement == \"statDataHead_performance_internal_transactions\")"
}
application/vnd.flux - CSV format:

query=from(bucket: "monitoring_main")
|> range(start: -30m)
|> filter(fn: (r) => r._measurement == "statDataHead_performance_internal_transactions")

Steps

  1. Generate a token.
    Token:
    
    admin@ecs:> tok=$(curl -iks https://localhost:4443/login -u emcmonitor:#### | grep X-SDS-AUTH-TOKEN) 
    
    admin@ecs:/> echo $tok
    X-SDS-AUTH-TOKEN:****
    #### represents a password.
    **** represents a X-SDS-AUTH-TOKEN value.
  2. Run the query.
    Curl arguments varies depending on output format (JSON or CSV). See the examples for details.

Example

JSON example

admin@ecs:/> curl https://localhost:4443/flux/api/external/v2/query -XPOST -k -sS -H "$tok" -H 'accept:application/json' -H 'content-type:application/json' -d '{
"query": "from(bucket:\"monitoring_main\") |> range(start: -30m) |> filter(fn: (r) => r._measurement == \"statDataHead_performance_internal_transactions\")" }'
{
"Series": [
{
"Datatypes": [
"long",
"dateTime:RFC3339",
"dateTime:RFC3339",
"dateTime:RFC3339",
"long",
"string",
"string",
"string",
"string",
"string",
"string"
],
"Columns": [
"table",
"_start",
"_stop",
"_time",
"_value",
"_field",
"_measurement",
"host",
"node_id",
"process",
"tag"
],
"Values": [
[
"0",
"2020-03-10T09:54:31.207799855Z",
"2020-03-10T10:24:31.207799855Z",
"2020-03-10T09:56:43Z",
"1",
"failed_request_counter",
"statDataHead_performance_internal_transactions",
"ecs.lss.emc.com",
"28cd473e-ca45-4623-b30d-0481c548a650",
"statDataHead",
"dashboard"
],
[
"0",
"2020-03-10T09:54:31.207799855Z",
"2020-03-10T10:24:31.207799855Z",
"2020-03-10T10:01:43Z",
"1",
"failed_request_counter",
"statDataHead_performance_internal_transactions",
"ecs.lss.emc.com",
"28cd473e-ca45-4623-b30d-0481c548a650",
"statDataHead",
"dashboard"
],
[
"0",
"2020-03-10T09:54:31.207799855Z",
"2020-03-10T10:24:31.207799855Z",
"2020-03-10T10:06:43Z",
"1",
"failed_request_counter",
"statDataHead_performance_internal_transactions",
"ecs.lss.emc.com",
"28cd473e-ca45-4623-b30d-0481c548a650",
"statDataHead",
"dashboard"
],

CSV example

admin@ecs:> curl https://localhost:4443/flux/api/external/v2/query -XPOST -k -sS -H "$tok" -H 'accept:application/csv' -H 'content-type:application/vnd.flux' -d 'from(bucket:"monitoring_main") |> range(start:-30m) |> filter(fn: (r) => r._measurement == "statDataHead_performance_internal_transactions")'
#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,long,string,string,string,string,string,string
#group,false,false,true,true,false,false,true,true,true,true,true,true
#default,_result,,,,,,,,,,,
,result,table,_start,_stop,_time,_value,_field,_measurement,host,node_id,process,tag
,,0,2020-03-10T09:58:59.049910533Z,2020-03-10T10:28:59.049910533Z,2020-03-10T10:01:43Z,1,failed_request_counter,statDataHead_performance_internal_transactions,ecs.lss.emc.com,28cd473e-ca45-4623-b30d-0481c548a650,statDataHead,dashboard
,,0,2020-03-10T09:58:59.049910533Z,2020-03-10T10:28:59.049910533Z,2020-03-10T10:06:43Z,1,failed_request_counter,statDataHead_performance_internal_transactions,ecs.lss.emc.com,28cd473e-ca45-4623-b30d-0481c548a650,statDataHead,dashboard
,,0,2020-03-10T09:58:59.049910533Z,2020-03-10T10:28:59.049910533Z,2020-03-10T10:11:43Z,1,failed_request_counter,statDataHead_performance_internal_transactions,ecs.lss.emc.com,28cd473e-ca45-4623-b30d-0481c548a650,statDataHead,dashboard
,,0,2020-03-10T09:58:59.049910533Z,2020-03-10T10:28:59.049910533Z,2020-03-10T10:16:43Z,1,failed_request_counter,statDataHead_performance_internal_transactions,ecs.lss.emc.com,28cd473e-ca45-4623-b30d-0481c548a650,statDataHead,dashboard