> ## 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.

# Overview of Apinizer Cache Metrics

> CacheMetricsService collects various metrics about Hazelcast cache, API performance, JVM, and system health and provides them in Prometheus format. These metrics enable monitoring cache performance, analyzing API response times, evaluating JVM resource usage, and tracking system health.

# Overview of Apinizer Cache Metrics

<CardGroup cols={2}>
  <Card title="Hazelcast Cache Statistics" icon="database">
    Monitors cache performance metrics such as cache lookups, additions, latencies, and memory usage.
  </Card>

  <Card title="API Performance Metrics" icon="chart-line">
    Collects API performance data such as API request counts, response times, and error rates.
  </Card>

  <Card title="JVM Metrics" icon="microchip">
    Provides JVM performance data such as memory usage, GC pause times, and thread counts.
  </Card>

  <Card title="System Metrics" icon="server">
    Monitors system resource data such as CPU usage, processor count, load average, and open file counts.
  </Card>
</CardGroup>

## Prometheus Metric Types

Cache metrics are collected using Prometheus's four metric types. 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">
    A value that only increases. It starts from zero when the application runs and only resets when the application is restarted. Ideal for tracking continuously increasing values such as total request count, error count, or completed operation count.

    **Available Operations:**

    * `sum`: The total value itself
    * `rate`: Calculates the rate of increase over time
    * `increase`: Calculates the total increase over a specific time range
  </Card>

  <Card title="Gauge" icon="gauge">
    Represents an instantaneous value. This value can increase, decrease, or remain constant. Used to monitor an instantaneous state or level such as current memory usage, instantaneous CPU usage, or number of active threads.

    **Available Operations:**

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

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

    **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 observed duration
    * `histogram_quantile`: Calculates percentiles
  </Card>

  <Card title="Summary" icon="chart-bar">
    A metric that calculates both the total of observed values and predetermined percentiles (quantiles). The difference from Timer and DistributionSummary is that it directly collects percentiles itself; since this is calculated when metrics are collected rather than at query time, percentiles are more accurate.

    **Available Operations:**

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

## Cache Metrics

<Info>
  These metrics monitor Cache's cache performance. Efficiency is analyzed by tracking cache lookups, additions, and latencies. Additionally, memory cost and distribution by partitions are measured.
</Info>

| Metric                           | Description                           | Type    |
| -------------------------------- | ------------------------------------- | ------- |
| `cache_gets_total`               | Total cache lookups (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

<Info>
  These metrics monitor Cache's API performance. API performance is evaluated with data such as request count, response time, and error rates.
</Info>

| 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

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

| 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

<Info>
  These metrics monitor Cache's overall performance with data such as CPU usage, processor count, and load average. Additionally, resource usage is evaluated with data such as process duration and open file counts.
</Info>

| Metric                     | Description                     | Type  |
| -------------------------- | ------------------------------- | ----- |
| `system_cpu_usage`         | Main system CPU usage           | 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 |
