-
Notifications
You must be signed in to change notification settings - Fork 74
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 cache stats as Prometheus metrics #75
Open
Baliedge
wants to merge
43
commits into
master
Choose a base branch
from
Baliedge/promexporter
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+991
−44
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Danny Kopping <[email protected]>
There are a few forks of groupcache now, so instead use an interface for the stats Signed-off-by: Danny Kopping <[email protected]>
Signed-off-by: Danny Kopping <[email protected]>
…ese can be configured on the registerer Signed-off-by: Danny Kopping <[email protected]>
Signed-off-by: Danny Kopping <[email protected]>
…erge-with-groupcache' into Baliedge/promexporter
Baliedge
force-pushed
the
Baliedge/promexporter
branch
from
December 24, 2024 18:45
ea4a718
to
c219d7c
Compare
I would say it's stable already, there were a lot of minor updates - https://go.dev/doc/devel/release#go1.23.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Based off of: https://github.com/udhos/groupcache_exporter by @udhos.
Synopsis
The groupcache_exporter repo contains a great solution for exporting groupcache statistics as Prometheus metrics. But, this requires Golang 1.23 to satisfy support for multiple implementations of groupcache. The Mailgun groupcache implementation does not have this requirement and prefers to stay on stable Golang 1.22.
Features
Usage
The exporter need only be configured once in your application. Registering the exporter again (with the same namespace) will create a metric name collision in Prometheus. All groupcache groups will be exported automatically, even those created after setting up the exporter.
Example:
Optionally pass one or more variadic arguments to
NewExporter()
:promexporter.WithNamespace("prefix")
: Add<namespace>_
prefix to all metric names.promexporter.WithLabels(labels)
: Add static labels to exported metrics.promexporter.WithGroups(fn)
: Set callback function to dynamically retrieve groupcache groups to export. Overrides default that discovers all groups.Metrics
Exported from groupcache's
CacheStats()
groupcache_cache_bytes{group,type="main|hot"}
: Gauge of current bytes in usegroupcache_cache_evictions_nonexpired_total{group,type="main|hot"}
: Count of cache evictions for non-expired keys due to memory fullgroupcache_cache_evictions_total{group,type="main|hot"}
: Count of cache evictionsgroupcache_cache_gets_total{group,type="main|hot"}
: Count of cache getsgroupcache_cache_hits_total{group,type="main|hot"}
: Count of cache hitsgroupcache_cache_items{group,type="main|hot"}
: Gauge of current items in useExported from groupcache's
Stats()
groupcache_get_from_peers_latency_lower{group}
: Represent slowest duration to request value from peersgroupcache_gets_total{group}
: Count of cache gets (including from peers, from either main or hot caches)groupcache_hits_total{group}
: Count of cache hits (from either main or hot caches)groupcache_loads_deduped_total{group}
: Count of loads after singleflightgroupcache_loads_total{group}
: Count of (gets - hits)groupcache_local_load_errs_total{group}
: Count of loads from local cache that failedgroupcache_local_loads_total{group}
: Count of loads from local cachegroupcache_peer_errors_total{group}
: Count of errors from peersgroupcache_peer_loads_total{group}
: Count of non-error loads or cache hits from peersgroupcache_server_requests_total{group}
: Count of gets that came over the network from peersChanges to Metrics from udhos Source
groupcache_get_from_peers_latency_slowest_milliseconds
->groupcache_get_from_peers_latency_lower
groupcache_local_load_total
->groupcache_local_loads_total