-
Notifications
You must be signed in to change notification settings - Fork 674
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
SOLR-10654: Introduce output of Prometheus metrics directly from Solr #2405
Merged
Merged
Changes from 29 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
3c3095a
Init commit for dropwizard to prometheus
b38b55b
Expose Prometheus Metrics directly from Solr from Core registry
8eb18f7
Incorrect check on counter instead of gauge
f531e49
Keep continuity in parameter orderings
d594f50
gradle tidy
59cc9b4
Write javadocs for new classes
bc6a60a
Refactor out prometheus registry to Prometheus metric snapshots
a57ffb4
Update dependencies
58fb18d
Add MetricsHandler prometheus test
680a0a3
Add new methods of creating and collecting datapoints
e4c5053
Add tests for SolrPrometheusExporter
a802716
Add test for Prometheus Response Writer
a57e107
Remove fobidden api usages
c40dda3
Check against different metric for test
0aa1b55
Broken precommit
88e6347
Remove transitive dependencies
5d399ef
Refactor based on review comments
58280e5
2nd round refactor from review comments
b8475f8
Simplified loop and var names
acde988
Export jetty/jvm/node registry metrics
060bb59
Update broken tests
7359d7c
Update ref-guide with Prometheus metrics endpoint
835c946
Change test assertion for metrics affected by testing environment
6cce972
Add additional java docs and integration test
bceb4fe
Change integration test to use SolrJettyTestRule
f1b410a
Update solr/solr-ref-guide/modules/deployment-guide/pages/monitoring-…
mlbiscoc a9ee37f
Manually register metrics not initializing from JettyTestRule
1949b5b
Merge branch 'refs/heads/main' into fork/mlbiscoc/SOLR-10654-promethe…
dsmiley 1d7b65a
Changes from review for refactor and tests
d6786ec
Add additional documentation to ref-guide
mlbiscoc d6bd407
Remove some JVM tests
mlbiscoc 9f1abbe
Add entry into CHANGES.txt
mlbiscoc 5da678c
Add names to CHANGES.txt
mlbiscoc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
57 changes: 57 additions & 0 deletions
57
solr/core/src/java/org/apache/solr/metrics/prometheus/SolrMetric.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.solr.metrics.prometheus; | ||
|
||
import com.codahale.metrics.Metric; | ||
import io.prometheus.metrics.model.snapshots.Labels; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Base class is a wrapper to categorize and export {@link com.codahale.metrics.Metric} to {@link | ||
* io.prometheus.metrics.model.snapshots.DataPointSnapshot} and register to a {@link | ||
* SolrPrometheusExporter}. {@link com.codahale.metrics.MetricRegistry} does not support tags unlike | ||
* prometheus. Metrics registered to the registry need to be parsed out from the metric name to be | ||
* exported to {@link io.prometheus.metrics.model.snapshots.DataPointSnapshot} | ||
*/ | ||
public abstract class SolrMetric { | ||
public Metric dropwizardMetric; | ||
public String metricName; | ||
public Map<String, String> labels = new HashMap<>(); | ||
|
||
public SolrMetric() {} | ||
|
||
public SolrMetric(Metric dropwizardMetric, String metricName) { | ||
this.dropwizardMetric = dropwizardMetric; | ||
this.metricName = metricName; | ||
} | ||
|
||
/* | ||
* Parse labels from the Dropwizard Metric name to be exported | ||
*/ | ||
public abstract SolrMetric parseLabels(); | ||
|
||
/* | ||
* Export metric to Prometheus with labels | ||
*/ | ||
public abstract void toPrometheus(SolrPrometheusExporter exporter); | ||
|
||
public Labels getLabels() { | ||
return Labels.of(new ArrayList<>(labels.keySet()), new ArrayList<>(labels.values())); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
solr/core/src/java/org/apache/solr/metrics/prometheus/SolrNoOpMetric.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.solr.metrics.prometheus; | ||
|
||
public class SolrNoOpMetric extends SolrMetric { | ||
public SolrNoOpMetric() {} | ||
|
||
@Override | ||
public SolrMetric parseLabels() { | ||
return this; | ||
} | ||
|
||
@Override | ||
public void toPrometheus(SolrPrometheusExporter exporter) {} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
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 is so special-purpose that I think it doesn't belong here. Can we get away with not registering it?
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.
Could not figure out a way to do with without registering it. Is there some example somewhere where a response writer exists without registering the class?
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.
Nevermind. We even have schema xml format, another special purpose one. Maybe some day this could be improved.
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.
I filed https://issues.apache.org/jira/browse/SOLR-17354 for improving this matter.