My suggestion for the people that maintain the documentation: an explanation in the /data/dp endpoint's documentation page mentioning that the previous operations are mandatory would have saved me a certain number of hours of perplexity.
Original Message:
Sent: Jan 30, 2025 04:50 AM
From: Olivier Mercier
Subject: Re: Unable to retrieve performance metric for a vm
Hi there,
I have been looking for a way to get the stats too and have tried something like this for a host before seeing this thread, but still, I'm stuck.
Two examples:
curl -sk -X POST -H "vmware-api-session-id: ${TOKEN}" "https://${VC}/api/stats/acq-specs" -d '{"counters": {"cid": "cpu.capacity.usage.HOST"}, "interval" :"30", "resources": [{"type":"HOST", "id_value": "host-22", "predicate":"EQUAL"}] }'
What I got:
{ "error_type": "INVALID_REQUEST", "messages": [ { "args": [], "default_message": "Unsupported media type.", "id": "com.vmware.vapi.rest.unsupportedMediaType" } ]}
- What I tried after reading this thread:
curl -sk -X POST -H "vmware-api-session-id: ${TOKEN}" "https://${VC}/api/stats/acq-specs" -d '{ "counters": { "cid_mid": { "cid":"power.capacity.usage.VM" } }, "interval" :"30", "expiration":"10000000000", "resources": [ { "type":"VM", "id_value":"vm-5175", "predicate":"EQUAL" } ] }' | jq
Same result:
{ "error_type": "INVALID_REQUEST", "messages": [ { "args": [], "default_message": "Unsupported media type.", "id": "com.vmware.vapi.rest.unsupportedMediaType" } ]}
Did I miss anything?
Any hints are welcome!
PS my vCenter vSphere client indicates version 8.0.2.00300
.
Original Message:
Sent: Jul 04, 2023 04:32 PM
From: doskiran
Subject: Re: Unable to retrieve performance metric for a vm
Looks like Create Acq Spec is not created.
vStats collects data only for the configured AcqSpecs.
Try these steps:
1. Create AcqSpecs with POST Create AcqSpec API
POST: https://{api_host}/api/stats/acq-specs
Spec:
{ "counters": { "cid_mid": { "cid":"power.capacity.usage.VM" } }, "interval" :"30", "expiration":"10000000000", "resources": [ { "type":"VM", "id_value":"<vm-moid>", "predicate":"EQUAL" } ]}
2. Query Data Points Data:
GET: https://{api_host}/api/stats/data/dp?cid=power.capacity.usage.VM&types=VM