# Stackdriver Logging Client - Class Metric (2.1.0)

2.1.0 (latest) 2.0.0 1.34.5 1.33.0 1.32.3 1.31.3 1.30.3 1.29.0 1.28.5 1.27.1 1.26.0 1.25.5 1.24.10 Reference documentation and code samples for the Stackdriver Logging Client class Metric.

A metric counts the number of log entries that match a given filter. You can
use these metrics to create charts and alerting policies in
[Stackdriver Monitoring](https://cloud.google.com/monitoring/docs).

Example:

    use Google\Cloud\Logging\LoggingClient;

    $logging = new LoggingClient();

    $metric = $logging->metric('my-metric');

## Namespace

Google \\ Cloud \\ Logging

## Methods

### __construct

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `connection` | `Connection\Gapic` Represents a connection to Cloud Logging. This object is created by LoggingClient, and should not be instantiated outside of this client. |
| `name` | `string` The metric's name. |
| `projectId` | `string` The project's ID. |
| `info` | `array` \[optional\] The metric's metadata. |

### exists

Check whether or not the metric exists.

Example:

    if ($metric->exists()) {
        echo 'Metric exists!';
    }

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `options` | `array` \[optional\] Configuration Options |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### delete

See also:

- [projects.metrics delete API documentation.](https://cloud.google.com/logging/docs/api/reference/rest/v2/projects.metrics/delete)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `options` | `array` \[optional\] Configuration Options. |

### update

See also:

- [projects.metrics update API documentation.](https://cloud.google.com/logging/docs/api/reference/rest/v2/projects.metrics/update)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `metadata` | `array` The data to update. |
| `↳ description` | `string` A description of the metric. |
| `↳ filter` | `string` An [advanced logs filter](https://cloud.google.com/logging/docs/view/advanced_filters). |
| `options` | `array` \[optional\] Configuration Options. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `array` |   |

### info

See also:

- [LogMetric resource API documentation.](https://cloud.google.com/logging/docs/api/reference/rest/v2/projects.metrics#resource-logmetric)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `options` | `array` \[optional\] Configuration Options. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `array` |   |

### reload

See also:

- [projects.metrics get API documentation.](https://cloud.google.com/logging/docs/api/reference/rest/v2/projects.metrics/get)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `options` | `array` \[optional\] Configuration Options. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `array` |   |

### name

Returns the metric's name.

Example:

    echo $metric->name();

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