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

add cache metrics #88

Merged
Merged
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
91 changes: 91 additions & 0 deletions collector/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var (
defaultThreadPoolLabels = append(defaultNodeLabels, "type")
defaultBreakerLabels = append(defaultNodeLabels, "breaker")
defaultFilesystemLabels = append(defaultNodeLabels, "mount", "path")
defaultCacheLabels = append(defaultNodeLabels, "cache")

defaultNodeLabelValues = func(cluster string, node NodeStatsNodeResponse) []string {
return []string{cluster, node.Host, node.Name}
Expand All @@ -26,6 +27,12 @@ var (
defaultFilesystemLabelValues = func(cluster string, node NodeStatsNodeResponse, mount string, path string) []string {
return append(defaultNodeLabelValues(cluster, node), mount, path)
}
defaultCacheHitLabelValues = func(cluster string, node NodeStatsNodeResponse) []string {
return append(defaultNodeLabelValues(cluster, node), "hit")
}
defaultCacheMissLabelValues = func(cluster string, node NodeStatsNodeResponse) []string {
return append(defaultNodeLabelValues(cluster, node), "miss")
}
)

type nodeMetric struct {
Expand Down Expand Up @@ -172,6 +179,66 @@ func NewNodes(logger log.Logger, client *http.Client, url *url.URL, all bool) *N
},
Labels: defaultNodeLabelValues,
},
{
Type: prometheus.CounterValue,
Desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "indices", "query_cache_total"),
"Query cache total count",
defaultNodeLabels, nil,
),
Value: func(node NodeStatsNodeResponse) float64 {
return float64(node.Indices.QueryCache.TotalCount)
},
Labels: defaultNodeLabelValues,
},
{
Type: prometheus.GaugeValue,
Desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "indices", "query_cache_cache_size"),
"Query cache cache size",
defaultNodeLabels, nil,
),
Value: func(node NodeStatsNodeResponse) float64 {
return float64(node.Indices.QueryCache.CacheSize)
},
Labels: defaultNodeLabelValues,
},
{
Type: prometheus.GaugeValue,
Desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "indices", "query_cache_cache_count"),
"Query cache cache count",
defaultNodeLabels, nil,
),
Value: func(node NodeStatsNodeResponse) float64 {
return float64(node.Indices.QueryCache.CacheCount)
},
Labels: defaultNodeLabelValues,
},
{
Type: prometheus.CounterValue,
Desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "indices", "query_cache_count"),
"Query cache count",
defaultCacheLabels, nil,
),
Value: func(node NodeStatsNodeResponse) float64 {
return float64(node.Indices.QueryCache.HitCount)
},
Labels: defaultCacheHitLabelValues,
},
{
Type: prometheus.CounterValue,
Desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "indices", "query_cache_count"),
"Query cache count",
defaultCacheLabels, nil,
),
Value: func(node NodeStatsNodeResponse) float64 {
return float64(node.Indices.QueryCache.MissCount)
},
Labels: defaultCacheMissLabelValues,
},
{
Type: prometheus.GaugeValue,
Desc: prometheus.NewDesc(
Expand All @@ -196,6 +263,30 @@ func NewNodes(logger log.Logger, client *http.Client, url *url.URL, all bool) *N
},
Labels: defaultNodeLabelValues,
},
{
Type: prometheus.CounterValue,
Desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "indices", "request_cache_count"),
"Request cache count",
defaultCacheLabels, nil,
),
Value: func(node NodeStatsNodeResponse) float64 {
return float64(node.Indices.RequestCache.HitCount)
},
Labels: defaultCacheHitLabelValues,
},
{
Type: prometheus.CounterValue,
Desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "indices", "request_cache_count"),
"Request cache count",
defaultCacheLabels, nil,
),
Value: func(node NodeStatsNodeResponse) float64 {
return float64(node.Indices.RequestCache.MissCount)
},
Labels: defaultCacheMissLabelValues,
},
{
Type: prometheus.CounterValue,
Desc: prometheus.NewDesc(
Expand Down