VMware Cloud Community
smuribi
Contributor
Contributor

Efficient way to get individual stats?

Is there a more efficient way to get individual stats?

For instance i'm using python/requests and hitting:

'https://vrops/suite-api/api/resources/' + resource_id + '/stats/latest

and after getting a json dict object back I get a get a list of dicts (stat_list) and iterate through the whole thing.

Is there a better way to query in the api?

    stat_list = latest_stats['values'][0]['stat-list']['stat']

    num_stats = len(stat_list)

    for x in range(0,num_stats):

        stat_name = stat_list[x]['statKey']['key']

        if stat_name == 'datastore:Aggregate of all instances|totalWriteLatency_average':

            disk_lat = str(stat_list[x]['data'][0])

            #print ("Disk Latency: %s " % disk_lat)

    return disk_lat

Reply
0 Kudos
1 Reply