# Storage Metrics

ESS includes a [Storage Metrics](https://docs.inrupt.com/ess/services/service-pod-management/service-pod-storage#storage-metrics) feature to gather the following metrics:

* The total number of Pods.
* The number of “created” Pods (i.e., Pods that have been created and confirmed).
* The number of “deleted” Pods (i.e., Pods that have been soft-deleted, i.e., marked as deleted).

The Storage Metrics is run as a [Kubernetes CronJobs](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/). To modify its schedule, see [Modify Storage Metrics Schedule](https://docs.inrupt.com/ess/2.5/installation/customize-configurations/customization-pod-maintenance/modify-storage-metrics) .

## Observability

{% tabs %}
{% tab title="Default Logging" %}
Logging for Pruning jobs share a consistent pattern where the **`messageId`** has the prefix **`STORAGEMETRICS`** or **`STORAGE`** :

```json
{
  "timestamp":<value>,
  "sequence":<value>,
  "loggerClassName":<value>,
  "loggerName":<value>,
  "level":<value>,
  "message": "<STORAGEMETRICS|STORAGE><number>: <description>",
  "threadName":<value>,
  "threadId":<value>,
  "hostName":<value>,
  "processName":<value>,
  "processId":<value>,
  "messageId": "STORAGEMETRICS|STORAGE<number>"
  // additional relevant fields, if any
}
```

For the storage metrics features, the additional fields include:

* an **`mdc`** (managed diagnostic context) field that can be used for correlation;
* various storage metrics.

The following lists the various storage metrics that appear in the **`INFO`** level log messages (listed by the **`messageId`** ):

{% hint style="info" %}
**Note**\
The log messages that include the storage metrics detail use the **`STORAGE`** prefix in the messageIds.
{% endhint %}

* **`STORAGE000128`** (associated with the storage counts)

  | **`resultCount`** | Total number of Pods (both “created” and “deleted”). |
  | ----------------- | ---------------------------------------------------- |
* **`STORAGE000130`** (associated with the “created” storage counts)

  | **`resultCount`** | The number of Pods that have been created and confirmed. |
  | ----------------- | -------------------------------------------------------- |

{% hint style="info" %}
**Tip** For the count of “deleted” Pods (i.e., soft-deleted or marked as deleted), you can subtract from the **`STORAGE000128`** message **`resultCount`** the **`resultCount`** from the the **`STORAGE000130`** message; alternatively, you can set the Log Level to **`DEBUG`** (and return the level to **`INFO`** afterwards).
{% endhint %}
{% endtab %}

{% tab title="Prometheus" %}
Prune emits Prometheus metrics with the following labeled names.

All of the following are prefixed with **`application_com_inrupt_storage_metrics_MetricsCollector_`** .

<table data-header-hidden><thead><tr><th width="254.65625"></th><th></th></tr></thead><tbody><tr><td><strong><code>{metricType=”count”, resourceType=”pod”, resourceStatus=”all”}</code></strong></td><td>Total number of Pods (both “created” and “deleted”).</td></tr><tr><td><strong><code>{metricType=”count”, resourceType=”pod”, resourceStatus=”created”}</code></strong></td><td>The number of Pods that have been created and confirmed.</td></tr><tr><td><strong><code>{metricType=”count”, resourceType=”pod”, resourceStatus=”deleted”}</code></strong></td><td>The number of Pods that have been marked as deleted.</td></tr><tr><td><strong><code>collect</code></strong></td><td>Time taken to run the queries to gather the metrics.</td></tr></tbody></table>

See also [Service Metrics: Prometheus Configuration](https://docs.inrupt.com/ess/2.5/administration/service-metrics-prometheus-configuration) .
{% endtab %}

{% tab title="OpenTelemetry" %}
When OpenTelemetry is configured, the application emits a single span named **`collect`** with the following attributes.

<table data-header-hidden><thead><tr><th width="208.0546875"></th><th></th></tr></thead><tbody><tr><td><strong><code>countPodAll</code></strong></td><td>Total number of Pods (both “created” and “deleted”).</td></tr><tr><td><strong><code>countPodCreated</code></strong></td><td>The number of Pods that have been created and confirmed.</td></tr><tr><td><strong><code>countPodDeleted</code></strong></td><td>The number of Pods that have been marked as deleted.</td></tr><tr><td><strong><code>durationMilliseconds</code></strong></td><td>Time taken to run the queries to gather the metrics.</td></tr></tbody></table>
{% endtab %}
{% endtabs %}
