top of page

VCF Operations Metric Picker

Writer: Brock Peterson
Brock Peterson
15m
2 min read

I was pulling ESX Host metric values from the VCF Operations API this morning and wrote a script to get just what I wanted, basically just curl commands against the REST API surface. As I finished I thought to myself, this could be much more robust and would be cool if it had a GUI option. Here's what I came up with!


Everything is documented in the README.md, but here's an example of running it CLI.

python3 vcf_operations_metrics_picker.py --server 192.168.135.113 --user admin --object_type HostSystem --stat_keys "mem|active_average" "mem|consumed_average" "cpu|capacity_usagepct_average" "cpu|coreUtilization_average" --sample_size 14d

A few things to note here:

  • IT runs curl commands against the VCF Operations REST API surface hosted on the node defined by the --server field

  • --user specifies the user, by default it will use Local authentication, but also supports AD

  • --object_type defines the Object Types being collected against

  • --stat_keys are the metrics being collected

  • --sample_size is the interval it collects metric values for


Once run it'll look like this:

python3 vcf_operations_metrics_picker.py --server 192.168.135.113 --user admin --object_type HostSystem --stat_keys "mem|active_average" "mem|consumed_average" "cpu|capacity_usagepct_average" "cpu|coreUtilization_average" --sample_size 14d
Collecting 4032 samples per metric (~14 day(s) at 5-min interval).
Password for admin: 
Found 3 HostSystem object(s).
[1/3] 192.168.135.12: 4032 samples
[2/3] 192.168.135.11: 4032 samples
[3/3] 192.168.135.13: 4032 samples
Looking up metric names:
  mem|active_average  ->  Memory|Guest Active (KB)
  mem|consumed_average  ->  Memory|Consumed (KB)
  cpu|capacity_usagepct_average  ->  CPU|Capacity Usage (%)
  cpu|coreUtilization_average  ->  CPU|Core Utilization (%)
Wrote HostSystem_metrics_20261015_1335.json
Wrote HostSystem_metrics_20261015_1335.xlsx

As you can see the output is provided in both JSON and XLSX formats. If you'd like it output in the shell you can run this.

python3 vcf_operations_metrics_picker.py --server 192.168.135.113 --user admin --object_type HostSystem --stat_keys "mem|active_average" "mem|consumed_average" "cpu|capacity_usagepct_average" "cpu|coreUtilization_average" --sample_size 60m --format table

The output will look like this.



If you'd prefer a GUI, you can run this.

python3 vcf_operations_metrics_gui.py

A few things to note here:

  • The Object type drop down allows you select the Object Types you want

  • The Stat keys box allows you to define the metrics you want to collect, these are the stat keys as defined/discovered in the API via GET /api/resources/statkeys

  • There is an option to use stat keys as labels or the metric names

  • There is a an option to run more/less Parallel Requests, which tells the tool how many Objects to pull metrics for concurrently

  • Three download options: XLSX, JSON, and CSV


This has been tested against Operations 8.18.7, 9.0.2, and 9.1.1. I hope this was helpful, enjoy!

Comments


    bottom of page