This page explains how to view the following metrics about a FHIR store:

- The types of FHIR resources in the FHIR store
- The number of each type of resource
- The size of the data in the FHIR store
- The size of the data version history in the FHIR store

You can use the metrics to do the following:

- Estimate future costs based on current usage.
- Track how the FHIR store is growing and changing over time.
- Ensure that the number of FHIR resources in a FHIR store matches the number you [imported](https://docs.cloud.google.com/healthcare-api/docs/how-tos/fhir-import-export.md.txt), [created using a bundle](https://docs.cloud.google.com/healthcare-api/docs/how-tos/fhir-bundles.md.txt), or [de-identified](https://docs.cloud.google.com/healthcare-api/docs/how-tos/fhir-deidentify.md.txt).

When you add or change FHIR resources, the resources are added
to the FHIR store asynchronously. There might be a delay
between when you make a change and when it appears in the metrics.

The following examples show how to view the metrics about a FHIR store.

### 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 FHIR store whose metrics you want to view.
   The **Data stores** page is displayed.

3. In the **Data stores** list, select the FHIR 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:

   - **Total number of resource types**
   - **Total number of resources**
   - **Total size of all resources**
   - **Total size of all versioned resources**
5. View and filter metrics in the **Metrics** table. After you filter metrics,
   select a FHIR resource type to view information about all resources of
   that type in the [FHIR viewer](https://docs.cloud.google.com/healthcare-api/docs/how-tos/fhir-search.md.txt#using_the_fhir_viewer).

### gcloud

Run the [`gcloud healthcare fhir-stores metrics`](https://docs.cloud.google.com/sdk/gcloud/reference/healthcare/fhir-stores/metrics) command.


Before using any of the command data below,
make the following replacements:

- <var class="edit" scope="PROJECT_ID" translate="no">PROJECT_ID</var>: the ID of your Google Cloud project
- <var class="edit" scope="LOCATION" translate="no">LOCATION</var>: the dataset location
- <var class="edit" scope="DATASET_ID" translate="no">DATASET_ID</var>: the FHIR store's parent dataset
- <var class="edit" scope="FHIR_STORE_ID" translate="no">FHIR_STORE_ID</var>: the FHIR store ID


Execute the

following

command:

#### Linux, macOS, or Cloud Shell

> [!NOTE]
> **Note:** Ensure you have initialized the Google Cloud CLI with authentication and a project by running either [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) and [gcloud config set project](https://docs.cloud.google.com/sdk/gcloud/reference/config/set.md.txt).

```bash
gcloud healthcare fhir-stores metrics FHIR_STORE_ID \
  --project=PROJECT_ID \
  --location=LOCATION \
  --dataset=DATASET_ID
```

#### Windows (PowerShell)

> [!NOTE]
> **Note:** Ensure you have initialized the Google Cloud CLI with authentication and a project by running either [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) and [gcloud config set project](https://docs.cloud.google.com/sdk/gcloud/reference/config/set.md.txt).

```bash
gcloud healthcare fhir-stores metrics FHIR_STORE_ID `
  --project=PROJECT_ID `
  --location=LOCATION `
  --dataset=DATASET_ID
```

#### Windows (cmd.exe)

> [!NOTE]
> **Note:** Ensure you have initialized the Google Cloud CLI with authentication and a project by running either [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) and [gcloud config set project](https://docs.cloud.google.com/sdk/gcloud/reference/config/set.md.txt).

```bash
gcloud healthcare fhir-stores metrics FHIR_STORE_ID ^
  --project=PROJECT_ID ^
  --location=LOCATION ^
  --dataset=DATASET_ID
```

You should receive a response similar to the following:

#### Response

```
metrics:
- count: 'FHIR_RESOURCE_TYPE_COUNT'
  resourceType: FHIR_RESOURCE_TYPE
  structuredStorageSizeBytes: 'FHIR_RESOURCE_TYPE_SIZE'
  versionedStorageSizeBytes: 'FHIR_RESOURCE_TYPE_VERSIONED_SIZE'
...
name: projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID
```

### REST

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


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

- <var class="edit" scope="PROJECT_ID" translate="no">PROJECT_ID</var>: the ID of your Google Cloud project
- <var class="edit" scope="LOCATION" translate="no">LOCATION</var>: the dataset location
- <var class="edit" scope="DATASET_ID" translate="no">DATASET_ID</var>: the FHIR store's parent dataset
- <var class="edit" scope="FHIR_STORE_ID" translate="no">FHIR_STORE_ID</var>: the FHIR 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/fhirStores/FHIR_STORE_ID:getFHIRStoreMetrics"
```

#### 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/fhirStores/FHIR_STORE_ID:getFHIRStoreMetrics" | 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.fhirStores/getFHIRStoreMetrics.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/fhirStores/FHIR_STORE_ID",
  "metrics": [
    {
      "resourceType": "FHIR_RESOURCE_TYPE",
      "count": "FHIR_RESOURCE_TYPE_COUNT",
      "structuredStorageSizeBytes": "FHIR_RESOURCE_TYPE_SIZE",
      "versionedStorageSizeBytes": "FHIR_RESOURCE_TYPE_VERSIONED_SIZE"
    },
    ...
  ]
}
```

<br />