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

Conversation

matsumana
Copy link
Contributor

Hello.

With reference to #87, I added metrics the following.

Please review.

# HELP elasticsearch_indices_query_cache_cache_size Query cache cache size
# TYPE elasticsearch_indices_query_cache_cache_size gauge
elasticsearch_indices_query_cache_cache_size{cluster="test"} 28869
# HELP elasticsearch_indices_query_cache_cache_count Query cache cache count
# TYPE elasticsearch_indices_query_cache_cache_count gauge
elasticsearch_indices_query_cache_cache_count{cluster="test"} 28925
# HELP elasticsearch_indices_query_cache_total Query cache total count
# TYPE elasticsearch_indices_query_cache_total counter
elasticsearch_indices_query_cache_total{cluster="test"} 4.916801e+06
# HELP elasticsearch_indices_query_cache_count Query cache count
# TYPE elasticsearch_indices_query_cache_count counter
elasticsearch_indices_query_cache_count{category="hit",cluster="test"} 1.958521e+06
elasticsearch_indices_query_cache_count{category="miss",cluster="test"} 2.95828e+06
# HELP elasticsearch_indices_request_cache_count Request cache count
# TYPE elasticsearch_indices_request_cache_count counter
elasticsearch_indices_request_cache_count{category="hit",cluster="test"} 75749
elasticsearch_indices_request_cache_count{category="miss",cluster="test"} 65144

Copy link
Member

@zwopir zwopir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Matsumana,

thanks for you contribution. I added some comments to the code, mainly asking you to stick to the pattern we are already using. The additional type nodeMetricVec and its usage makes the code really hard to read.

defaultThreadPoolLabels = append(defaultNodeLabels, "type")
defaultBreakerLabels = append(defaultNodeLabels, "breaker")
defaultFilesystemLabels = append(defaultNodeLabels, "mount", "path")
defaultCacheCategoryLabels = append(defaultNodeLabels, "category")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a don't think "category" describes the label correctly. I would then prefer "cache"

defaultFilesystemLabels = append(defaultNodeLabels, "mount", "path")
defaultCacheCategoryLabels = append(defaultNodeLabels, "category")
defaultCacheHitLabels = append(defaultNodeLabels, "hit")
defaultCacheMissLabels = append(defaultNodeLabels, "miss")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"hit" and "miss" are the labelvalues for defaultCacheCategoryLabels, not labels. So it really confuses the code reader if they appear in a slice together with labels

LabelValues func(cluster string, node NodeStatsNodeResponse) [][]string
Values func(node NodeStatsNodeResponse) []float64
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a reason adding a new type for metrics. The type nodeMetric already covers the usecase. Please use it. It is also pretty unclear what the dimensions of LabelValues func(...) [][]string represent. Same for Values func(...) []float64. A metric label can't be a slice

values := metric.Values(node)

for i, labelValue := range labelValues {
counterVec := prometheus.NewCounterVec(prometheus.CounterOpts{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NewCounterVec must not be called in the Collect func implementing prometheus.Collector. Throughout the collector we are using the pattern to create a new const metric. (prometheus.MustNewConstMetric). It perfectly fits to our use case.

counterVec.WithLabelValues(labelValue...).Set(values[i])
counterVec.Collect(ch)
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this metric returns false results regarding the labels: on our cluster we get:

# TYPE elasticsearch_indices_query_cache_count counter
elasticsearch_indices_query_cache_count{category="hit",cluster="cluster",host="host",name="name"} 3.1548049e+07
elasticsearch_indices_query_cache_count{category="miss",cluster="cluster",host="host",name="name"} 4.9529376e+07

(the label values for host and name are not (!) redacted)

@matsumana
Copy link
Contributor Author

@zwopir Thank you for the comments.
I fixed.
Would you please review again?

@zwopir
Copy link
Member

zwopir commented Sep 6, 2017

yes, that looks good - Thanks again for your contribution!

@zwopir zwopir merged commit b81f753 into prometheus-community:master Sep 6, 2017
@matsumana matsumana deleted the feature/add-cache-metrics branch September 7, 2017 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants