Stat API
Query for statistics
Statistic query format
{
"resource_type": ...,
"query": {...},
"join": [...],
"formulas": [...]
}
{
"resource_type": "identity.ServiceAccount",
"query": {
"aggregate": {
"group": {
"keys": [
{
"key": "provider",
"name": "provider"
},
{
"key": "service_account_id",
"name": "service_account_id"
},
{
"key": "name",
"name": "service_account_name"
}
]
}
},
"sort": {
"name": "resource_count",
"desc": true
},
"limit": 5
}
}
query specification : (type: dict)
query:
refer to statistic query specification
{
"resource_type": ...,
"query": ...,
"join": [
{
"keys": [
"service_account_id"
],
"resource_type": "inventory.Server",
"query": {
"aggregate": {
"unwind": [
{
"path": "collection_info.service_accounts"
}
],
"group": {
"keys": [
{
"key": "service_account_id",
"name": "service_account_id"
}
],
"fields": [
{
"operator": "count",
"name": "server_count"
}
]
}
}
}
},
{
"keys": [
"service_account_id"
],
"type": "RIGHT",
"resource_type": "inventory.CloudService",
"query": {
"aggregate": {
"unwind": [
{
"path": "collection_info.service_accounts"
}
],
"group": {
"keys": [
{
"key": "service_account_id",
"name": "service_account_id"
}
],
"fields": [
{
"operator": "count",
"name": "cloud_service_count"
}
]
}
}
}
},
{
"keys": [
"service_account_id"
],
"type": "RIGHT",
"resource_type": "secret.Secret",
"query": {
"aggregate": {
"group": {
"keys": [
{
"key": "service_account_id",
"name": "service_account_id"
}
],
"fields": [
{
"operator": "count",
"name": "secret_count"
}
]
}
}
}
}
],
"formulas": ...
}
Note: join has a dependencies on main resource_type, and query must pair with resource_type & query
join specification ( type: list )
join_key:
refer to below images for each type's concept
query:
refer to statistic query specification
{
"resource_type": ...,
"query": ...,
"join": ...,
"formulas": [
{
"name": "resource_count",
"formula": "server_count + cloud_service_count"
}
]
}
Note: formulas has a dependencies on main resource_type, and query must pair with resource_type & query and join(if needed)
formula specification : ( type: list )
formula use case
{
"resource_type": ...,
"query": ...,
"join": ...,
"formulas": [
{
"name": "total",
"formula": "server_count + cloud_service_count"
},
{
"formula": "total > 0",
"operator": "QUERY"
}
]
}
Operator is OPTIONAL; Value EVAL(default) will be automatically set if there's no operator has not specifically declared in formula parameters.
Value Query has to be set to perform selective result as above within formulas.
Refers to - pandas.eval - pandas.DataFrame.query
Last updated