REST Queries for Data Aggregation

This topic provides REST queries that you can use to retrieve aggregated data, such as average, minimum, maximum, count, standard deviation, and so on.

Table 1. Retrieve the Average Value
Parameter Value
Method GET
URI http://<Public IP address of the REST Query service>:8989/v1/tags
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Body
{
    "start": <start time>,
    "end": <end time>
    "tags": [{
        "name": "<tag name>",
        "aggregations": [{
            "type": "avg",
            "sampling": {
                "unit": "<units for data interval>",
                //valid values: ms, s, mi, h, d, w, mm, y 
                "value": "<data interval>"
            }
        }]
    }],
    
}
Example
{
    "tags": [{
        "name": "GF260PF2E_Simulation.Simulation00004",
        "aggregations": [{
            "type": "avg",
            "sampling": {
                "unit": "s",
                "value": "30"
            }
        }]
    }],
    "start": 1641177806000,
    "end": 1641185238000
}
{
    "start": 1641178610000,
    "end": 1641185810000,
    "tags": [{
        "name": "GF260PF2E_Simulation.Simulation00004",
        "aggregations": [{
            "type": "avg",
            "sampling": {
                "datapoints": 1
            }
        }]
    }]
}
Table 2. Retrieve the Sum of Values
Parameter Value
Method GET
URI http://<Public IP address of the REST Query service>:8989/v1/tags
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Body
{
    "start": <start time>,
    "end": <end time>,
    "tags": [{
        "name": "tag name>",
        "aggregations": [{
            "type": "sum",
            "sampling": {
                "datapoints": <number>
            }
        }]
    }]
}
Example
{
    "start": 1641178610000,
    "end": 1641185810000,
    "tags": [{
        "name": "GF260PF2E_Simulation.Simulation00004",
        "aggregations": [{
            "type": "sum",
            "sampling": {
                "datapoints": 1
            }
        }]
    }]
}
Output:
{
    "tags": [
        {
            "name": "GF260PF2E_Simulation.Simulation00004",
            "results": [
                {
                    "groups": [
                        {
                            "name": "type",
                            "type": "number"
                        }
                    ],
                    "values": [
                        [
                            1641178610000,
                            4.073673509635417E8,
                            3
                        ]
                    ],
                    "attributes": {}
                }
            ],
            "stats": {
                "rawCount": 4073
            }
        }
    ]
}
Table 3. Retrieve the Count of Data Samples
Parameter Value
Method GET
URI http://<Public IP address of the REST Query service>:8989/v1/tags
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Body
{
    "start": <start time>,
    "tags": [{
        "name": "<tag name>",
        "aggregations": [{
            "type": "count",
            "sampling": {
                "datapoints": 1
            }
        }]
    }]
}
Example
{
    "start": 1641178610000,
    "tags": [{
        "name": "GF260PF2E_Simulation.Simulation00004",
        "aggregations": [{
            "type": "count",
            "sampling": {
                "datapoints": 1
            }
        }]
    }]
}
Table 4. Retrieve the Count of Data Samples
Parameter Value
Method GET
URI http://<Public IP address of the REST Query service>:8989/v1/tags
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Body
{
    "start": <start time>,
    "tags": [{
        "name": "<tag name>",
        "aggregations": [{
            "type": "count",
            "sampling": {
                "datapoints": 1
            }
        }]
    }]
}
Example
{
    "start": 1641178610000,
    "tags": [{
        "name": "GF260PF2E_Simulation.Simulation00004",
        "aggregations": [{
            "type": "count",
            "sampling": {
                "datapoints": 1
            }
        }]
    }]
}
Table 5. Retrieve the Count of Data Samples
Parameter Value
Method GET
URI http://<Public IP address of the REST Query service>:8989/v1/tags
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Body
{
    "start": <start time>,
    "tags": [{
        "name": "<tag name>",
        "aggregations": [{
            "type": "count",
            "sampling": {
                "datapoints": 1
            }
        }]
    }]
}
Example
{
    "start": 1641178610000,
    "tags": [{
        "name": "GF260PF2E_Simulation.Simulation00004",
        "aggregations": [{
            "type": "count",
            "sampling": {
                "datapoints": 1
            }
        }]
    }]
}
Table 6. Retrieve the Standard Deviation of Data Samples
Parameter Value
Method GET
URI http://<Public IP address of the REST Query service>:8989/v1/tags
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Body
{
    "start": <start name>,
    "tags": [{
        "name": "<tag name>",
        "aggregations": [{
            "type": "dev",
            "sampling": {
                "datapoints": 1
            }
        }]
    }]
}
Example
{
    "start": 1641178610000,
    "tags": [{
        "name": "GF260PF2E_Simulation.Simulation00004",
        "aggregations": [{
            "type": "dev",
            "sampling": {
                "datapoints": 1
            }
        }]
    }]
}
Table 7. Retrieve Gaps (Null Data) in Data Samples
Parameter Value
Method GET
URI http://<Public IP address of the REST Query service>:8989/v1/tags
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Body
{
    "start": <start time>,
    "tags": [{
        "name": "<tag name>",
        "aggregations": [{
            "type": "gaps",
            "sampling": {
                "datapoints": <number>
            }
        }]
    }]
}
Example
{
    "start": 1641178610000,
    "tags": [{
        "name": "GF260PF2E_Simulation.Simulation00004",
        "aggregations": [{
            "type": "gaps",
            "sampling": {
                "datapoints": 9000
            }
        }]
    }]
}
Table 8. Retrieve Least Squares
Parameter Value
Description This query returns the best-fit line through a set of data points.
Method GET
URI http://<Public IP address of the REST Query service>:8989/v1/tags
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Body
{
    "start": <start time>,
    "tags": [{
        "name": "<tag name>",
        "aggregations": [{
            "type": "least_squares",
            "sampling": {
                "datapoints": 1
            }
        }]
    }]
}
Example
{
    "start": 1641178610000,
    "tags": [{
        "name": "GF260PF2E_Simulation.Simulation00004",
        "aggregations": [{
            "type": "least_squares",
            "sampling": {
                "datapoints": 1
            }
        }]
    }]
}
Table 9. Retrieve the Maximum Value
Parameter Value
Method GET
URI http://<Public IP address of the REST Query service>:8989/v1/tags
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Body
{
    "start": 1641178610000,
    "tags": [{
        "name": "GF260PF2E_Simulation.Simulation00004",
        "aggregations": [{
            "type": "max",
            "sampling": {
                "datapoints": 1
            }
        }]
    }]
}
Example
{
    "start": 1641178610000,
    "tags": [{
        "name": "GF260PF2E_Simulation.Simulation00004",
        "aggregations": [{
            "type": "max",
            "sampling": {
                "datapoints": 1
            }
        }]
    }]
}
Table 10. Retrieve the Minimum Value
Parameter Value
Method GET
URI http://<Public IP address of the REST Query service>:8989/v1/tags
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Body
{
    "start": <start time>,
    "tags": [{
        "name": "tag name>",
        "aggregations": [{
            "type": "min",
            "sampling": {
                "datapoints": 1
            }
        }]
    }]
}
Example
{
    "start": 1641178610000,
    "tags": [{
        "name": "GF260PF2E_Simulation.Simulation00004",
        "aggregations": [{
            "type": "min",
            "sampling": {
                "datapoints": 1
            }
        }]
    }]
}
Table 11. Retrieve the Maximum and Minimum Values
Parameter Value
Method GET
URI http://<Public IP address of the REST Query service>:8989/v1/tags
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Body
{
    "start": <start time>,
    "tags": [{
        "name": "<tag name>",
        "aggregations": [{
            "type": "trendmode",
            "sampling": {
                "datapoints": 1
            }
        }]
    }]
}
Example
{
    "start": 1641178610000,
    "tags": [{
        "name": "GF260PF2E_Simulation.Simulation00004",
        "aggregations": [{
            "type": "trendmode",
            "sampling": {
                "datapoints": 1
            }
        }]
    }]
}
Table 12. Retrieve the Quotient of a Division
Parameter Value
Method GET
URI http://<Public IP address of the REST Query service>:8989/v1/tags
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Body
{
    "start": <start time>,
    "end": <end time>
    "tags": [{
        "name": "<tag name>",
        "aggregations": [{
            "type": "div",
            "divisor": <divisor>
        }]
    }],
}
Example
{ 
    "start": 1641177806000,
    "end": 1641185238000
    "tags": [{
        "name": "GF260PF2E_Simulation.Simulation00004",
        "aggregations": [{
            "type": "div",
            "divisor": 3
        }]
    }],   
}
Table 13. Retrieve the Percentile
Parameter Value
Description This query determines the probability distribution of a set of data, and returns the percentile. The percentile value ranges between 0 and 1, where .5 is 50% and 1 is 100%.
Method GET
URI http://<Public IP address of the REST Query service>:8989/v1/tags
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Body
{
    "start": "<start time>"
    "tags": [{
        "name": "<tag name>",
        "aggregations": [{
            "type": "percentile",
            "percentile": 1.0
        }]
    }],    
}
Example
{
    "start": "15mi-ago"
    "tags": [{
        "name": "GF260PF2E_Simulation.Simulation00004",
        "aggregations": [{
            "type": "percentile",
            "percentile": 1.0
        }]
    }],    
}
Table 14. Retrieve the Rate of Change
Parameter Value
Method GET
URI http://<Public IP address of the REST Query service>:8989/v1/tags
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Body
{  
   "start":<start time>,
   "end":<end time>,
   "tags":[  
      {  
         "name":"<tag name>",
         "aggregations":[  
            {  
               "type":"rate",
                "sampling": {
                    "unit": "<units for the time interval>",
                    "value": <time interval>,
                    "datapoints": <number>
            }
            }
         ]
      }
   ]
}
Example
{  
   "start":1640931121000,
   "end":1640935148000,
   "tags":[  
      {  
         "name":"GF260PF2E_Simulation.Simulation00002",
         "aggregations":[  
            {  
               "type":"rate",
                "sampling": {
                    "unit": "mi",
                    "value": 2,
                    "datapoints": 100
            }
            }
         ]
      }
   ]
}
Table 15. Retrieve the Sampling Rate of Change
Parameter Value
Method GET
URI http://<Public IP address of the REST Query service>:8989/v1/tags
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Body
{
    "start": <start time>,
    "end": <end time>,
    "tags": [{
        "name": "<tag name>",
        "aggregations": [{
            "type": "sampler"
        }]
    }]
}
Example
{
    "start": 1641178610000,
    "end": 1641185810000,
    "tags": [{
        "name": "GF260PF2E_Simulation.Simulation00004",
        "aggregations": [{
            "type": "sampler"
        }]
    }]
}
Table 16. Scale Data Points by a Factor
Parameter Value
Method GET
URI http://<Public IP address of the REST Query service>:8989/v1/tags
Authorization Bearer <token>
Content-Type application/json
Predix-Zone-Id uaa
Body
{
    "start": <start time>,
    "end": <end time>,
    "tags": [{
        "name": "<tag name>",
        "aggregations": [{
            "type": "scale",
            "factor": <number>
        }]
    }]
}
Example
{
    "start": 1641178610000,
    "end": 1641185810000,
    "tags": [{
        "name": "GF260PF2E_Simulation.Simulation00004",
        "aggregations": [{
            "type": "scale",
            "factor": 2
        }]
    }]
}