> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apinizer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Apinizer Cache Metrics Overview

> You can monitor Apinizer Cache metrics. CacheMetricsService collects various metrics about Hazelcast cache, API performance, JVM and system health. You can analyze cache statistics, API performance metrics, JVM and system metrics with Prometheus metric types.

CacheMetricsService collects various metrics about Hazelcast cache, API Performance, JVM and System Health. These metrics are divided into the following categories:

* Hazelcast cache statistics
* API performance metrics
* JVM
* System Metrics

## Prometheus Metric Types

Cache metrics are collected using four metric types of Prometheus. These types are designed to best represent different data types and behaviors. Each metric type serves different purposes depending on how you collect and analyze the data.

<CardGroup cols={2}>
  <Card title="Counter" icon="arrow-up">
    Counter is a value that only increases. It starts from zero when the application runs and increases, and is reset only when the application is restarted. Counter type metrics are ideal for tracking continuously increasing values such as total request count, error count, or number of completed operations.

    **Available Operations:**

    * `sum`: The total value itself
    * `rate`: Calculates the rate of increase over time (such as how much it increases per second)
    * `increase`: Calculates the total increase in a specific time range
  </Card>

  <Card title="Gauge" icon="gauge">
    Gauge represents an instant value. This value can increase, decrease, or remain constant. Gauge type metrics are used to monitor an instant state or level such as current memory usage, instant CPU usage, or number of active threads.

    **Available Operations:**

    * `sum`: Sum of Gauge values grouped by labels
    * `mean`: Average of Gauge values grouped by labels
    * `min/max`: Minimum or maximum of values grouped by labels
  </Card>

  <Card title="Timer" icon="clock">
    Timer measures how long an operation takes (usually in milliseconds or seconds). Although technically not a special type in Prometheus, it is a metric created by libraries such as Micrometer with a combination of DistributionSummary and Counter. These metrics provide information such as average duration, maximum duration, and percentile slices.

    **Available Operations:**

    * `sum`: Gives the total duration
    * `count`: Gives how many times the operation was performed in total
    * `mean`: Calculates the average duration of the operation
    * `max`: Gives the longest duration observed
    * `histogram_quantile`: Calculates percentile slices
  </Card>

  <Card title="Summary" icon="chart-bar">
    Summary is a metric that calculates both the total of observed values and predetermined percentile slices (quantiles). Its difference from Timer and DistributionSummary is that it collects percentile slices directly; since these are calculated when the metric is collected, not at query time, percentile slices are more accurate.

    **Available Operations:**

    * `sum`: Total of observed values
    * `count`: Number of observed values
    * Predetermined percentile slices (`<metric_name>{quantile="0.99"}`)
  </Card>
</CardGroup>

## Cache Metrics

These metrics monitor Cache's cache performance. Cache searches, additions, and latencies are tracked to analyze efficiency. In addition, memory cost and distribution by partitions are measured.

| Metric                            | Description                            | Type    |
| --------------------------------- | -------------------------------------- | ------- |
| cache\_gets\_total                | Total cache searches (hits and misses) | Counter |
| cache\_puts\_total                | Total cache additions                  | Counter |
| cache\_size                       | Current number of entries in cache     | Gauge   |
| cache\_entries                    | Number of entries per cache partition  | Gauge   |
| cache\_entry\_memory\_bytes       | Memory cost of cache entries           | Gauge   |
| cache\_gets\_latency\_seconds     | Cache access latency                   | Summary |
| cache\_puts\_latency\_seconds     | Cache addition latency                 | Summary |
| cache\_removals\_latency\_seconds | Cache removal latency                  | Summary |

## API Metrics

These metrics monitor the performance of Cache's APIs. API performance is evaluated with data such as request count, response time, and error rates.

| Metric                                | Description                 | Type    |
| ------------------------------------- | --------------------------- | ------- |
| apinizer\_cache\_api\_requests\_total | Total API request count     | Counter |
| apinizer\_cache\_api\_response\_time  | API response time (seconds) | Timer   |
| apinizer\_cache\_api\_errors\_total   | Total API error count       | Counter |

## JVM Metrics

These metrics monitor Cache's memory and thread usage. JVM performance is analyzed with data such as memory usage, GC (Garbage Collection) pause durations, and active threads.

| Metric                        | Description                          | Type    |
| ----------------------------- | ------------------------------------ | ------- |
| jvm\_memory\_used\_bytes      | Memory usage by area (heap/non-heap) | Gauge   |
| jvm\_memory\_committed\_bytes | Committed memory by area             | Gauge   |
| jvm\_memory\_max\_bytes       | Maximum memory by area               | Gauge   |
| jvm\_gc\_pause\_seconds       | GC pause duration                    | Summary |
| jvm\_threads\_live\_threads   | Current number of live threads       | Gauge   |
| jvm\_threads\_daemon\_threads | Current number of daemon threads     | Gauge   |

## System Metrics

These metrics monitor Cache's general performance with data such as CPU usage, processor count, and load average. In addition, resource usage is evaluated with data such as process duration and number of open files.

| Metric                      | Description                     | Type  |
| --------------------------- | ------------------------------- | ----- |
| system\_cpu\_usage          | CPU usage of main system        | Gauge |
| system\_cpu\_count          | Number of available processors  | Gauge |
| system\_load\_average\_1m   | System load average (1 minute)  | Gauge |
| process\_cpu\_usage         | CPU usage of JVM process        | Gauge |
| process\_uptime\_seconds    | Runtime of JVM process          | Gauge |
| process\_files\_open\_files | Number of open file descriptors | Gauge |
