vmware.vmware_rest.appliance_monitoring_query module – Query the monitored statistics data of the vCenter Server Appliance.

Note

This module is part of the vmware.vmware_rest collection (version 5.0.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install vmware.vmware_rest.

To use it in a playbook, specify: vmware.vmware_rest.appliance_monitoring_query.

New in vmware.vmware_rest 5.0.0

Synopsis

  • Retrieve the recorded data points for one or more monitored items on the vCenter Server Appliance, such as CPU, memory, network, or storage usage over a period of time.

  • The data is returned as a time series aggregated over a chosen interval using a chosen aggregation function (for example, the average CPU utilization sampled every five minutes).

  • Use vmware.vmware_rest.appliance_monitoring_info to discover which monitored item IDs are available before querying their data with this module.

Parameters

Parameter

Comments

item

dictionary / required

The parameters that define the time range and shape of the data to return.

Describes the sampling interval, the aggregation function, and the start and end of the period to query.

end_time

string / required

The end of the time range to query, as an ISO 8601 timestamp in UTC, for example 2026-01-01T12:00:00.000Z.

function

string / required

How the raw samples are aggregated into each returned data point.

COUNT - Uses the count (sum) per period.

MAX - Uses the maximum per period.

AVG - Uses the average per period.

MIN - Uses the minimum per period.

Choices:

  • "COUNT"

  • "MAX"

  • "AVG"

  • "MIN"

interval

string / required

The time between each returned data point.

MINUTES30 - Thirty minutes between values. One week is 336 values.

HOURS2 - Two hours between values. One month has 360 values.

MINUTES5 - Five minutes between values (the finest interval). One day has 288 values, one week is 2016.

DAY1 - 24 hours between values. One year has 365 values.

HOURS6 - Six hours between values. One quarter is 360 values.

Choices:

  • "MINUTES30"

  • "HOURS2"

  • "MINUTES5"

  • "DAY1"

  • "HOURS6"

start_time

string / required

The start of the time range to query, as an ISO 8601 timestamp in UTC, for example 2026-01-01T00:00:00.000Z.

names

aliases: filter_names

list / elements=string / required

The IDs of the monitored items to query data for, for example cpu.util or mem.util.

The available IDs can be listed with vmware.vmware_rest.appliance_monitoring_info.

session_timeout

float

Timeout in seconds for the whole operation including connection establishment, request sending, and response.

Default: 300.0

vcenter_hostname

string / required

The hostname or IP address of the vSphere vCenter.

If the value is not specified in the task, the value of environment variable VMWARE_HOST will be used instead.

vcenter_password

string / required

The vSphere vCenter password.

If the value is not specified in the task, the value of environment variable VMWARE_PASSWORD will be used instead.

vcenter_port

integer

The port number of the vSphere vCenter.

If the value is not specified in the task, the value of environment variable VMWARE_PORT will be used instead.

vcenter_rest_log_file

string

Optional path to a log file for HTTP REST interaction.

If the value is not specified in the task, the value of environment variable VMWARE_REST_LOG_FILE will be used instead.

vcenter_username

string / required

The vSphere vCenter username.

If the value is not specified in the task, the value of environment variable VMWARE_USER will be used instead.

vcenter_validate_certs

boolean

Allows connection when SSL certificates are not valid.

Set to false when certificates are not trusted.

If the value is not specified in the task, the value of environment variable VMWARE_VALIDATE_CERTS will be used instead.

Choices:

  • false

  • true ← (default)

Notes

Note

  • Generated from vSphere API spec 9.1.0.

  • Compatible with vSphere API 7.0.3.

  • Compatible with vSphere API 8.0.2.

Examples

- name: Query average CPU utilization over the last day at five minute intervals
  vmware.vmware_rest.appliance_monitoring_query:
    item:
      interval: MINUTES5
      function: AVG
      start_time: "2026-01-01T00:00:00.000Z"
      end_time: "2026-01-02T00:00:00.000Z"
    names:
      - cpu.util
  register: cpu_data

- name: Query maximum CPU and memory usage over a week at thirty minute intervals
  vmware.vmware_rest.appliance_monitoring_query:
    item:
      interval: MINUTES30
      function: MAX
      start_time: "2026-01-01T00:00:00.000Z"
      end_time: "2026-01-08T00:00:00.000Z"
    names:
      - cpu.util
      - mem.util
  register: usage_data

- name: Display the data points returned for the first monitored item
  ansible.builtin.debug:
    var: usage_data.info[0].data

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

info

list / elements=dictionary

A list of the monitored item data returned by the query.

Returned: On success

Sample: [{"data": ["3.5", "4.1", "2.9"], "end_time": "2026-01-02T00:00:00.000Z", "function": "AVG", "interval": "MINUTES5", "name": "cpu.util", "start_time": "2026-01-01T00:00:00.000Z"}, {"data": ["512000", "524288", "530012"], "end_time": "2026-01-02T00:00:00.000Z", "function": "AVG", "interval": "MINUTES5", "name": "mem.util", "start_time": "2026-01-01T00:00:00.000Z"}]

value

any

The queried monitoring data.

A single monitored item’s data as a dictionary when only one item was returned, otherwise a list of monitored item data dictionaries.

Returned: On success

Sample: {"data": ["3.5", "4.1", "2.9"], "end_time": "2026-01-02T00:00:00.000Z", "function": "AVG", "interval": "MINUTES5", "name": "cpu.util", "start_time": "2026-01-01T00:00:00.000Z"}

Authors

  • Ansible Eco Content Team (@eco-ansible-content)