This page describes how to view the following HL7v2 store metrics:

- The number of HL7v2 messages for a given HL7v2 message type, such as `ADT` or `ORU`.
- The [Structured Storage](https://cloud.google.com/healthcare-api/pricing#data_storage) size, in bytes, of all HL7v2 messages for a given HL7v2 message type.

You can use these metrics to do the following:

- Estimate future costs based on current usage.
- Track how an HL7v2 store grows and changes over time.
- Ensure that the number of HL7v2 messages matches the number that you [imported](https://docs.cloud.google.com/healthcare-api/docs/how-tos/hl7v2-import-export).

Modifications to HL7v2 data, such as storing, deleting, or editing the data,
are asynchronous. There might be a delay
between when you modify the data and when the modifications are shown
in the HL7v2 store metrics.

The following samples show how to view HL7v2 store metrics.

### Console

1. In the Google Cloud console, go to the **Datasets** page.

   [Go to Datasets](https://console.cloud.google.com/healthcare/browser)
2. Select the dataset containing the HL7v2 store whose metrics you want to view.

3. In the **Data stores** list, select the HL7v2 store whose metrics you want
   to view. The **Data store details** page is displayed.

4. Click the **Metrics** tab.

   The tab shows the following metrics on a scorecard:
   - **Total number of message types**
   - **Total number of messages**
   - **Total size of messages**

   The metrics table contains the following columns:

   | Column | Description |
   |---|---|
   | `Message type` | The message type, such as `ADT`, `ORM`, or `ACK`. |
   | `Number of messages` | The number of messages of a given message type. |
   | `Total size` | The total size of all the messages of a given message type. |

5. To filter the table data, enter the filter criteria in the **Filter** field.

   You can filter using the message type, the number of messages, and the total
   size of a message type. For example, to filter the **Total size** column,
   you can select the filter criteria, select an operator, and enter the filter
   value with the units of the size as they appear in the table.
   Some valid filter criteria to filter according to the total size are
   as follows: `Total size:> 2 MiB` and `Total size:>= 2 GiB`.

### REST

Use the [`hl7V2Stores.getHL7v2StoreMetrics`](https://docs.cloud.google.com/healthcare-api/docs/reference/rest/v1/projects.locations.datasets.hl7V2Stores/getHL7v2StoreMetrics.md.txt)
method.


Before using any of the request data,
make the following replacements:

- `PROJECT_ID`: the ID of your Google Cloud project
- `LOCATION`: the dataset location
- `DATASET_ID`: the HL7v2 store's parent dataset
- `HL7V2_STORE_ID`: the HL7v2 store ID

To send your request, choose one of these options:

#### curl

> [!NOTE]
> **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](https://docs.cloud.google.com/sdk/gcloud/reference/init) or [`gcloud auth login`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login.md.txt) , or by using [Cloud Shell](https://docs.cloud.google.com/shell/docs.md.txt), which automatically logs you into the `gcloud` CLI . You can check the currently active account by running [`gcloud auth list`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/list.md.txt).


Execute the following command:

```
curl -X GET \
     -H "Authorization: Bearer $(gcloud auth print-access-token)" \
     "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID:getHL7v2StoreMetrics"
```

#### PowerShell

> [!NOTE]
> **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](https://docs.cloud.google.com/sdk/gcloud/reference/init) or [`gcloud auth login`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/login.md.txt) . You can check the currently active account by running [`gcloud auth list`](https://docs.cloud.google.com/sdk/gcloud/reference/auth/list.md.txt).


Execute the following command:

```
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
    -Method GET `
    -Headers $headers `
    -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID:getHL7v2StoreMetrics" | Select-Object -Expand Content
```

#### APIs Explorer


Open the

[method reference page](https://docs.cloud.google.com/healthcare-api/docs/reference/rest/v1/projects.locations.datasets.hl7V2Stores/getHL7v2StoreMetrics.md.txt).
The APIs Explorer panel opens on the right side of the page.
You can interact with this tool to send requests.

Complete any required fields and click **Execute**.

You should receive a JSON response similar to the following:

#### Response

```
{
  "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID",
  "metrics": [
    {
      "messageType": "MESSAGE_TYPE",
      "count": "COUNT",
      "structuredStorageSizeBytes": "STRUCTURED_STORAGE_BYTES"
    }
  ]
}
```

<br />