Apache Solr open-source search software
SOLR-13773: Prometheus Exporter GC and Heap options (#887)
Houston Putmanc7f84873280d
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 55c1eb50f98..8f1f90d4092 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -163,6 +163,8 @@ Improvements* SOLR-13763: Improve the tracking of "freedisk" in autoscaling simulations. (ab)+* SOLR-13773: Add Prometheus Exporter GC and Heap options. (Houston Putman via Anshum Gupta, David Smiley)+Bug Fixes----------------------diff --git a/solr/contrib/prometheus-exporter/bin/solr-exporter b/solr/contrib/prometheus-exporter/bin/solr-exporterindex ea349609ed4..9dc717ea7c8 100755--- a/solr/contrib/prometheus-exporter/bin/solr-exporter+++ b/solr/contrib/prometheus-exporter/bin/solr-exporter@@ -104,7 +104,23 @@ doCLASSPATH="$CLASSPATH":"$JAR"done-EXTRA_JVM_ARGUMENTS="-Xmx512m -Dlog4j.configurationFile=file:"$BASEDIR"/../../server/resources/log4j2-console.xml"+# Memory settings+JAVA_MEM_OPTS=+if [ -z "$JAVA_HEAP" ] && [ -n "$JAVA_MEM" ]; then+ JAVA_MEM_OPTS="$JAVA_MEM"+else+ JAVA_HEAP="${JAVA_HEAP:-512m}"+ JAVA_MEM_OPTS="-Xms$JAVA_HEAP -Xmx$JAVA_HEAP"+fi++# define default GC_TUNE+if [ -z ${GC_TUNE+x} ]; then+ GC_TUNE='-XX:+UseG1GC'+else+ GC_TUNE="$GC_TUNE"+fi++EXTRA_JVM_ARGUMENTS="-Dlog4j.configurationFile=file:"$BASEDIR"/../../server/resources/log4j2-console.xml"# For Cygwin, switch paths to Windows format before running javaif $cygwin; then@@ -115,7 +131,10 @@ if $cygwin; then[ -n "$REPO" ] && REPO=`cygpath --path --windows "$REPO"`fi-exec "$JAVACMD" $JAVA_OPTS \+exec "$JAVACMD" \+ $JAVA_MEM_OPTS \+ $GC_TUNE \+ $JAVA_OPTS \$EXTRA_JVM_ARGUMENTS \-classpath "$CLASSPATH" \-Dapp.name="solr-exporter" \diff --git a/solr/contrib/prometheus-exporter/bin/solr-exporter.cmd b/solr/contrib/prometheus-exporter/bin/solr-exporter.cmdindex 4ff47cf6d1f..e5bd65ef8a4 100644--- a/solr/contrib/prometheus-exporter/bin/solr-exporter.cmd+++ b/solr/contrib/prometheus-exporter/bin/solr-exporter.cmd@@ -63,19 +63,22 @@ set BASEDIR=%~dp0..:repoSetup+IF NOT "%JAVA_HEAP%"=="" set JAVA_MEM=-Xms%JAVA_HEAP% -Xmx%JAVA_HEAP%+IF "%JAVA_MEM%"=="" set JAVA_MEM=-Xms512m -Xmx512m+IF "%GC_TUNE%"=="" set GC_TUNE=-XX:+UseG1GCif "%JAVACMD%"=="" set JAVACMD=javaif "%REPO%"=="" set REPO=%BASEDIR%\libset CLASSPATH=%REPO%\*;%BASEDIR%\..\..\dist\solrj-lib\*;%BASEDIR%\..\..\dist\*;%BASEDIR%\lucene-libs\*;%BASEDIR%\..\..\server\solr-webapp\webapp\WEB-INF\lib\*-set EXTRA_JVM_ARGUMENTS=-Xmx512m -Dlog4j.configurationFile=file:///%BASEDIR%\..\..\server\resources\log4j2-console.xml+set EXTRA_JVM_ARGUMENTS=-Dlog4j.configurationFile=file:///%BASEDIR%\..\..\server\resources\log4j2-console.xmlgoto endInit@REM Reaching here means variables are defined and arguments have been captured:endInit-%JAVACMD% %JAVA_OPTS% %EXTRA_JVM_ARGUMENTS% -classpath "%CLASSPATH_PREFIX%;%CLASSPATH%" -Dapp.name="solr-exporter" -Dapp.repo="%REPO%" -Dbasedir="%BASEDIR%" org.apache.solr.prometheus.exporter.SolrExporter %CMD_LINE_ARGS%+%JAVACMD% %JAVA_MEM% %GC_TUNE% %JAVA_OPTS% %EXTRA_JVM_ARGUMENTS% -classpath "%CLASSPATH_PREFIX%;%CLASSPATH%" -Dapp.name="solr-exporter" -Dapp.repo="%REPO%" -Dbasedir="%BASEDIR%" org.apache.solr.prometheus.exporter.SolrExporter %CMD_LINE_ARGS%if ERRORLEVEL 1 goto errorgoto enddiff --git a/solr/solr-ref-guide/src/monitoring-solr-with-prometheus-and-grafana.adoc b/solr/solr-ref-guide/src/monitoring-solr-with-prometheus-and-grafana.adocindex 08edd1146d5..b980267b4da 100644--- a/solr/solr-ref-guide/src/monitoring-solr-with-prometheus-and-grafana.adoc+++ b/solr/solr-ref-guide/src/monitoring-solr-with-prometheus-and-grafana.adoc@@ -108,12 +108,28 @@ The number of seconds between collecting metrics from Solr. The `solr-exporter`The Solr's metrics exposed by `solr-exporter` can be seen at: `\http://localhost:9983/solr/admin/metrics`.-=== Getting metrics from a secure Solr(Cloud)+=== Environment Variable Options++The start commands provided with the Prometheus Exporter support the use of custom java options through the following environment variables:++`JAVA_HEAP`::+Sets the initial (`Xms`) and max (`Xmx`) Java heap size. The default is `512m`.++`JAVA_MEM`::+Custom java memory settings (e.g. `-Xms1g -Xmx2g`). This is ignored if `JAVA_HEAP` is provided.-Your Solr(Cloud) might be secured by measures described in <<securing-solr.adoc#securing-solr,Securing Solr>>. The security configuration can be injected into `solr-exporter` using environment variables in a fashion similar to other clients using <<using-solrj.adoc#using-solrj,SolrJ>>. This is possible because the main script picks up two external environment variables and passes them on to the Java process:+`GC_TUNE`::+Custom Java garbage collection settings. The default is `-XX:+UseG1GC`.++`JAVA_OPTS`::+Extra JVM options.++`CLASSPATH_PREFIX`::+Location of extra libraries to load when starting the `solr-exporter`.++=== Getting metrics from a secure Solr(Cloud)-* `JAVA_OPTS` allows to add extra JVM options-* `CLASSPATH_PREFIX` allows to add extra libraries+Your Solr(Cloud) might be secured by measures described in <<securing-solr.adoc#securing-solr,Securing Solr>>. The security configuration can be injected into `solr-exporter` using environment variables in a fashion similar to other clients using <<using-solrj.adoc#using-solrj,SolrJ>>. This is possible because the main script picks up <<Environment Variable Options>> and passes them on to the Java process.Example for a SolrCloud instance secured by <<basic-authentication-plugin.adoc#basic-authentication-plugin,Basic Authentication>>, <<enabling-ssl.adoc#enabling-ssl,SSL>> and <<zookeeper-access-control.adoc#zookeeper-access-control,ZooKeeper Access Control>>: