Statistics Query
Basic query for statistics
Basic statistic query format
query: query includes following options items below for grouping. Note: Either of distinct option or aggregate option must be given.
FILTER:
FILTER_OR:
{
"query": {
"distinct": ...,
"aggregate": {...},
"filter": [...],
"filter_or": [...],
"sort": {...},
"limit":{...}
}
}
{
"query": {
"distinct": "server_id"
}
}{
"query": {
"aggregate": {
"unwind": [
{
"path": "collection_info.service_accounts"
}
],
"group": {
"keys": [
{
"key": "service_account_id",
"name": "service_account"
}
],
"fields": [
{
"operator": "count",
"name": "cloud_service_count"
}
]
},
"count": {
"name": "service_counts"
}
}
}
}
aggregate specification : (type: dict)
Either of 'group' or 'unwind' or 'count' must declare under aggregate parameters Note: Applying order on aggregate unwind > group > count
unwind specification : (type: list)
{
"unwind": [
{
"path": "collection_info.service_accounts"
}
]
}
group specification : (type: dict)
{
"keys": [
{
"key": "service_account_id",
"name": "service_account"
}
],
"fields": [
{
"operator": "count",
"name": "cloud_service_count"
}
]
}
{
"keys": [
{
"key": "created_at",
"name": "created",
"date_format": "%Y-%m-%d"
}
],
"fields": [
{
"key" : "values.success_count"
"name": "success_count"
"operator": "max",
},
{
"key" : "values.fail_count"
"name": "fail_count"
"operator": "max",
},
{
"name": "year",
"value": "now/d - 7d",
"operator": "date",
"date_format": "%Y"
},
{
"name": "month",
"value": "now/d - 7d",
"operator": "date",
"date_format": "%m"
},
{
"name": "day",
"value": "now/d - 7d",
"operator": "date",
"date_format": "%d"
}
]
}
keys specification : (type: list)
Note: each items in keys applies to given name(alias)
fields specification : (type: list)
key can be omitted when operator is 'count'
value can be omitted when operator is NOT 'date'
date_format can be omitted when operator is NOT 'date'
Operators
count specification : (type: dict)
{
"query": {
"filter": [
{
"key": "name",
"value": [
"stark",
"nick"
],
"operator": "in"
}
]
}
}
Operators refer to Filter Operators
{
"query": {
"filter_or": [
{
"key": "name",
"value": [
"stark",
"admin"
],
"operator": "in"
},
{
"key": "user_id",
"value": [
"ua-abcdefg"
],
"operator": "not_in"
}
]
}
}
Operators refer to Filter Operators
{
"query": {
"sort": {
"name": "resource_count",
"desc": true
}
}
}
DISTINCT:
In case of distinct, sorting key - name is NOT available for sorting option - desc is available.
{
"query": {
"page": {
"start": 1,
"limit": 3
}
}
}
Last updated