[comment]: # ({7ddf901c-7bc79a95})
# 4 VMware monitoring setup example

[comment]: # ({/7ddf901c-7bc79a95})

[comment]: # ({3c9549aa-4948cb9c})
#### Overview

The following example describes how to set up Zabbix for monitoring VMware virtual machines. This involves:

- creating a host that represents your VMware environment;
- creating a low-level discovery rule that discovers virtual machines in your VMware environment;
- creating a host prototype, based on which Zabbix will generate real hosts for virtual machines discovered by the low-level discovery rule.

[comment]: # ({/3c9549aa-4948cb9c})

[comment]: # ({8d40aabd-5d265fdc})
#### Prerequisites

::: noteclassic
This example does not cover the configuration of VMware. It is assumed that VMware is already configured.
:::

Before proceeding, set the [`StartVMwareCollectors`](/manual/appendix/config/zabbix_server#startvmwarecollectors) parameter in Zabbix server configuration file to `2` [or more](/manual/vm_monitoring#configuration) (the default value is `0`).

[comment]: # ({/8d40aabd-5d265fdc})

[comment]: # ({ae84527f-05232a19})
#### Create a host

1\. Go to *Data collection* → [*Hosts*](/manual/web_interface/frontend_sections/data_collection/hosts).

2\. [Create](/manual/config/hosts/host) a host:

- In the *Host name* field, enter a host name (for example, "VMware VMs").
- In the *Host groups* field, type or select a host group (for example, "Virtual machines").

![](../../../assets/en/manual/vm_monitoring/vmware_host.png){width="600"}

- In the *Macros* tab, set the following host macros:
    - {$VMWARE.URL} - VMware service (ESXi hypervisor) SDK URL (https://servername/sdk)
    - {$VMWARE.USERNAME} - VMware service user name
    - {$VMWARE.PASSWORD} - VMware service {$VMWARE.USERNAME} user password

![](../../../assets/en/manual/vm_monitoring/vmware_host_macros.png){width="600"}

3\. Click the *Add* button to create the host. This host will represent your VMware environment.

[comment]: # ({/ae84527f-05232a19})

[comment]: # ({7fa8a958-967b85cf})
#### Create a low-level discovery rule

1\. Click *Discovery* for the created host to go to the list of low-level discovery rules for that host.

2\. [Create](/manual/discovery/low_level_discovery#configuring-low-level-discovery) a low-level discovery rule:

- In the *Name* field, enter a low-level discovery rule name (for example, "Discover VMware VMs").
- In the *Type* field, select "[Simple check](/manual/config/items/itemtypes/simple_checks)".
- In the *Key* field, enter the built-in item key for discovering VMware virtual machines: [`vmware.vm.discovery[{$VMWARE.URL}]`](/manual/vm_monitoring/vmware_keys#vmware.vm.discovery)
- In the *User name* and *Password* fields, enter the corresponding macros previously configured on the host.

![](../../../assets/en/manual/vm_monitoring/vmware_host_discovery.png){width="600"}

3\. Click the *Add* button to create the low-level discovery rule.
This discovery rule will discover virtual machines in your VMware environment.

[comment]: # ({/7fa8a958-967b85cf})

[comment]: # ({3c0bd2af-4202131d})
#### Create a host prototype

1\. In the list of low-level discovery rules, click *Host prototypes* for the previously created low-level discovery rule.

2\. [Create](/manual/discovery/low_level_discovery/host_prototypes#configuration) a host prototype.
Since host prototypes are blueprints for creating hosts through low-level discovery rules, most fields will contain [low-level discovery macros](/manual/config/macros/lld_macros).
This ensures that the hosts are created with properties based on the [content retrieved](/manual/vm_monitoring/discovery_fields) by the previously created low-level discovery rule.

- In the *Host name* field, enter the macro {#VM.UUID}.
- In the *Visible name* field, enter the macro {#VM.NAME}.
- In the *Templates* field, enter or select the "VMware Guest" template.
This template contains [VMware items](/manual/vm_monitoring/vmware_keys) and discovery rules for monitoring the power state of a virtual machine, CPU usage, memory usage, network devices, etc.
- In the *Host groups* field, enter or select a host group (for example, "Discovered hosts").
- In the *Interfaces* field, add a custom [host interface](/manual/discovery/low_level_discovery/host_prototypes#host-interfaces).
Then, enter the macro {#VM.DNS} in the *DNS name* field, or enter the macro {#VM.IP} in the *IP address* field.
Alternatively, if your VMware environment virtual machines have multiple interfaces, proceed to the [*Advanced host interface configuration*](#advanced-host-interface-configuration) section.
Configuring a custom host interface is necessary for the correct functioning of the *VMware Guest* template.

![](../../../assets/en/manual/vm_monitoring/vmware_host_prototype.png){width="600"}

- In the *Macros* tab, set the {$VMWARE.VM.UUID} macro with the value {#VM.UUID}.
This is necessary for the correct functioning of the *VMware Guest* template that uses this macro as a host-level user macro in item parameters
(for example, *vmware.vm.net.if.discovery\[{$VMWARE.URL}, {$VMWARE.VM.UUID}\]*).

![](../../../assets/en/manual/vm_monitoring/vmware_host_prototype_macros.png){width="600"}

3\. Click the *Add* button to create the host prototype.
This host prototype will be used to create hosts for virtual machines discovered by the previously created low-level discovery rule.

[comment]: # ({/3c0bd2af-4202131d})

[comment]: # ({3e8fd594-92a7e887})
#### View hosts and metrics

After the host prototype has been created, the low-level discovery rule will create hosts for discovered VMware virtual machines, and Zabbix will start to monitor them.
Note that the discovery and creation of hosts can also be [executed manually](/manual/config/items/check_now), if necessary.

To view the created hosts, navigate to the [*Data collection* → *Hosts*](/manual/web_interface/frontend_sections/data_collection/hosts) menu section.

![](../../../assets/en/manual/vm_monitoring/vmware_discovered_hosts.png){width="600"}

To view collected metrics, navigate to the [*Monitoring* → *Hosts*](/manual/web_interface/frontend_sections/monitoring/hosts) menu section and click *Latest data* for one of the hosts.

![](../../../assets/en/manual/vm_monitoring/vmware_monitored_hosts.png){width="600"}

[comment]: # ({/3e8fd594-92a7e887})

[comment]: # ({2e5060fa-2c1d07a4})
#### Advanced host interface configuration

The `vmware.vm.discovery[{$VMWARE.URL}]` item key, configured in the [*Create a low-level discovery rule*](#create-a-low-level-discovery-rule) section, returns network interfaces data in the ["net_if" field](/manual/vm_monitoring/discovery_fields):

```json
"net_if": [
      {
        "ifname": "5000",
        "ifdesc": "Network adapter 1",
        "ifmac": "00:11:22:33:44:55",
        "ifconnected": true,
        "iftype": "VirtualVmxnet3",
        "ifbackingdevice": "VLAN(myLab)",
        "ifdvswitch_uuid": "",
        "ifdvswitch_portgroup": "",
        "ifdvswitch_port": "",
        "ifip": [
          "127.0.0.1",
          "::1"
        ]
      },
      {
        "ifname": "5001",
        "ifdesc": "Network adapter 2",
        "ifmac": "00:11:22:33:44:55",
        "ifconnected": false,
        "iftype": "VirtualVmxnet3",
        "ifbackingdevice": "VLAN(myLab2)",
        "ifdvswitch_uuid": "",
        "ifdvswitch_portgroup": "",
        "ifdvswitch_port": "",
        "ifip": []
      }
    ]
```

This data can be used to configure a custom host interface.

1\. When [creating a low-level discovery rule](#create-a-low-level-discovery-rule), additionally configure a [low-level discovery macro](/manual/config/macros/lld_macros).
In the *LLD macros* tab, create a custom LLD macro with a [JSONPath](/manual/config/items/preprocessing/jsonpath_functionality) value. For example:

- {#MYLAB.NET.IF} - `$.net_if[?(@.ifbackingdevice=="VLAN(myLab)")].ifip[0].first()`

![](../../../assets/en/manual/vm_monitoring/vmware_lld_macro.png){width="600"}

2\. When [creating a host prototype](#create-a-host-prototype), add a custom host interface and enter the LLD macro in the *DNS name* or *IP address* field.

![](../../../assets/en/manual/vm_monitoring/vmware_lld_macro_host_prototype.png){width="600"}

[comment]: # ({/2e5060fa-2c1d07a4})
