# Metrics API

## Metrics API

Diarkis provides a default endpoint to obtain metrics.

It is designed to feed values into Prometheus for visualization with Grafana, or to obtain JSON format data for a quick check of current indicators locally.

The metrics are updated every 2 seconds.

In addition to the default metrics, you can also define and output custom metrics.

## Endpoint

* $HTTP\_ENDPOINT/metrics/prometheus/v/3: Provides a scraping endpoint for Prometheus (<https://prometheus.io/>).
  * `curl $HTTP_ENDPOINT/metrics/prometheus/v/3`
* $HTTP\_ENDPOINT/metrics/json: Returns the same content in JSON format.
  * `curl $HTTP_ENDPOINT/metrics/json`

## Metrics Defined by Default in Diarkis

| Indicator Name                                     | Description                                                                                           |
| -------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| Users\_UDP\_node                                   | Number of users connected to the UDP server                                                           |
| Users\_TCP\_node                                   | Number of users connected to the TCP server                                                           |
| UDP\_Packets\_In\_UDP\_node                        | Number of UDP packets received by the UDP server                                                      |
| TCP\_Packets\_In\_TCP\_node                        | Number of TCP packets received by the TCP server                                                      |
| TCP\_Packets\_Out\_TCP\_node                       | Number of TCP packets sent by the TCP server                                                          |
| UDP\_Packets\_Out\_UDP\_node                       | Number of UDP packets sent by the UDP server                                                          |
| UDP\_Packets\_In\_UDP\_node                        | Number of UDP packets received by the UDP server                                                      |
| Commands\_In\_UDP\_node                            | Number of commands received by the UDP server (A single packet can contain multiple commands.)        |
| Commands\_In\_TCP\_node                            | Number of commands received by the TCP server (A single packet can contain multiple commands.)        |
| Commands\_Out\_UDP\_node                           | Number of commands sent by the UDP server to clients (A single packet can contain multiple commands.) |
| Commands\_Out\_TCP\_node                           | Number of commands sent by the TCP server to clients (A single packet can contain multiple commands.) |
| RUDP\_Retries\_UDP\_node                           | Number of RUDP retries on the UDP server                                                              |
| RUDP\_Split\_In\_UDP\_node                         | Number of packets received by the UDP server that exceed MTU                                          |
| RUDP\_Split\_Out\_UDP\_node                        | Number of packets sent by the UDP server that exceed MTU                                              |
| Mesh\_Packets\_In\_HTTP\_node                      | Number of packets received in the internal network by the HTTP server                                 |
| Mesh\_Packets\_In\_UDP\_node                       | Number of packets received in the internal network by the UDP server                                  |
| Mesh\_Packets\_In\_TCP\_node                       | Number of packets received in the internal network by the TCP server                                  |
| Mesh\_Packets\_Out\_HTTP\_node                     | Number of packets sent in the internal network by the HTTP server                                     |
| Mesh\_Packets\_Out\_UDP\_node                      | Number of packets sent in the internal network by the UDP server                                      |
| Mesh\_Packets\_Out\_TCP\_node                      | Number of packets sent in the internal network by the TCP server                                      |
| Mesh\_Retry\_UDP\_node                             | Number of retries in the internal network by the UDP server                                           |
| Mesh\_Retry\_TCP\_node                             | Number of retries in the internal network by the TCP server                                           |
| Rooms\_UDP\_node                                   | Number of rooms in the UDP server                                                                     |
| Rooms\_TCP\_node                                   | Number of rooms in the TCP server                                                                     |
| Groups\_UDP\_node                                  | Number of groups in the UDP server                                                                    |
| Groups\_TCP\_node                                  | Number of groups in the TCP server                                                                    |
| MatchMaker\_Search\_HTTP\_node                     | Number of MatchMaker searches performed by the HTTP server                                            |
| MatchMaker\_Empty\_HTTP\_node                      | Number of empty MatchMaker searches performed by the HTTP server                                      |
| MatchMaker\_Ticket\_UDP\_node                      | Number of MatchMaker tickets in the UDP server                                                        |
| MatchMaker\_Ticket\_TCP\_node                      | Number of MatchMaker tickets in the TCP server                                                        |
| MatchMaker\_Ticket\_Search\_UDP\_node              | Number of MatchMaker searches issued by the UDP server                                                |
| MatchMaker\_Ticket\_Search\_TCP\_node              | Number of MatchMaker searches issued by the TCP server                                                |
| MatchMaker\_Ticket\_Add\_UDP\_node                 | Number of searches originating from MatchMaker tickets issued by the UDP server                       |
| MatchMaker\_Ticket\_Add\_TCP\_node                 | Number of searches originating from MatchMaker tickets issued by the TCP server                       |
| MatchMaker\_Complete\_UDP\_node                    | Number of MatchMaker tickets completed by the UDP server                                              |
| MatchMaker\_Complete\_TCP\_node                    | Number of MatchMaker tickets completed by the TCP server                                              |
| MatchMaker\_Ticket\_Complete\_Time\_Avg\_UDP\_node | Average time taken to complete MatchMaker tickets in the UDP server                                   |
| MatchMaker\_Ticket\_Complete\_Time\_Avg\_TCP\_node | Average time taken to complete MatchMaker in the TCP server                                           |
| MatchMaker\_Ticket\_Complete\_Time\_Min\_UDP\_node | Minimum time taken to complete MatchMaker tickets in the UDP server                                   |
| MatchMaker\_Ticket\_Complete\_Time\_Min\_TCP\_node | Minimum time taken to complete MatchMaker tickets in the TCP server                                   |
| MatchMaker\_Ticket\_Complete\_Time\_Max\_UDP\_node | Maximum time taken to complete MatchMaker tickets in the UDP server                                   |
| MatchMaker\_Ticket\_Complete\_Time\_Max\_TCP\_node | Maximum time taken to complete MatchMaker tickets in the TCP server                                   |
| P2P\_Success\_UDP\_node                            | Number of successful P2P attempts                                                                     |
| P2P\_Attempt\_UDP\_node                            | Number of P2P attempts                                                                                |
| Field\_Grids\_UDP\_node                            | Number of Field grids held by the UDP server                                                          |
| Field\_Grids\_TCP\_node                            | Number of Field grids held by the TCP server                                                          |

## Prometheus Setup Instructions

\#TODO

## Custom Metrics Setup Instructions


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.diarkis.io/en/diarkis-server/metrics-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
