# SLOWLOG EXPORT

> Return every slow log entry as a JSON array, including the user, tenant and database.

URL: https://docs.hotkv.com/commands/slowlog-export/

```
SLOWLOG EXPORT
```

- Group: Server
- Complexity: O(N) where N is the number of entries
- HotKV Cloud: all plans
- On-Premise: no license needed

`SLOWLOG EXPORT` returns the whole slow log as one JSON document, oldest
entry first. Besides the fields of [SLOWLOG GET](https://docs.hotkv.com/commands/slowlog-get/index.md), each
entry says which ACL user ran the command, in which tenant and in which
database, which makes it easy to send the log to a log pipeline or to find
which team's workload is slow.

## Return value

A bulk string holding a JSON array, in RESP2 and RESP3. Each element is an
object:

| Key | Value |
| --- | --- |
| `id` | Entry id. |
| `timestamp` | Unix time in seconds. |
| `duration_us` | Execution time in microseconds. |
| `args` | Array of the command's arguments, shortened as in `SLOWLOG GET`. |
| `client_addr` | Client address and port. |
| `client_name` | Client name, or an empty string. |
| `username` | ACL user of the connection. |
| `tenant_id` | Tenant the command ran for, or an empty string. |
| `database` | Database number. |

Arguments are binary-safe in HotKV but JSON is text: bytes that are not
valid UTF-8 are replaced with U+FFFD, so the output always parses.

## Examples

```
127.0.0.1:6379> SLOWLOG EXPORT
"[{\"id\":41,\"timestamp\":1790000000,\"duration_us\":15320,\"args\":[\"KEYS\",\"*\"],\"client_addr\":\"10.0.0.21:40118\",\"client_name\":\"reporting\",\"username\":\"default\",\"tenant_id\":\"\",\"database\":0}]"
```

## Compatibility

HotKV-only subcommand. Redis 7 and Valkey 8 do not have it.

## See also

[SLOWLOG GET](https://docs.hotkv.com/commands/slowlog-get/index.md), [AUDIT.EXPORT](https://docs.hotkv.com/commands/audit-export/index.md)