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

# Example PromQL Queries for Apinizer Cache

> Provides example PromQL queries that can be used to analyze Apinizer Cache metrics. Includes ready query examples in different categories such as cache performance, API analyses, JVM metrics, and system resource usage. These queries enable monitoring and analyzing Cache performance when used in Grafana dashboards or Prometheus Query UI.

# Example PromQL Queries for Apinizer Cache

## Cache Analyses

<Info>
  Metrics used to monitor cache usage and efficiency. Performance is evaluated with data such as cache lookups, additions, and memory consumption.
</Info>

### 1. Total Cache Lookup Count (for 1 hour)

```promql theme={null}
sum(increase(cache_gets_total[1h]))
```

### 2. Cache Addition Count (for 10 minutes)

```promql theme={null}
sum(increase(cache_puts_total[10m]))
```

### 3. Cache Hit Rate (%) (for 5 minutes)

```promql theme={null}
(sum(increase(cache_gets_total[5m])) - sum(increase(apinizer_cache_api_errors_total[5m]))) / sum(increase(cache_gets_total[5m])) * 100
```

### 4. Current Number of Entries in Cache

```promql theme={null}
sum(cache_size)
```

### 5. Cache Features with Highest Memory Usage

```promql theme={null}
topk(5, sum by (cache) (cache_entry_memory_bytes))
```

## Cache API Analyses

<Info>
  Used to monitor Cache API request performance. The system's ability to respond is analyzed with data such as API request count and success rate.
</Info>

### 1. Total API Request Count (for 1 hour)

```promql theme={null}
sum(increase(apinizer_cache_api_requests_total[1h]))
```

### 2. API Success Rate (%) (for 10 minutes)

```promql theme={null}
(sum(increase(apinizer_cache_api_requests_total[10m])) - sum(increase(apinizer_cache_api_errors_total[10m]))) / sum(increase(apinizer_cache_api_requests_total[10m])) * 100
```

## JVM Analyses

<Info>
  Evaluates application resource consumption and performance by monitoring JVM memory usage, GC (Garbage Collector) pause times, and thread count.
</Info>

### 1. Memory Usage Percentage

```promql theme={null}
(sum(jvm_memory_used_bytes{application="apinizer-cache"}) * 100) / sum(jvm_memory_max_bytes{application="apinizer-cache"})
```

### 2. Garbage Collection Duration (for 5 minutes)

```promql theme={null}
sum(rate(jvm_gc_pause_seconds_sum{application="apinizer-cache"}[5m]))
```

### 3. Current Number of Live Threads

```promql theme={null}
sum(jvm_threads_live_threads{application="apinizer-cache"})
```

## System Analyses

<Info>
  Monitors overall resource usage and performance with data such as system CPU usage, process duration, and open file descriptor counts.
</Info>

### 1. Pod CPU Usage

```promql theme={null}
sum(rate(container_cpu_usage_seconds_total{namespace="apinizer"}[5m])) by (pod) * 100
```

### 2. JVM Process Duration (seconds)

```promql theme={null}
sum(process_uptime_seconds)
```

### 3. Open File Descriptor Count

```promql theme={null}
sum(process_files_open_files{application="apinizer-cache"})
```
