# Metric

> **Package : spaceone.api.monitoring.v1**

## Metric

{% hint style="info" %}
**Metric Methods:**
{% endhint %}

| Method                     | Request                                 | Response                          |
| -------------------------- | --------------------------------------- | --------------------------------- |
| [**list**](#list)          | [MetricRequest](#metricrequest)         | [MetricsInfo](#metricsinfo)       |
| [**get\_data**](#get_data) | [MetricDataRequest](#metricdatarequest) | [MetricDataInfo](#metricdatainfo) |

### list

> **GET** /monitoring/v1/data-source/{data\_source\_id}/metrics

> Gets a list of all Metrics of one or more specified Resources. The parameter `resources` is a list of Resources from which to get a list of Metrics collected.

| Type     | Message                         |
| -------- | ------------------------------- |
| Request  | [MetricRequest](#metricrequest) |
| Response | [MetricsInfo](#metricsinfo)     |

{% tabs %}
{% tab title="Request Example" %}

```
{
    "data_source_id": "ds-31190a65a42a",
    "resource_type": "inventory.CloudService",
    "resources": [
        "cloud-svc-cd0105d255da"
    ],
    "domain_id": "domain-58010aa2e451"
}
```

{% endtab %}

{% tab title="Response Example" %}

```
{
    "metrics": [
        {
            "key": "AWS/EC2.CPUUtilization",
            "name": "CPUUtilization",
            "unit": {
                "y": "Percent",
                "x": "Timestamp"
            },
            "chart_type": "line",
            "chart_options": {}
        },
        {
            "key": "AWS/EC2.NetworkIn",
            "name": "NetworkIn",
            "unit": {
                "y": "Bytes",
                "x": "Timestamp"
            },
            "chart_type": "line",
            "chart_options": {}
        }
    ],
    "available_resources": {
        "cloud-svc-cd0105d255da": true
    },
    "domain_id": "domain-58010aa2e451"
}
```

{% endtab %}
{% endtabs %}

### get\_data

> **GET** /monitoring/v1/data-source/{data\_source\_id}/metric-data

> Gets data of a single Metric. You must specify the parameter `metric` to get data of. You can specify the `period` to get data for.

| Type     | Message                                 |
| -------- | --------------------------------------- |
| Request  | [MetricDataRequest](#metricdatarequest) |
| Response | [MetricDataInfo](#metricdatainfo)       |

{% tabs %}
{% tab title="Request Example" %}

```
{
    "data_source_id": "ds-31190a65a42a",
    "resource_type": "inventory.CloudService",
    "resources": [
        "cloud-svc-cd0105d255da"
    ],
    "metric": "AWS/EC2.CPUUtilization",
    "start": "2022-06-21T03:11:29.438Z",
    "end": "2022-06-21T04:11:29.438Z",
    "stat": "AVERAGE",
    "domain_id": "domain-58010aa2e451"
}
```

{% endtab %}

{% tab title="Response Example" %}

```
{
    "labels": [
        "2022-06-21T03:13:00.000Z",
        "2022-06-21T03:18:00.000Z",
        "2022-06-21T03:23:00.000Z",
        "2022-06-21T03:28:00.000Z",
        "2022-06-21T03:33:00.000Z",
        "2022-06-21T03:38:00.000Z",
        "2022-06-21T03:43:00.000Z",
        "2022-06-21T03:48:00.000Z",
        "2022-06-21T03:53:00.000Z",
        "2022-06-21T03:58:00.000Z",
        "2022-06-21T04:03:00.000Z",
        "2022-06-21T04:08:00.000Z"
    ],
    "resource_values": {
        "cloud-svc-cd0105d255da": [
            0.099999999999999,
            0.10001852366397981,
            0.10001852366397981,
            0.1328230362675432,
            0.099472075576548,
            0.06507936507936621,
            0.166703713994628,
            0.1338983050847476,
            0.1327868852458988,
            0.1339168287487284,
            0.1328610417160508,
            0.10056497175141618
        ]
    },
    "domain_id": "domain-58010aa2e451"
}
```

{% endtab %}
{% endtabs %}

##

## Message

### MetricDataInfo

| Field      | Type                                                                                                               | Description |
| ---------- | ------------------------------------------------------------------------------------------------------------------ | ----------- |
| labels     | [google.protobuf.ListValue](https://developers.google.com/protocol-buffers/docs/reference/overview)                |             |
| values     | [google.protobuf.Struct](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto) |             |
| domain\_id | string                                                                                                             |             |

### MetricDataRequest

| Field            | Type                                                                                                               | Required | Description |
| ---------------- | ------------------------------------------------------------------------------------------------------------------ | :------: | ----------- |
| data\_source\_id | string                                                                                                             |     ✔    |             |
| metric\_query    | [google.protobuf.Struct](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto) |     ✔    |             |
| metric           | string                                                                                                             |     ✔    |             |
| start            | string                                                                                                             |     ✔    |             |
| end              | string                                                                                                             |     ✔    |             |
| period           | [int32](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/type.proto)                    |     ✘    |             |
| stat             | string                                                                                                             |     ✘    |             |
| domain\_id       | string                                                                                                             |     ✔    |             |

### MetricInfo

| Field         | Type                                                                                                               | Description |
| ------------- | ------------------------------------------------------------------------------------------------------------------ | ----------- |
| key           | string                                                                                                             |             |
| name          | string                                                                                                             |             |
| group         | string                                                                                                             |             |
| unit          | [google.protobuf.Struct](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto) |             |
| metric\_query | [google.protobuf.Struct](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto) |             |

### MetricRequest

| Field            | Type           | Required | Description |
| ---------------- | -------------- | :------: | ----------- |
| data\_source\_id | string         |     ✔    |             |
| resources        | list of string |     ✔    |             |
| domain\_id       | string         |     ✔    |             |

### MetricsInfo

| Field                | Type                                                                                                               | Description |
| -------------------- | ------------------------------------------------------------------------------------------------------------------ | ----------- |
| metrics              | [list of MetricInfo](#metricinfo)                                                                                  |             |
| available\_resources | [google.protobuf.Struct](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto) |             |
| domain\_id           | string                                                                                                             |             |
