# Logs and Dashboards

> Watch API Maker run - log profiles which choose the calls to log, the log explorer which searches them, the servers of the cluster with their configuration, the Redis dashboard of the cache, and the ER diagram of the account.

Source: https://docs.apimaker.dev/v4/docs/logs/logs-and-dashboards.html

What the admin panel shows of API Maker at work : the calls it logged, the servers it runs on, its cache, and the tables it knows.

## Log profiles

A log profile says which calls are written to the log database. Several profiles can be active ; a call is logged when any active profile selects its API.

| | |
|---|---|
| Page | `Operations → Log Profile` : the profiles on the left, the tree of the account on the right. |
| Selects | Tables and their APIs, custom APIs, system APIs, events, schedulers, WebSocket events. |
| Per API | **Save this API's response in the log** keeps the answer next to the request. |
| Active | Only active profiles log. **Clone** copies a profile ; a **default** profile can be marked. |
| Read | [Log Explorer](https://docs.apimaker.dev/v4/docs/logs/logs-and-dashboards.html#log-explorer). |

1. **Add New**, give a name, check the APIs, decide per API whether the response is kept, **Save Log Profile**.
2. Make it active. From now on every call of those APIs, on every server, writes an entry : who called, from where, how long it took, the payload and the console output of your code.
3. Open the Log Explorer to search them.

- Logs live in the log database of the [configuration](https://docs.apimaker.dev/v4/docs/am-resources/api-maker-configurations.html) (`logs.mongo_db_connection_logs`) and are trimmed to `maxLogsCount` by a daily job.
- Log profiles go to Git.

## Log explorer

`Operations → Log Explorer` is where the entries written by the [log profiles](https://docs.apimaker.dev/v4/docs/logs/logs-and-dashboards.html#log-profiles) are searched.

| | |
|---|---|
| Columns | Time, method, status, duration, category, API and table, API user, tenant, server, client IP, user agent, request id, rows returned, payload size, size, cached response, log id. Pick the columns and the density ; save a search. |
| Filters | A time window (relative or absolute), the duration between two values, a category, a status, a text ; **Exclude** removes what matches. |
| One entry | The request (headers, query, path variables, payload), the response when the profile kept it, the console output of your code, the errors. **Copy this call as a cURL command**, **Copy the whole log as JSON**. |
| Export | Every matching event as CSV or JSON. |
| Delete | Every stored log of the account. |

- The **request id** links every log of one request : copy it and search it to see the custom API and the calls it made.
- **Has console output** filters the entries with `g.logger` lines.
- **Log storage is not configured** means the server has no log database : set `logs.mongo_db_connection_logs`.

## Servers

The **Servers** card of the dashboard of the root user lists every server of the cluster, one pill each : a server runs one process of API Maker, and the number on its pill is the threads of that process : as many as its machine has cores. Select a server to see what it runs with. It is the place to check that all servers run the same version and the same configuration after a change of `.env`.

| | |
|---|---|
| Server information | Version of API Maker, the id of the server, the id of its process, its threads, the address it is reached at (`BE_HOST_PORT`), when it started and for how long it has run, its runtime, and the runtime and version of each language its sandboxes use. |
| Platform information | Platform, machine name, home and temp folders, CPU count and model, how long the machine has been up. |
| Configuration | The values it read from `package.json`, `.env`, the environment and the command line : the heap of a sandbox of Node.js, the `.env` path, the log path, the Oracle client path, logs on or off and their cleanup, the Redis expiry and largest cached answer, JWT expiry and issuer, the validity of encrypted data and of refresh tokens, the compression threshold, the body limit, the cron time zone, the most test users, the cleanup of uploaded files, the console output kept. |
| DB connections | The connection pools the server has open, per instance : type, name, most connections, in use, free. |

- The page asks every server through Redis and lists the ones which answer within three seconds : a server is there while its process runs.
- [Schedulers](https://docs.apimaker.dev/v4/docs/apis-all/schedulers/user-created-schedulers-api.html) are spread over these servers : the Schedulers page shows the server running each one.
- Learn what each value does in [API Maker configuration](https://docs.apimaker.dev/v4/docs/am-resources/api-maker-configurations.html).

## Redis dashboard

`Operations → Redis Dashboard` shows the external Redis of the account : the answers cached by [automatic caching](https://docs.apimaker.dev/v4/docs/features/automatic-caching.html) and the keys your code stores with [set redis key](https://docs.apimaker.dev/v4/docs/apis-all/system-apis/system-generated-set-redis-key-api.html).

| | |
|---|---|
| Tree | The keys grouped by their parts (account, kind, instance, database, table…) : **Expand All**, **Collapse All**, search. |
| Per key | Its value and its TTL in seconds. **UpdateTTL** and the value are editable. **Delete** removes a key. |
| New key | **Add New Key** : a name, a value and a TTL. Without a TTL the key lives until it is deleted. |
| Flush | **Flush redis database** empties it : every cached answer and every key of yours. |
| Refresh | Reloads the tree. |

- A cached answer of a table reads as `…:<instance>:<database>:<table>:…`. Deleting it is a manual cache reset for that one request.
- The internal Redis of API Maker (auto increment counters, cluster coordination) is not shown here : the [Auto Increments](https://docs.apimaker.dev/v4/docs/features/auto-increment.html) page manages the counters.

## ER diagram

`Database → ER Diagram` draws the account : every active instance, its databases, their tables, and the relations the [schemas](https://docs.apimaker.dev/v4/docs/schema/schema.html#6-relations-and-virtual-fields) declare with `collection` and `column`.

| | |
|---|---|
| Boxes | One per table, with its fields and their types, grouped by database and instance. **Expand All** and **Collapse All**. |
| Lines | A relation from a field to the column of another table. Virtual fields draw the reverse. |
| Marks | `PK` primary key · `AM+` auto increment by API Maker · `DB+` auto increment by the database · `R` required |
| Zoom | Double click zooms in, `Shift` + double click zooms out, the mouse wheel does both. |

- A table without a schema shows without relations : generate its schema to see them.

## Related

- [API Maker configuration](https://docs.apimaker.dev/v4/docs/am-resources/api-maker-configurations.html) · [Automatic caching](https://docs.apimaker.dev/v4/docs/features/automatic-caching.html) · [Table schema](https://docs.apimaker.dev/v4/docs/schema/schema.html)
