-
Notifications
You must be signed in to change notification settings - Fork 738
SOLR-17797: add prometheus formatter support for segment merge metrics #3407
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,32 +16,92 @@ | |
*/ | ||
package org.apache.solr.metrics.prometheus.core; | ||
|
||
import com.codahale.metrics.Gauge; | ||
import com.codahale.metrics.Metric; | ||
import com.codahale.metrics.*; | ||
import org.apache.solr.metrics.prometheus.SolrPrometheusFormatter; | ||
|
||
/** Dropwizard metrics of name INDEX.* */ | ||
public class SolrCoreIndexMetric extends SolrCoreMetric { | ||
public static final String CORE_INDEX_METRICS = "solr_metrics_core_index_size_bytes"; | ||
|
||
public static final String CORE_INDEX_FLUSH_METRICS = "solr_metrics_core_index_flush"; | ||
public static final String CORE_INDEX_MERGE_ERRORS_METRICS = "solr_metrics_core_index_merge_errors"; | ||
|
||
public static final String CORE_INDEX_MERGE_METRICS = "solr_metrics_core_index_merges"; | ||
|
||
// these are only for major merges with more details enabled | ||
public static final String CORE_INDEX_MERGE_DOCS_METRICS = "solr_metrics_core_index_merged_docs"; | ||
public static final String CORE_INDEX_MERGE_DELETED_DOCS_METRICS = "solr_metrics_core_index_merged_deleted_docs"; | ||
|
||
public static final String CORE_INDEX_MERGING_METRICS = "solr_metrics_core_index_merges_running"; | ||
public static final String CORE_INDEX_MERGING_DOCS_METRICS = "solr_metrics_core_index_merging_docs"; | ||
public static final String CORE_INDEX_MERGING_SEGMENTS_METRICS = "solr_metrics_core_index_merging_segments"; | ||
|
||
public SolrCoreIndexMetric(Metric dropwizardMetric, String metricName) { | ||
super(dropwizardMetric, metricName); | ||
} | ||
|
||
/* | ||
* Metric examples being exported | ||
* INDEX.sizeInBytes | ||
* | ||
* INDEX.merge.errors | ||
* INDEX.merge.minor | ||
* INDEX.merge.minor.running | ||
* INDEX.merge.minor.running.docs | ||
* INDEX.merge.minor.running.segments | ||
* INDEX.merge.major | ||
* INDEX.merge.major.docs | ||
* INDEX.merge.major.deletedDocs | ||
* INDEX.merge.major.running | ||
* INDEX.merge.major.running.docs | ||
* INDEX.merge.major.running.segments | ||
Comment on lines
+47
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You shouldn't need to comment every metric here you export. Just a few should be fine. Might also be worth mentioning in the comment that these must be enabled |
||
*/ | ||
|
||
@Override | ||
public SolrCoreMetric parseLabels() { | ||
String[] parsedMetric = metricName.split("\\."); | ||
if (parsedMetric.length < 3) { | ||
return this; | ||
} | ||
if (parsedMetric[1].equals("merge")) { | ||
labels.put("type", parsedMetric[2]); // minor / major | ||
if (parsedMetric.length > 3) { | ||
labels.put("running", "true"); | ||
} else { | ||
labels.put("running", "false"); | ||
} | ||
} | ||
return this; | ||
} | ||
|
||
@Override | ||
public void toPrometheus(SolrPrometheusFormatter formatter) { | ||
if (metricName.endsWith("sizeInBytes")) { | ||
formatter.exportGauge(CORE_INDEX_METRICS, (Gauge<?>) dropwizardMetric, getLabels()); | ||
if (dropwizardMetric instanceof Gauge) { | ||
if (metricName.endsWith("sizeInBytes")) { | ||
formatter.exportGauge(CORE_INDEX_METRICS, (Gauge<?>) dropwizardMetric, getLabels()); | ||
} else if (metricName.endsWith("running")) { | ||
formatter.exportGauge(CORE_INDEX_MERGING_METRICS, (Gauge<?>) dropwizardMetric, getLabels()); | ||
} else if (metricName.endsWith("segments")) { | ||
formatter.exportGauge(CORE_INDEX_MERGING_SEGMENTS_METRICS, (Gauge<?>) dropwizardMetric, getLabels()); | ||
} else if (metricName.endsWith("docs")) { | ||
formatter.exportGauge(CORE_INDEX_MERGING_DOCS_METRICS, (Gauge<?>) dropwizardMetric, getLabels()); | ||
Comment on lines
+80
to
+87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at these metrics myself, these are very confusing:
They have
It has no label for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the last two are |
||
} | ||
} else if (dropwizardMetric instanceof Timer) { | ||
if (metricName.endsWith("minor") || metricName.endsWith("major")) { | ||
formatter.exportTimer(CORE_INDEX_MERGE_METRICS, (Timer) dropwizardMetric, getLabels()); | ||
} | ||
} else if (dropwizardMetric instanceof Counter) { | ||
if (metricName.endsWith("errors")) { | ||
formatter.exportCounter(CORE_INDEX_MERGE_ERRORS_METRICS, (Counter) dropwizardMetric, getLabels()); | ||
} | ||
} else if (dropwizardMetric instanceof Meter) { | ||
if (metricName.endsWith("flush")) { | ||
formatter.exportMeter(CORE_INDEX_FLUSH_METRICS, (Meter) dropwizardMetric, getLabels()); | ||
} else if (metricName.endsWith("docs")) { | ||
formatter.exportMeter(CORE_INDEX_MERGE_DOCS_METRICS, (Meter) dropwizardMetric, getLabels()); | ||
} else if (metricName.endsWith("deletedDocs")) { | ||
formatter.exportMeter(CORE_INDEX_MERGE_DELETED_DOCS_METRICS, (Meter) dropwizardMetric, getLabels()); | ||
Comment on lines
+98
to
+103
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can these be merged together? One single metric name with labels operation |
||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This metric name seems wrong. It's a timer but nothing in this name explains its a timer. Name should be something like
solr_core_index_merge_time_ms
.I actually think the times are ns but this PR fixes up some of the timer implementation to get the quantiles out from this metric and gives a better understanding of the unit being used by converting to ms. I'd like to get that merged in as well so this can pick up the quantiles.