You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by an...@apache.org on 2019/09/18 20:40:52 UTC
[lucene-solr] branch branch_8x updated: SOLR-13773: Prometheus
Exporter GC and Heap options (#887) (#890)
This is an automated email from the ASF dual-hosted git repository.
anshum pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/branch_8x by this push:
new b9633e0 SOLR-13773: Prometheus Exporter GC and Heap options (#887) (#890)
b9633e0 is described below
commit b9633e0f26052155a18fcbdd08b7fa3a30a88e37
Author: Anshum Gupta <an...@apache.org>
AuthorDate: Wed Sep 18 13:40:46 2019 -0700
SOLR-13773: Prometheus Exporter GC and Heap options (#887) (#890)
* SOLR-13773: Prometheus Exporter GC and Heap options
* Adding info to the ref-guide.
---
solr/CHANGES.txt | 2 ++
solr/contrib/prometheus-exporter/bin/solr-exporter | 23 +++++++++++++++++++--
.../prometheus-exporter/bin/solr-exporter.cmd | 7 +++++--
...onitoring-solr-with-prometheus-and-grafana.adoc | 24 ++++++++++++++++++----
4 files changed, 48 insertions(+), 8 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 50e686f..76d217e 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -106,6 +106,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-exporter
index ea34960..9dc717e 100755
--- a/solr/contrib/prometheus-exporter/bin/solr-exporter
+++ b/solr/contrib/prometheus-exporter/bin/solr-exporter
@@ -104,7 +104,23 @@ do
CLASSPATH="$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 java
if $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.cmd
index 4ff47cf..e5bd65e 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:+UseG1GC
if "%JAVACMD%"=="" set JAVACMD=java
if "%REPO%"=="" set REPO=%BASEDIR%\lib
set 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.xml
goto 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 error
goto end
diff --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.adoc
index 08edd11..b980267 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>>: