# Google API Common Protos Client - Class MonitoredResource (4.14.0)

4.14.0 (latest) 4.13.0 4.12.5 4.11.0 4.10.0 4.9.0 4.8.3 Reference documentation and code samples for the Google API Common Protos Client class MonitoredResource.

An object representing a resource that can be used for monitoring, logging,
billing, or other purposes. Examples include virtual machine instances,
databases, and storage devices such as disks. The `type` field identifies a
[MonitoredResourceDescriptor](https://docs.cloud.google.com/php/docs/reference/common-protos/latest/Api.MonitoredResourceDescriptor) object
that describes the resource's schema. Information in the `labels` field
identifies the actual resource and its attributes according to the schema.

For example, a particular Compute Engine VM instance could be represented by
the following object, because the
[MonitoredResourceDescriptor](https://docs.cloud.google.com/php/docs/reference/common-protos/latest/Api.MonitoredResourceDescriptor) for
`"gce_instance"` has labels
`"project_id"`, `"instance_id"` and `"zone"`:
{ "type": "gce_instance",
"labels": { "project_id": "my-project",
"instance_id": "12345678901234",
"zone": "us-central1-a" }}

Generated from protobuf message `google.api.MonitoredResource`

## Namespace

Google \\ Api

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ type` | `string` Required. The monitored resource type. This field must match the `type` field of a [MonitoredResourceDescriptor](https://docs.cloud.google.com/php/docs/reference/common-protos/latest/Api.MonitoredResourceDescriptor) object. For example, the type of a Compute Engine VM instance is `gce_instance`. Some descriptors include the service name in the type; for example, the type of a Datastream stream is `datastream.googleapis.com/Stream`. |
| `↳ labels` | `array|https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField` Required. Values for all of the labels listed in the associated monitored resource descriptor. For example, Compute Engine VM instances use the labels `"project_id"`, `"instance_id"`, and `"zone"`. |

### getType

Required. The monitored resource type. This field must match
the `type` field of a
[MonitoredResourceDescriptor](https://docs.cloud.google.com/php/docs/reference/common-protos/latest/Api.MonitoredResourceDescriptor)
object. For example, the type of a Compute Engine VM instance is
`gce_instance`. Some descriptors include the service name in the type; for
example, the type of a Datastream stream is
`datastream.googleapis.com/Stream`.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setType

Required. The monitored resource type. This field must match
the `type` field of a
[MonitoredResourceDescriptor](https://docs.cloud.google.com/php/docs/reference/common-protos/latest/Api.MonitoredResourceDescriptor)
object. For example, the type of a Compute Engine VM instance is
`gce_instance`. Some descriptors include the service name in the type; for
example, the type of a Datastream stream is
`datastream.googleapis.com/Stream`.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getLabels

Required. Values for all of the labels listed in the associated monitored
resource descriptor. For example, Compute Engine VM instances use the
labels `"project_id"`, `"instance_id"`, and `"zone"`.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField` |   |

### setLabels

Required. Values for all of the labels listed in the associated monitored
resource descriptor. For example, Compute Engine VM instances use the
labels `"project_id"`, `"instance_id"`, and `"zone"`.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array|https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |