Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export direct_reclaims_total metric to prometheus #227

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ The exporter collects a number of statistics from the server:
# TYPE memcached_current_connections gauge
# HELP memcached_current_items Current number of items stored by this instance.
# TYPE memcached_current_items gauge
# HELP memcached_direct_reclaims_total Times worker threads had to directly reclaim or evict items.
# TYPE memcached_direct_reclaims_total counter
# HELP memcached_items_evicted_total Total number of valid items removed from cache to free memory for new items.
# TYPE memcached_items_evicted_total counter
# HELP memcached_items_reclaimed_total Total number of times an entry was stored using memory from an expired entry.
Expand Down
9 changes: 9 additions & 0 deletions pkg/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ type Exporter struct {
lruCrawlerMovesToCold *prometheus.Desc
lruCrawlerMovesToWarm *prometheus.Desc
lruCrawlerMovesWithinLru *prometheus.Desc
directReclaims *prometheus.Desc
malloced *prometheus.Desc
itemsNumber *prometheus.Desc
itemsAge *prometheus.Desc
Expand Down Expand Up @@ -276,6 +277,12 @@ func New(server string, timeout time.Duration, logger *slog.Logger, tlsConfig *t
nil,
nil,
),
directReclaims: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "", "direct_reclaims_total"),
"Times worker threads had to directly reclaim or evict items.",
nil,
nil,
),
lruCrawlerEnabled: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystemLruCrawler, "enabled"),
"Whether the LRU crawler is enabled.",
Expand Down Expand Up @@ -704,6 +711,7 @@ func (e *Exporter) Describe(ch chan<- *prometheus.Desc) {
ch <- e.lruHotMaxAgeFactor
ch <- e.lruWarmMaxAgeFactor
ch <- e.lruCrawlerStarts
ch <- e.directReclaims
ch <- e.lruCrawlerReclaimed
ch <- e.lruCrawlerItemsChecked
ch <- e.lruCrawlerMovesToCold
Expand Down Expand Up @@ -912,6 +920,7 @@ func (e *Exporter) parseStats(ch chan<- prometheus.Metric, stats map[net.Addr]me
e.parseAndNewMetric(ch, e.itemStoreTooLarge, prometheus.CounterValue, s, "store_too_large"),
e.parseAndNewMetric(ch, e.itemStoreNoMemory, prometheus.CounterValue, s, "store_no_memory"),
e.parseAndNewMetric(ch, e.lruCrawlerStarts, prometheus.CounterValue, s, "lru_crawler_starts"),
e.parseAndNewMetric(ch, e.directReclaims, prometheus.CounterValue, s, "direct_reclaims"),
e.parseAndNewMetric(ch, e.lruCrawlerItemsChecked, prometheus.CounterValue, s, "crawler_items_checked"),
e.parseAndNewMetric(ch, e.lruCrawlerReclaimed, prometheus.CounterValue, s, "crawler_reclaimed"),
e.parseAndNewMetric(ch, e.lruCrawlerMovesToCold, prometheus.CounterValue, s, "moves_to_cold"),
Expand Down