COMMANDLOG GET · Valkey

COMMANDLOG GET

Returns the specified command log’s entries.

Usage

COMMANDLOG GET count <slow | large-request | large-reply>

Description

The COMMANDLOG GET command returns entries from the command log of specified type in chronological order.

The Command Log system is used to record commands that consume significant resources during server operation, including CPU, memory, and network bandwidth. These commands and the data they access may lead to abnormal instance operations, the command log can help users quickly and intuitively locate issues.

Currently, three types of command logs are supported:

Each log type has two key parameters: 1. A threshold value that determines when a command is logged. This threshold is specific to the type of log (e.g., execution time, request size, or reply size). A negative value disables logging. A value of 0 logs all commands. 2. A maximum length that specifies the number of entries to retain in the log. Increasing the length allows more entries to be stored but consumes additional memory. To clear all entries for a specific log type and reclaim memory, use the COMMANDLOG RESET subcommand followed by the log type.

See the details of configurations in valkey.conf.

Each entry from the specific type of command log is comprised of the following six values:

  1. A unique progressive identifier for every entry.
  2. The unix timestamp at which the logged command was processed.
  3. Each type of command log has its own meaning, currently there are three types:
  4. The array composing the arguments of the command.
  5. Client peer information (e.g. Client IP address and port for TCP connected clients or unix path for unix sockets).
  6. Client name if set via the CLIENT SETNAME command.

The entry’s unique ID can be used in order to avoid processing command log entries multiple times (for instance you may have a script sending you an email alert for every new command log entry). The ID is never reset in the course of the Valkey server execution, even after COMMANDLOG RESET was executed. In order to reset the ID a server restart is needed.

Complexity

O(N) where N is the number of entries returned

ACL Categories

@admin @dangerous @slow

History

See also

ACL, ACL CAT, ACL DELUSER, ACL DRYRUN, ACL GENPASS, ACL GETUSER, ACL HELP, ACL LIST, ACL LOAD, ACL LOG, ACL SAVE, ACL SETUSER, ACL USERS, ACL WHOAMI, BGREWRITEAOF, BGSAVE, COMMAND, COMMAND COUNT, COMMAND DOCS, COMMAND GETKEYS, COMMAND GETKEYSANDFLAGS, COMMAND HELP, COMMAND INFO, COMMAND LIST, COMMANDLOG, COMMANDLOG HELP, COMMANDLOG LEN, COMMANDLOG RESET, CONFIG, CONFIG GET, CONFIG HELP, CONFIG RESETSTAT, CONFIG REWRITE, CONFIG SET, DBSIZE, DEBUG, FAILOVER, FLUSHALL, FLUSHDB, INFO, LASTSAVE, LATENCY, LATENCY DOCTOR, LATENCY GRAPH, LATENCY HELP, LATENCY HISTOGRAM, LATENCY HISTORY, LATENCY LATEST, LATENCY RESET, LOLWUT, MEMORY, MEMORY DOCTOR, MEMORY HELP, MEMORY MALLOC-STATS, MEMORY PURGE, MEMORY STATS, MEMORY USAGE, MODULE, MODULE HELP, MODULE LIST, MODULE LOAD, MODULE LOADEX, MODULE UNLOAD, MONITOR, PSYNC, REPLCONF, REPLICAOF, RESTORE-ASKING, ROLE, SAVE, SHUTDOWN, SWAPDB, SYNC, TIME.