in aliyun/log/logclient_operator.py [0:0]
def get_resource_usage(client, project):
result = {"logstore": {},
"shard": {"logstores": {}},
"logtail": {},
"consumer_group": {"logstores": {}},
}
res = client.list_logstore(project, size=-1)
result["logstore"] = {"count": {"status": res.total,
"limitation": 200,
"usage": _get_percentage(res.total, 200)}}
shard_count = 0
consumer_group_count = 0
for logstore in res.logstores:
res = client.list_shards(project, logstore)
shard_count += res.count
result["shard"]["logstores"][logstore] = {"status": res.count}
res = client.list_consumer_group(project, logstore)
if res.count:
result["consumer_group"]["logstores"][logstore] = {"status": res.count, "limitation": 10,
"usage": _get_percentage(res.count, 10)}
consumer_group_count += res.count
result["shard"]["count"] = {"status": shard_count, "limitation": 200, "usage": _get_percentage(shard_count, 200)}
result["consumer_group"]["count"] = {"status": consumer_group_count}
res = client.list_logtail_config(project, offset=1000) # pass 1000 to just get total count
result["logtail"] = {"count": {"status": res.total,
"limitation": 100,
"usage": _get_percentage(res.total, 100)}}
res = client.list_machine_group(project, offset=1000) # pass 1000 to just get total count
result["machine_group"] = {"count": {"status": res.total,
"limitation": 100,
"usage": _get_percentage(res.total, 100)}}
res = client.list_savedsearch(project, offset=1000) # pass 1000 to just get total count
result["saved_search"] = {"count": {"status": res.total,
"limitation": 100,
"usage": _get_percentage(res.total, 100)}}
res = client.list_dashboard(project, offset=1000) # pass 1000 to just get total count
result["dashboard"] = {"count": {"status": res.total,
"limitation": 50,
"usage": _get_percentage(res.total, 50)}}
return ResourceUsageResponse(result)