slow log configuration implemented
This commit is contained in:
parent
63d62eb786
commit
35a6044140
18
redis.conf
18
redis.conf
@ -312,6 +312,24 @@ no-appendfsync-on-rewrite no
|
|||||||
auto-aof-rewrite-percentage 100
|
auto-aof-rewrite-percentage 100
|
||||||
auto-aof-rewrite-min-size 64mb
|
auto-aof-rewrite-min-size 64mb
|
||||||
|
|
||||||
|
################################## SLOW LOG ###################################
|
||||||
|
|
||||||
|
# The Redis Slow Log is a system to log queries that exceeded a specified
|
||||||
|
# execution time. The execution time does not include the I/O operations
|
||||||
|
# like talking with the client, sending the reply and so forth,
|
||||||
|
# but just the time needed to actually execute the command (this is the only
|
||||||
|
# stage of command execution where the thread is blocked and can not serve
|
||||||
|
# other requests in the meantime).
|
||||||
|
#
|
||||||
|
# You can configure the slow log with two parameters: one tells Redis
|
||||||
|
# what is the execution time, in microseconds, to exceed in order for the
|
||||||
|
# command to get logged, and the other parameter is the length of the
|
||||||
|
# slow log. When a new command is logged the oldest one is removed from the
|
||||||
|
# queue of logged commands.
|
||||||
|
|
||||||
|
slowlog-log-slower-than 10000
|
||||||
|
slowlog-log-len 1024
|
||||||
|
|
||||||
############################### ADVANCED CONFIG ###############################
|
############################### ADVANCED CONFIG ###############################
|
||||||
|
|
||||||
# Hashes are encoded in a special way (much more memory efficient) when they
|
# Hashes are encoded in a special way (much more memory efficient) when they
|
||||||
|
22
src/config.c
22
src/config.c
@ -296,6 +296,12 @@ void loadServerConfig(char *filename) {
|
|||||||
} else if (!strcasecmp(argv[0],"cluster-config-file") && argc == 2) {
|
} else if (!strcasecmp(argv[0],"cluster-config-file") && argc == 2) {
|
||||||
zfree(server.cluster.configfile);
|
zfree(server.cluster.configfile);
|
||||||
server.cluster.configfile = zstrdup(argv[1]);
|
server.cluster.configfile = zstrdup(argv[1]);
|
||||||
|
} else if (!strcasecmp(argv[0],"slowlog-log-slower-than") &&
|
||||||
|
argc == 2)
|
||||||
|
{
|
||||||
|
server.slowlog_log_slower_than = strtoll(argv[1],NULL,10);
|
||||||
|
} else if (!strcasecmp(argv[0],"slowlog-max-len") && argc == 2) {
|
||||||
|
server.slowlog_max_len = strtoll(argv[1],NULL,10);
|
||||||
} else {
|
} else {
|
||||||
err = "Bad directive or wrong number of arguments"; goto loaderr;
|
err = "Bad directive or wrong number of arguments"; goto loaderr;
|
||||||
}
|
}
|
||||||
@ -466,6 +472,12 @@ void configSetCommand(redisClient *c) {
|
|||||||
} else if (!strcasecmp(c->argv[2]->ptr,"zset-max-ziplist-value")) {
|
} else if (!strcasecmp(c->argv[2]->ptr,"zset-max-ziplist-value")) {
|
||||||
if (getLongLongFromObject(o,&ll) == REDIS_ERR || ll < 0) goto badfmt;
|
if (getLongLongFromObject(o,&ll) == REDIS_ERR || ll < 0) goto badfmt;
|
||||||
server.zset_max_ziplist_value = ll;
|
server.zset_max_ziplist_value = ll;
|
||||||
|
} else if (!strcasecmp(c->argv[2]->ptr,"slowlog-log-slower-than")) {
|
||||||
|
if (getLongLongFromObject(o,&ll) == REDIS_ERR) goto badfmt;
|
||||||
|
server.slowlog_log_slower_than = ll;
|
||||||
|
} else if (!strcasecmp(c->argv[2]->ptr,"slowlog-max-len")) {
|
||||||
|
if (getLongLongFromObject(o,&ll) == REDIS_ERR || ll < 0) goto badfmt;
|
||||||
|
server.slowlog_max_len = (unsigned)ll;
|
||||||
} else {
|
} else {
|
||||||
addReplyErrorFormat(c,"Unsupported CONFIG parameter: %s",
|
addReplyErrorFormat(c,"Unsupported CONFIG parameter: %s",
|
||||||
(char*)c->argv[2]->ptr);
|
(char*)c->argv[2]->ptr);
|
||||||
@ -637,6 +649,16 @@ void configGetCommand(redisClient *c) {
|
|||||||
addReplyBulkLongLong(c,server.zset_max_ziplist_value);
|
addReplyBulkLongLong(c,server.zset_max_ziplist_value);
|
||||||
matches++;
|
matches++;
|
||||||
}
|
}
|
||||||
|
if (stringmatch(pattern,"slowlog-log-slower-than",0)) {
|
||||||
|
addReplyBulkCString(c,"slowlog-log-slower-than");
|
||||||
|
addReplyBulkLongLong(c,server.slowlog_log_slower_than);
|
||||||
|
matches++;
|
||||||
|
}
|
||||||
|
if (stringmatch(pattern,"slowlog-max-len",0)) {
|
||||||
|
addReplyBulkCString(c,"slowlog-max-len");
|
||||||
|
addReplyBulkLongLong(c,server.slowlog_max_len);
|
||||||
|
matches++;
|
||||||
|
}
|
||||||
setDeferredMultiBulkLength(c,replylen,matches*2);
|
setDeferredMultiBulkLength(c,replylen,matches*2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,7 +529,7 @@ struct redisServer {
|
|||||||
long long stat_fork_time; /* time needed to perform latets fork() */
|
long long stat_fork_time; /* time needed to perform latets fork() */
|
||||||
list *slowlog;
|
list *slowlog;
|
||||||
long long slowlog_log_slower_than;
|
long long slowlog_log_slower_than;
|
||||||
unsigned int slowlog_max_len;
|
unsigned long slowlog_max_len;
|
||||||
/* Configuration */
|
/* Configuration */
|
||||||
int verbosity;
|
int verbosity;
|
||||||
int maxidletime;
|
int maxidletime;
|
||||||
|
@ -54,6 +54,7 @@ void slowlogInit(void) {
|
|||||||
* This function will make sure to trim the slow log accordingly to the
|
* This function will make sure to trim the slow log accordingly to the
|
||||||
* configured max length. */
|
* configured max length. */
|
||||||
void slowlogPushEntryIfNeeded(robj **argv, int argc, long long duration) {
|
void slowlogPushEntryIfNeeded(robj **argv, int argc, long long duration) {
|
||||||
|
if (server.slowlog_log_slower_than < 0) return; /* Slowlog disabled */
|
||||||
if (duration > server.slowlog_log_slower_than)
|
if (duration > server.slowlog_log_slower_than)
|
||||||
listAddNodeHead(server.slowlog,slowlogCreateEntry(argv,argc,duration));
|
listAddNodeHead(server.slowlog,slowlogCreateEntry(argv,argc,duration));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user