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

> You can use example PromQL queries to analyze Apinizer Cache metrics. You can use ready queries for cache analyses, Cache API analyses, JVM analyses and system analyses in Prometheus and Grafana.

## Cache Analyses

Metrics used to monitor cache usage and efficiency. Performance is evaluated with data such as cache searches, additions, and memory consumption.

### 1. Total Cache Search 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

Used to monitor the performance of Cache API requests. The system's ability to respond is analyzed with data such as API request count and success rate.

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

Application's resource consumption and performance are evaluated by monitoring JVM's memory usage, GC (Garbage Collector) pause durations, and thread count.

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

General resource usage and performance are monitored with data such as system's CPU usage, process duration, and number of open file descriptors.

### 1. CPU Usage of Pods

```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. Number of Open File Descriptors

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