-
Notifications
You must be signed in to change notification settings - Fork 491
Commit
also add rejected_connections stat
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,48 +20,216 @@ func init() { | |
collectors = append(collectors, &IntervalCollector{F: c_redis, init: redisInit}) | ||
} | ||
|
||
var redisFields = map[string]bool{ | ||
"aof_enabled": true, | ||
"aof_rewrite_in_progress": true, | ||
"aof_rewrite_scheduled": true, | ||
"aof_last_rewrite_time_sec": true, | ||
"aof_current_rewrite_time_sec": true, | ||
"aof_last_bgrewrite_status": true, | ||
"bgrewriteaof_in_progress": true, | ||
"bgsave_in_progress": true, | ||
"blocked_clients": true, | ||
"changes_since_last_save": true, | ||
"client_biggest_input_buf": true, | ||
"client_longest_output_list": true, | ||
"connected_clients": true, | ||
"connected_slaves": true, | ||
"evicted_keys": true, | ||
"expired_keys": true, | ||
"hash_max_zipmap_entries": true, | ||
"hash_max_zipmap_value": true, | ||
"keyspace_hits": true, | ||
"keyspace_misses": true, | ||
"master_link_status": true, | ||
"master_sync_in_progress": true, | ||
"master_last_io_seconds_ago": true, | ||
"master_sync_left_bytes": true, | ||
"mem_fragmentation_ratio": true, | ||
"pubsub_channels": true, | ||
"pubsub_patterns": true, | ||
"rdb_changes_since_last_save": true, | ||
"rdb_bgsave_in_progress": true, | ||
"rdb_last_save_time": true, | ||
"rdb_last_bgsave_status": true, | ||
"rdb_last_bgsave_time_sec": true, | ||
"rdb_current_bgsave_time_sec": true, | ||
"role": true, | ||
"total_commands_processed": true, | ||
"total_connections_received": true, | ||
"uptime_in_seconds": true, | ||
"used_cpu_sys": true, | ||
"used_cpu_user": true, | ||
"used_memory": true, | ||
"used_memory_rss": true, | ||
var redisMeta = map[string]MetricMeta{ // http://redis.io/commands/info) | ||
// Persistence Section | ||
// AOF | ||
"aof_enabled": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.Enabled, | ||
Desc: "AOF Enabled indicates that Append Only File logging is activated.", | ||
}, | ||
"aof_cuurent_size": { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
RateType: metadata.Gauge, | ||
Unit: metadata.Bytes, | ||
Desc: "The current file size of the AOF (Append Only File).", | ||
}, | ||
"aof_rewrite_in_progress": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.InProgress, | ||
Desc: "Rewrite in progress indicates that AOF (Append Only File) logging is activated.", | ||
}, | ||
"aof_rewrite_scheduled": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.Scheduled, | ||
Desc: "AOF rewrite scheduled means an Append Only file rewrite operation will be scheduled once the on-going RDB save is complete.", | ||
}, | ||
"aof_last_rewrite_time_sec": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.Second, | ||
Desc: "The duration of the last AOF (Append Only file) rewrite operation in seconds.", | ||
}, | ||
"aof_current_rewrite_time_sec": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.Second, | ||
Desc: "The duration of the ongoing AOF (Append Only file) rewrite operation in seconds -- if there is one.", | ||
}, | ||
"aof_last_bgrewrite_status": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.Bool, | ||
Desc: "The status of the last AOF (Append Only File) rewrite opperation.", | ||
}, | ||
"changes_since_last_save": { | ||
This comment has been minimized.
Sorry, something went wrong.
gbrayut
Contributor
|
||
RateType: metadata.Gauge, | ||
Unit: metadata.Change, | ||
Desc: "The number of operations that produced some kind of changes in the dataset since the last time either SAVE or BGSAVE was called.", | ||
}, | ||
// RDB | ||
"rdb_bgsave_in_progress": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.InProgress, | ||
Desc: "BGSAVE in progress indicates if a RDB save is on-going.", | ||
}, | ||
"rdb_changes_since_last_save": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.Change, | ||
Desc: "The number of changes since the last dump.", | ||
}, | ||
"rdb_last_bgsave_status": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.Bool, | ||
Desc: "The Status of the last RDB save operation.", | ||
}, | ||
"rdb_last_bgsave_time_sec": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.Second, | ||
Desc: "The duration of the last RDB save operation.", | ||
}, | ||
"rdb_current_bgsave_time_sec": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.Second, | ||
Desc: "The duration of the ongoing RDB save operation -- if there is one.", | ||
}, | ||
"rdb_last_save_time": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.Timestamp, | ||
Desc: "The epoch-based timestamp of last successful RDB save.", | ||
}, | ||
|
||
// Clients Section | ||
"blocked_clients": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.Client, | ||
Desc: "The number of clients pending on a blocking call (BLPOP, BRPOP, BRPOPLPUSH).", | ||
}, | ||
"connected_clients": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.Connection, | ||
Desc: "The number of client connections (excluding connections from slaves).", | ||
}, | ||
"client_biggest_input_buf": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.Count, // Need to figure out what this is, bytes? | ||
Desc: "The biggest input buffer among current client connections.", | ||
}, | ||
"client_longest_output_list": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.Count, // Need to figure out what this is, length? | ||
Desc: "The longest output list among current client connections.", | ||
}, | ||
|
||
// Replication Sections | ||
"connected_slaves": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.Slave, | ||
Desc: "The number of connected slaves.", | ||
}, | ||
"master_link_status": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.Ok, | ||
Desc: "The up/down status of the link to the master.", | ||
}, | ||
"master_last_io_seconds_ago": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.Second, | ||
Desc: "The number of seconds since the last interaction with master.", | ||
}, | ||
"master_sync_in_progress": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.InProgress, | ||
Desc: "Master sync in progress indicates that the master is syncing to the slave.", | ||
}, | ||
"master_sync_left_bytes": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.Bytes, | ||
Desc: "The number of bytes left before syncing is complete.", | ||
}, | ||
"master_sync_last_io_seconds_ago": { | ||
This comment has been minimized.
Sorry, something went wrong.
gbrayut
Contributor
|
||
RateType: metadata.Gauge, | ||
Unit: metadata.Second, | ||
Desc: "The number of seconds since last transfer I/O during a SYNC operation.", | ||
}, | ||
|
||
// Stats Section | ||
"evicted_keys": { | ||
RateType: metadata.Counter, | ||
Unit: metadata.Key, | ||
Desc: "The number of evicted keys due to maxmemory limit.", | ||
}, | ||
"expired_keys": { | ||
RateType: metadata.Counter, | ||
Unit: metadata.Key, | ||
Desc: "The total total number of key expiration events.", | ||
}, | ||
"keyspace_hits": { | ||
RateType: metadata.Counter, | ||
Unit: metadata.CacheHit, | ||
Desc: "The number of successful lookup of keys in the main dictionary.", | ||
}, | ||
"keyspace_misses": { | ||
RateType: metadata.Counter, | ||
Unit: metadata.CacheMiss, | ||
Desc: "The number of failed lookup of keys in the main dictionary.", | ||
}, | ||
"used_cpu_sys": { | ||
RateType: metadata.Counter, | ||
Unit: metadata.Pct, | ||
Desc: "The system CPU used by the main Redis process.", | ||
}, | ||
"used_cpu_user": { | ||
RateType: metadata.Counter, | ||
Unit: metadata.Pct, | ||
Desc: "The user space CPU used by the main Redis process.", | ||
}, | ||
"uptime_in_seconds": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.Second, | ||
Desc: "The number of seconds since Redis server start.", | ||
}, | ||
"total_connections_received": { | ||
RateType: metadata.Counter, | ||
Unit: metadata.Connection, | ||
Desc: "The total number of connections accepted by the server.", | ||
}, | ||
"total_connections_processed": { | ||
This comment has been minimized.
Sorry, something went wrong.
gbrayut
Contributor
|
||
RateType: metadata.Counter, | ||
Unit: metadata.Connection, | ||
Desc: "The total number of connections processed by the server.", | ||
}, | ||
"pubsub_channels": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.Channel, | ||
Desc: "Global number of pub/sub channels with client subscriptions.", | ||
}, | ||
"pubsub_patterns": { | ||
RateType: metadata.Gauge, | ||
Unit: "Pattern", | ||
Desc: "Global number of pub/sub channels with client subscriptions.", | ||
}, | ||
"rejected_connections": { | ||
This comment has been minimized.
Sorry, something went wrong.
gbrayut
Contributor
|
||
RateType: metadata.Counter, | ||
Unit: metadata.Connection, | ||
Desc: "The number of connections rejected because of maxclients limit.", | ||
}, | ||
|
||
// Memory Section | ||
"used_memory": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.Bytes, | ||
Desc: "The total number of bytes allocated by Redis using its allocator (either standard libc, jemalloc, or an alternative allocator such as tcmalloc.", | ||
}, | ||
"used_rss": { | ||
This comment has been minimized.
Sorry, something went wrong.
gbrayut
Contributor
|
||
RateType: metadata.Gauge, | ||
Unit: metadata.Bytes, | ||
Desc: "The number of bytes that Redis allocated as seen by the operating system (a.k.a resident set size). This is the number reported by tools such as top(1) and ps(1).", | ||
}, | ||
"mem_fragmentation_ratio": { | ||
RateType: metadata.Gauge, | ||
Unit: metadata.Ratio, | ||
Desc: "The ratio between used_memory_rss and used_memory.", | ||
}, | ||
|
||
//Other | ||
"role": {}, // This gets treated independtly to create the is_slave metric | ||
} | ||
|
||
// For master_link_status. | ||
|
@@ -221,19 +389,23 @@ func c_redis() (opentsdb.MultiDataPoint, error) { | |
continue | ||
} | ||
sp := strings.Split(line, ":") | ||
if len(sp) < 2 || !(redisFields[sp[0]] || strings.HasPrefix(sp[0], "cmdstat_")) { | ||
if len(sp) < 2 { | ||
continue | ||
} | ||
m, foundMeta := redisMeta[sp[0]] | ||
if !(foundMeta || strings.HasPrefix(sp[0], "cmdstat_")) { | ||
continue | ||
} | ||
if sp[0] == "master_link_status" { | ||
Add(&md, "redis."+sp[0], redisMlsMap[sp[1]], tags, metadata.Unknown, metadata.None, "") | ||
Add(&md, "redis."+sp[0], redisMlsMap[sp[1]], tags, m.RateType, m.Unit, m.Desc) | ||
continue | ||
} | ||
if sp[0] == "role" { | ||
Add(&md, "redis.is_slave", slave(sp[1]), tags, metadata.Gauge, metadata.Bool, "") | ||
Add(&md, "redis.is_slave", slave(sp[1]), tags, metadata.Gauge, metadata.Bool, descRedisIsSlave) | ||
continue | ||
} | ||
if sp[0] == "aof_last_bgrewrite_status" || sp[0] == "rdb_last_bgsave_status" { | ||
Add(&md, "redis."+sp[0], status(sp[1]), tags, metadata.Unknown, metadata.None, "") | ||
Add(&md, "redis."+sp[0], status(sp[1]), tags, m.RateType, m.Unit, m.Desc) | ||
continue | ||
} | ||
if strings.HasPrefix(sp[0], "cmdstat_") { | ||
|
@@ -272,7 +444,7 @@ func c_redis() (opentsdb.MultiDataPoint, error) { | |
Add(&md, "redis.cmdstats_calls", cmdStatsCalls[1], tags, metadata.Counter, metadata.Operation, descRedisCmdCalls) | ||
continue | ||
} | ||
Add(&md, "redis."+sp[0], sp[1], tags, metadata.Unknown, metadata.None, "") | ||
Add(&md, "redis."+sp[0], sp[1], tags, m.RateType, m.Unit, m.Desc) | ||
} | ||
Add(&md, "redis.key_count", keys, tags, metadata.Gauge, metadata.Key, descRedisKeyCount) | ||
} | ||
|
@@ -281,7 +453,8 @@ func c_redis() (opentsdb.MultiDataPoint, error) { | |
|
||
const ( | ||
descRedisKeyCount = "The total number of keys in the instance." | ||
descRedisCmdMsecPc = "Average CPU consumed per command execution." | ||
descRedisCmdMsec = "Total CPU time consumed by commands." | ||
descRedisCmdCalls = "Number of calls." | ||
descRedisCmdMsecPc = "The average CPU consumed per command execution." | ||
descRedisCmdMsec = "The total CPU time consumed by commands." | ||
descRedisCmdCalls = "The total number of calls." | ||
descRedisIsSlave = "This indicates if the redis instance is a slave or not." | ||
) |
typo: aof_cuRrent_size