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

# Gateway Metrics Overview

> Apinizer Gateway collects various metrics about API traffic, external connections, cache operations, and JVM status. These metrics are presented in Prometheus format and can be used to monitor, analyze, and optimize API performance. Metrics are collected in two formats: general and tagged, and are categorized into Counter, Gauge, Timer, and DistributionSummary types.

## Metric Categories

Apinizer Gateway metrics are divided into four main categories:

<CardGroup cols={2}>
  <Card title="API Traffic Metrics" icon="chart-line">
    Provides detailed information about API requests, success/error rates, response times, and sizes.
  </Card>

  <Card title="External Connection Metrics" icon="network-wired">
    Provides information about requests made to external services, success/error rates, and response times.
  </Card>

  <Card title="Cache Metrics" icon="database">
    Provides information about cache operations, success/error rates, and response times.
  </Card>

  <Card title="JVM Metrics" icon="microchip">
    Provides information about memory usage, GC, thread status, and processor usage.
  </Card>
</CardGroup>

## Metric Formats

Each metric is collected in two formats:

<Columns cols={2}>
  <Card title="General Metric" icon="layer-group">
    Total values without labels. For example, total number of all API requests.
  </Card>

  <Card title="Tagged Metric" icon="tags">
    Metrics enriched with labels for detailed analysis. For example, requests by API ID.
  </Card>
</Columns>

## Prometheus Metric Types

Gateway metrics are collected using four basic metric types of Prometheus. These types are designed to best represent different data types and behaviors.

<Info>
  Each metric type serves different purposes depending on how you collect and analyze the data.
</Info>

### Counter

<Card title="Counter (Counter)" icon="arrow-up">
  It 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.
</Card>

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

### Gauge

<Card title="Gauge (Gauge)" icon="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.
</Card>

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

### Timer

<Card title="Timer (Timer)" icon="clock">
  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.
</Card>

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

### DistributionSummary

<Card title="DistributionSummary (Distribution Summary)" icon="chart-bar">
  Used to monitor the distribution of a value. It works similarly to Timer, but instead of measuring time, it measures arbitrary numerical values such as request size, file size. This metric also provides statistical information such as average, maximum, and percentile slices.
</Card>

**Available Operations:**

* `sum`: Gives the total value
* `count`: Gives the number of observed values
* `mean`: Calculates the average of values
* `max`: Gives the largest value observed
* `histogram_quantile`: Calculates percentile slices

## API Traffic Metrics

These metrics are used to monitor API requests passing through Apinizer and measure their performance. While total requests, success, error, and cache hit rates are tracked numerically, request processing time and data sizes are measured for performance analysis.

<Info>
  Some metrics are provided with **api\_id** and **api\_name** labels for API-based detailed examination.
</Info>

### General Metrics

| Metric Name                                      | Description                     | Type                |
| ------------------------------------------------ | ------------------------------- | ------------------- |
| apinizer\_api\_traffic\_total\_count             | Total API traffic requests      | Counter             |
| apinizer\_api\_traffic\_success\_count           | Successful API requests         | Counter             |
| apinizer\_api\_traffic\_error\_count             | Failed API requests             | Counter             |
| apinizer\_api\_traffic\_blocked\_count           | Blocked API requests            | Counter             |
| apinizer\_api\_traffic\_request\_pipeline\_time  | API request pipeline time (ms)  | Timer               |
| apinizer\_api\_traffic\_routing\_time            | API routing time (ms)           | Timer               |
| apinizer\_api\_traffic\_response\_pipeline\_time | API response pipeline time (ms) | Timer               |
| apinizer\_api\_traffic\_total\_time              | API total time (ms)             | Timer               |
| apinizer\_api\_traffic\_request\_size            | API request size (byte)         | DistributionSummary |
| apinizer\_api\_traffic\_response\_size           | API response size (byte)        | DistributionSummary |
| apinizer\_api\_traffic\_cache\_hits\_count       | API cache hit count             | Counter             |

### Tagged Metrics (api\_id, api\_name)

| Metric Name                                              | Description                     | Type                | Labels             |
| -------------------------------------------------------- | ------------------------------- | ------------------- | ------------------ |
| apinizer\_api\_traffic\_total\_count\_tagged             | Total API traffic requests      | Counter             | api\_id, api\_name |
| apinizer\_api\_traffic\_success\_count\_tagged           | Successful API requests         | Counter             | api\_id, api\_name |
| apinizer\_api\_traffic\_error\_count\_tagged             | Failed API requests             | Counter             | api\_id, api\_name |
| apinizer\_api\_traffic\_blocked\_count\_tagged           | Blocked API requests            | Counter             | api\_id, api\_name |
| apinizer\_api\_traffic\_request\_pipeline\_time\_tagged  | API request pipeline time (ms)  | Timer               | api\_id, api\_name |
| apinizer\_api\_traffic\_routing\_time\_tagged            | API routing time (ms)           | Timer               | api\_id, api\_name |
| apinizer\_api\_traffic\_response\_pipeline\_time\_tagged | API response pipeline time (ms) | Timer               | api\_id, api\_name |
| apinizer\_api\_traffic\_total\_time\_tagged              | API total time (ms)             | Timer               | api\_id, api\_name |
| apinizer\_api\_traffic\_request\_size\_tagged            | API request size (byte)         | DistributionSummary | api\_id, api\_name |
| apinizer\_api\_traffic\_response\_size\_tagged           | API response size (byte)        | DistributionSummary | api\_id, api\_name |
| apinizer\_api\_traffic\_cache\_hits\_count\_tagged       | API cache hit count             | Counter             | api\_id, api\_name |

## External Connection Metrics

These metrics are used to monitor external requests made through Apinizer. Performance of external services is analyzed by measuring total requests, error count, and response time.

<Info>
  Some metrics are provided with the **url** label for URL-based detailed examination.
</Info>

### General Metrics

| Metric Name                                | Description                  | Type    |
| ------------------------------------------ | ---------------------------- | ------- |
| apinizer\_external\_requests\_total\_count | Total external request count | Counter |
| apinizer\_external\_errors\_total\_count   | Total external error count   | Counter |
| apinizer\_external\_response\_time         | External response time (ms)  | Timer   |

### Tagged Metrics (url)

| Metric Name                                        | Description                  | Type    | Labels |
| -------------------------------------------------- | ---------------------------- | ------- | ------ |
| apinizer\_external\_requests\_total\_count\_tagged | Total external request count | Counter | url    |
| apinizer\_external\_errors\_total\_count\_tagged   | Total external error count   | Counter | url    |
| apinizer\_external\_response\_time\_tagged         | External response time (ms)  | Timer   | url    |

## Cache Metrics

These metrics are used to monitor the interaction of the worker (gateway) pod with cache. How the worker pod performs cache operations and its performance is analyzed by measuring total requests, error count, and response time.

| Metric Name                             | Description                        | Type    |
| --------------------------------------- | ---------------------------------- | ------- |
| apinizer\_cache\_requests\_total\_count | Total cache request count          | Counter |
| apinizer\_cache\_errors\_total\_count   | Total cache error count            | Counter |
| apinizer\_cache\_response\_time         | Cache operation response time (ms) | Timer   |

## JVM Metrics

These metrics are used to monitor JVM performance and resource usage in the worker (gateway) pod. They help analyze the system's efficient operation by providing detailed information about memory, GC (Garbage Collection) activity, and thread status.

| Metric Name                              | Description                             | Type    |
| ---------------------------------------- | --------------------------------------- | ------- |
| jvm\_buffer\_count\_buffers              | Number of buffers used by JVM           | Gauge   |
| jvm\_buffer\_memory\_used\_bytes         | Total buffer memory used (byte)         | Gauge   |
| jvm\_buffer\_total\_capacity\_bytes      | Buffer total capacity (byte)            | Gauge   |
| jvm\_gc\_live\_data\_size\_bytes         | Data size surviving after GC (byte)     | Gauge   |
| jvm\_gc\_max\_data\_size\_bytes          | Maximum data size for GC (byte)         | Gauge   |
| jvm\_gc\_memory\_allocated\_bytes\_total | Amount of memory allocated by GC (byte) | Counter |
| jvm\_gc\_memory\_promoted\_bytes\_total  | Memory promoted by GC (byte)            | Counter |
| jvm\_gc\_pause\_seconds\_count           | Total number of GC pauses               | Counter |
| jvm\_gc\_pause\_seconds\_max             | Longest GC pause (seconds)              | Gauge   |
| jvm\_gc\_pause\_seconds\_sum             | Total GC pause duration (seconds)       | Gauge   |
| 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\_threads\_live\_threads              | Current number of live threads          | Gauge   |
| jvm\_threads\_daemon\_threads            | Current number of daemon threads        | Gauge   |
| 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   |
