Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Document the latest metrics improvements #242

Merged
merged 9 commits into from
Jul 31, 2023
65 changes: 49 additions & 16 deletions text/0174-metrics-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,27 @@ A metric is composed by several fields:

Meilisearch returns the metrics specified in the table below.

| Name | Type |
|---------------------------------------------------------------------------|-----------|
| [`http_requests_total`](#321-http_requests_total) | counter |
| [`http_response_time_seconds`](#322-http_response_time_seconds) | histogram |
| [`meilisearch_database_size_bytes`](#323-meilisearch_database_size_bytes) | gauge |
| [`meilisearch_index_docs_count`](#324-meilisearch_index_docs_count) | gauge |
| [`meilisearch_index_count`](#325-meilisearch_index_count) | gauge |

#### 3.2.1 `http_requests_total`
| Name | Type |
|----------------------------------------------------------------------------------------|-----------|
| [`meilisearch_http_requests_total`](#321-meilisearch_http_requests_total) | counter |
| [`meilisearch_http_response_time_seconds`](#322-meilisearch_http_response_time_seconds)| histogram |
| [`meilisearch_db_size_bytes`](#323-meilisearch_db_size_bytes) | gauge |
| [`meilisearch_used_db_size_bytes`](#324-meilisearch_used_db_size_bytes) | gauge |
| [`meilisearch_index_docs_count`](#325-meilisearch_index_docs_count) | gauge |
| [`meilisearch_index_count`](#326-meilisearch_index_count) | gauge |
| [`meilisearch_nb_tasks`](#327-meilisearch_nb_tasks) | counter |

#### 3.2.1 `meilisearch_http_requests_total`

Returns the number of times an API resource is accessed.

```
# HELP http_requests_total HTTP requests total
# TYPE http_requests_total counter
http_requests_total{method=":httpMethod",path=":resourcePath"} :numberOfRequest
meilisearch_http_requests_total{method=":httpMethod",path=":resourcePath"} :numberOfRequest
```

#### 3.2.2. `http_responses_time_seconds`
#### 3.2.2. `meilisearch_http_response_time_seconds`

Returns a time histogram showing the number of times an API resource call goes into a time bucket (expressed in second).

Expand All @@ -74,20 +76,33 @@ http_response_time_seconds_bucket{method=":httpMethod",path=":resourcePath",le="
http_response_time_seconds_bucket{method=":httpMethod",path=":resourcePath",le="1"} :numberOfRequest
http_response_time_seconds_bucket{method=":httpMethod",path=":resourcePath",le="+Inf"} :numberOfRequest
http_response_time_seconds_sum{method=":httpMethod",path=":resourcePath"} :numberOfRequest
http_response_time_seconds_count{method=":httpMethod",path=":resourcePath"} :numberOfRequest
meilisearch_http_response_time_seconds_count{method=":httpMethod",path=":resourcePath"} :numberOfRequest
```

#### 3.2.3. `meilisearch_database_size_bytes`
#### 3.2.3. `meilisearch_db_size_bytes`

Returns the size of the database in bytes.
Returns the “real” size of the database on disk in bytes.
It includes all the lmdb memory mapped files plus all the files contained in the `data.ms` directory (mainly the updates files that were not processed yet).

```
# HELP meilisearch_db_size_bytes Meilisearch Db Size In Bytes
# TYPE meilisearch_db_size_bytes gauge
meilisearch_db_size_bytes :databaseSizeInBytes
```

#### 3.2.4. `meilisearch_index_docs_count`
#### 3.2.4. `meilisearch_used_db_size_bytes`

Returns the size of the database actually used by meilisearch in bytes.
Include all the same files as `meilisearch_db_size_bytes` except that when it comes to an LMDB database, we only count the pages used by meilisearch.
This means if you see a large gap between both metrics, adding documents will probably re-use freed pages instead of growing `meilisearch_db_size_bytes`.

```
# HELP meilisearch_used_db_size_bytes Meilisearch Used DB Size In Bytes
# TYPE meilisearch_used_db_size_bytes gauge
meilisearch_used_db_size_bytes :databaseSizeInBytes
```

#### 3.2.5. `meilisearch_index_docs_count`

Returns the number of documents for an index.

Expand All @@ -97,7 +112,7 @@ Returns the number of documents for an index.
meilisearch_index_docs_count{index=":indexUid"} :numberOfDocuments
```

#### 3.2.5. `meilisearch_index_count`
#### 3.2.6. `meilisearch_index_count`

Returns the total number of index for the Meilisearch instance.

Expand All @@ -107,6 +122,24 @@ Returns the total number of index for the Meilisearch instance.
meilisearch_index_count :numberOfIndex
````

#### 3.2.7. `meilisearch_nb_tasks`

Returns the total number of index for the Meilisearch instance.
irevoire marked this conversation as resolved.
Show resolved Hide resolved

```
# HELP meilisearch_nb_tasks Meilisearch Number of tasks
# TYPE meilisearch_nb_tasks gauge
meilisearch_nb_tasks{kind=":kind",value=":value"} :number
````

Here is a list of available kind and associated values:

| Kind | values |
|-----------|------------------------------------------------------------------------|
| indexes | Any created indexes |
| statuses | Any task statuses (i.e.: succeeded, failed, enqueued, etc...) |
| types | Any task types (i.e.: documentAdditionOrUpdate, settingsUpdate, etc...)|

### 3.3. API Endpoints Definition

#### 3.3.1. `GET` - `/metrics`
Expand Down