Skip to content

Commit

Permalink
feat: gather additional stats from memcached (#10641)
Browse files Browse the repository at this point in the history
  • Loading branch information
LINKIWI authored Feb 15, 2022
1 parent 2d458ac commit fe299d9
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 27 deletions.
9 changes: 8 additions & 1 deletion plugins/inputs/memcached/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ Fields:
* decr_misses - Number of decr reqs against missing keys
* delete_hits - Number of deletion reqs resulting in an item being removed
* delete_misses - umber of deletions reqs for missing keys
* evicted_active - Items evicted from LRU that had been hit recently but did not jump to top of LRU
* evicted_unfetched - Items evicted from LRU that were never touched by get/incr/append/etc
* evictions - Number of valid items removed from cache to free memory for new items
* expired_unfetched - Items pulled from LRU that were never touched by get/incr/append/etc before expiring
* get_expired - Number of items that have been requested but had already expired
* get_flushed - Number of items that have been requested but have been flushed via flush_all
* get_hits - Number of keys that have been requested and found present
* get_misses - Number of items that have been requested and not found
* hash_bytes - Bytes currently used by hash tables
Expand All @@ -53,7 +56,11 @@ Fields:
* incr_misses - Number of incr reqs against missing keys
* limit_maxbytes - Number of bytes this server is allowed to use for storage
* listen_disabled_num - Number of times server has stopped accepting new connections (maxconns)
* max_connections - Max number of simultaneous connections
* reclaimed - Number of times an entry was stored using memory from an expired entry
* rejected_connections - Conns rejected in maxconns_fast mode
* store_no_memory - Number of rejected storage requests caused by exhaustion of the memory limit when evictions are disabled
* store_too_large - Number of rejected storage requests caused by attempting to write a value larger than the item size limit
* threads - Number of worker threads requested
* total_connections - Total number of connections opened since the server started running
* total_items - Total number of items stored since the server started
Expand All @@ -80,5 +87,5 @@ SELECT mean(get_hits) / mean(cmd_get) as get_ratio, mean(get_misses) / mean(cmd_

```shell
$ ./telegraf --config telegraf.conf --input-filter memcached --test
memcached,server=localhost:11211 get_hits=1,get_misses=2,evictions=0,limit_maxbytes=0,bytes=10,uptime=3600,curr_items=2,total_items=2,curr_connections=1,total_connections=2,connection_structures=1,cmd_get=2,cmd_set=1,delete_hits=0,delete_misses=0,incr_hits=0,incr_misses=0,decr_hits=0,decr_misses=0,cas_hits=0,cas_misses=0,bytes_read=10,bytes_written=10,threads=1,conn_yields=0 1453831884664956455
memcached,server=localhost:11211 accepting_conns=1i,auth_cmds=0i,auth_errors=0i,bytes=0i,bytes_read=7i,bytes_written=0i,cas_badval=0i,cas_hits=0i,cas_misses=0i,cmd_flush=0i,cmd_get=0i,cmd_set=0i,cmd_touch=0i,conn_yields=0i,connection_structures=3i,curr_connections=2i,curr_items=0i,decr_hits=0i,decr_misses=0i,delete_hits=0i,delete_misses=0i,evicted_active=0i,evicted_unfetched=0i,evictions=0i,expired_unfetched=0i,get_expired=0i,get_flushed=0i,get_hits=0i,get_misses=0i,hash_bytes=524288i,hash_is_expanding=0i,hash_power_level=16i,incr_hits=0i,incr_misses=0i,limit_maxbytes=67108864i,listen_disabled_num=0i,max_connections=1024i,reclaimed=0i,rejected_connections=0i,store_no_memory=0i,store_too_large=0i,threads=4i,total_connections=3i,total_items=0i,touch_hits=0i,touch_misses=0i,uptime=3i 1644771989000000000
```
7 changes: 7 additions & 0 deletions plugins/inputs/memcached/memcached.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ var sendMetrics = []string{
"decr_misses",
"delete_hits",
"delete_misses",
"evicted_active",
"evicted_unfetched",
"evictions",
"expired_unfetched",
"get_expired",
"get_flushed",
"get_hits",
"get_misses",
"hash_bytes",
Expand All @@ -62,7 +65,11 @@ var sendMetrics = []string{
"incr_misses",
"limit_maxbytes",
"listen_disabled_num",
"max_connections",
"reclaimed",
"rejected_connections",
"store_no_memory",
"store_too_large",
"threads",
"total_connections",
"total_items",
Expand Down
140 changes: 114 additions & 26 deletions plugins/inputs/memcached/memcached_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,36 @@ func TestMemcachedParseMetrics(t *testing.T) {
key string
value string
}{
{"pid", "23235"},
{"uptime", "194"},
{"time", "1449174679"},
{"version", "1.4.14 (Ubuntu)"},
{"libevent", "2.0.21-stable"},
{"pid", "5619"},
{"uptime", "11"},
{"time", "1644765868"},
{"version", "1.6.14_5_ge03751b"},
{"libevent", "2.1.11-stable"},
{"pointer_size", "64"},
{"rusage_user", "0.000000"},
{"rusage_system", "0.007566"},
{"curr_connections", "5"},
{"total_connections", "6"},
{"connection_structures", "6"},
{"rusage_user", "0.080905"},
{"rusage_system", "0.059330"},
{"max_connections", "1024"},
{"curr_connections", "2"},
{"total_connections", "3"},
{"rejected_connections", "0"},
{"connection_structures", "3"},
{"response_obj_oom", "0"},
{"response_obj_count", "1"},
{"response_obj_bytes", "16384"},
{"read_buf_count", "2"},
{"read_buf_bytes", "32768"},
{"read_buf_bytes_free", "0"},
{"read_buf_oom", "0"},
{"reserved_fds", "20"},
{"cmd_get", "0"},
{"cmd_set", "0"},
{"cmd_flush", "0"},
{"cmd_touch", "0"},
{"cmd_meta", "0"},
{"get_hits", "0"},
{"get_misses", "0"},
{"get_expired", "0"},
{"get_flushed", "0"},
{"delete_misses", "0"},
{"delete_hits", "0"},
{"incr_misses", "0"},
Expand All @@ -74,25 +86,57 @@ func TestMemcachedParseMetrics(t *testing.T) {
{"cas_badval", "0"},
{"touch_hits", "0"},
{"touch_misses", "0"},
{"store_too_large", "0"},
{"store_no_memory", "0"},
{"auth_cmds", "0"},
{"auth_errors", "0"},
{"bytes_read", "7"},
{"bytes_read", "6"},
{"bytes_written", "0"},
{"limit_maxbytes", "67108864"},
{"accepting_conns", "1"},
{"listen_disabled_num", "0"},
{"time_in_listen_disabled_us", "0"},
{"threads", "4"},
{"conn_yields", "0"},
{"hash_power_level", "16"},
{"hash_bytes", "524288"},
{"hash_is_expanding", "0"},
{"expired_unfetched", "0"},
{"evicted_unfetched", "0"},
{"slab_reassign_rescues", "0"},
{"slab_reassign_chunk_rescues", "0"},
{"slab_reassign_evictions_nomem", "0"},
{"slab_reassign_inline_reclaim", "0"},
{"slab_reassign_busy_items", "0"},
{"slab_reassign_busy_deletes", "0"},
{"slab_reassign_running", "0"},
{"slabs_moved", "0"},
{"lru_crawler_running", "0"},
{"lru_crawler_starts", "1"},
{"lru_maintainer_juggles", "60"},
{"malloc_fails", "0"},
{"log_worker_dropped", "0"},
{"log_worker_written", "0"},
{"log_watcher_skipped", "0"},
{"log_watcher_sent", "0"},
{"log_watchers", "0"},
{"unexpected_napi_ids", "0"},
{"round_robin_fallback", "0"},
{"bytes", "0"},
{"curr_items", "0"},
{"total_items", "0"},
{"slab_global_page_pool", "0"},
{"expired_unfetched", "0"},
{"evicted_unfetched", "0"},
{"evicted_active", "0"},
{"evictions", "0"},
{"reclaimed", "0"},
{"crawler_reclaimed", "0"},
{"crawler_items_checked", "0"},
{"lrutail_reflocked", "0"},
{"moves_to_cold", "0"},
{"moves_to_warm", "0"},
{"moves_within_lru", "0"},
{"direct_reclaims", "0"},
{"lru_bumps_dropped", "0"},
}

for _, test := range tests {
Expand All @@ -108,24 +152,36 @@ func TestMemcachedParseMetrics(t *testing.T) {
}
}

var memcachedStats = `STAT pid 23235
STAT uptime 194
STAT time 1449174679
STAT version 1.4.14 (Ubuntu)
STAT libevent 2.0.21-stable
var memcachedStats = `STAT pid 5619
STAT uptime 11
STAT time 1644765868
STAT version 1.6.14_5_ge03751b
STAT libevent 2.1.11-stable
STAT pointer_size 64
STAT rusage_user 0.000000
STAT rusage_system 0.007566
STAT curr_connections 5
STAT total_connections 6
STAT connection_structures 6
STAT rusage_user 0.080905
STAT rusage_system 0.059330
STAT max_connections 1024
STAT curr_connections 2
STAT total_connections 3
STAT rejected_connections 0
STAT connection_structures 3
STAT response_obj_oom 0
STAT response_obj_count 1
STAT response_obj_bytes 16384
STAT read_buf_count 2
STAT read_buf_bytes 32768
STAT read_buf_bytes_free 0
STAT read_buf_oom 0
STAT reserved_fds 20
STAT cmd_get 0
STAT cmd_set 0
STAT cmd_flush 0
STAT cmd_touch 0
STAT cmd_meta 0
STAT get_hits 0
STAT get_misses 0
STAT get_expired 0
STAT get_flushed 0
STAT delete_misses 0
STAT delete_hits 0
STAT incr_misses 0
Expand All @@ -137,24 +193,56 @@ STAT cas_hits 0
STAT cas_badval 0
STAT touch_hits 0
STAT touch_misses 0
STAT store_too_large 0
STAT store_no_memory 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 7
STAT bytes_read 6
STAT bytes_written 0
STAT limit_maxbytes 67108864
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT time_in_listen_disabled_us 0
STAT threads 4
STAT conn_yields 0
STAT hash_power_level 16
STAT hash_bytes 524288
STAT hash_is_expanding 0
STAT expired_unfetched 0
STAT evicted_unfetched 0
STAT slab_reassign_rescues 0
STAT slab_reassign_chunk_rescues 0
STAT slab_reassign_evictions_nomem 0
STAT slab_reassign_inline_reclaim 0
STAT slab_reassign_busy_items 0
STAT slab_reassign_busy_deletes 0
STAT slab_reassign_running 0
STAT slabs_moved 0
STAT lru_crawler_running 0
STAT lru_crawler_starts 1
STAT lru_maintainer_juggles 60
STAT malloc_fails 0
STAT log_worker_dropped 0
STAT log_worker_written 0
STAT log_watcher_skipped 0
STAT log_watcher_sent 0
STAT log_watchers 0
STAT unexpected_napi_ids 0
STAT round_robin_fallback 0
STAT bytes 0
STAT curr_items 0
STAT total_items 0
STAT slab_global_page_pool 0
STAT expired_unfetched 0
STAT evicted_unfetched 0
STAT evicted_active 0
STAT evictions 0
STAT reclaimed 0
STAT crawler_reclaimed 0
STAT crawler_items_checked 0
STAT lrutail_reflocked 0
STAT moves_to_cold 0
STAT moves_to_warm 0
STAT moves_within_lru 0
STAT direct_reclaims 0
STAT lru_bumps_dropped 0
END
`

0 comments on commit fe299d9

Please sign in to comment.