You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ko...@apache.org on 2018/03/02 02:52:16 UTC

[8/8] lucene-solr:branch_7x-SOLR-11795: SOLR-11795: Add Solr metrics exporter for Prometheus

SOLR-11795: Add Solr metrics exporter for Prometheus


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/961269aa
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/961269aa
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/961269aa

Branch: refs/heads/branch_7x-SOLR-11795
Commit: 961269aa5d0feef86cac9b4a94c2268de9f498f6
Parents: e2b3a97
Author: koji <ko...@apache.org>
Authored: Fri Mar 2 11:18:10 2018 +0900
Committer: koji <ko...@apache.org>
Committed: Fri Mar 2 11:25:09 2018 +0900

----------------------------------------------------------------------
 dev-tools/idea/.idea/ant.xml                    |    1 +
 .../Solr_prometheus_exporter_library.xml        |   10 +
 dev-tools/idea/.idea/modules.xml                |    1 +
 dev-tools/idea/.idea/workspace.xml              |   13 +-
 .../prometheus-exporter/prometheus-exporter.iml |   37 +
 dev-tools/maven/solr/contrib/pom.xml.template   |    1 +
 .../prometheus-exporter/pom.xml.template        |   80 +
 lucene/ivy-versions.properties                  |   14 +-
 solr/CHANGES.txt                                |    2 +
 solr/build.xml                                  |    6 +-
 solr/contrib/prometheus-exporter/README.md      |   21 +
 solr/contrib/prometheus-exporter/README.txt     |    1 +
 .../prometheus-exporter/bin/solr-exporter       |  122 +
 .../prometheus-exporter/bin/solr-exporter.cmd   |  104 +
 solr/contrib/prometheus-exporter/build.xml      |   64 +
 .../conf/grafana-solr-dashboard.json            | 4465 ++++++++++++++++++
 .../prometheus-exporter/conf/log4j.properties   |   22 +
 .../conf/solr-exporter-config.xml               | 1806 +++++++
 solr/contrib/prometheus-exporter/ivy.xml        |   40 +
 .../prometheus/collector/SolrCollector.java     |  463 ++
 .../solr/prometheus/collector/package-info.java |   21 +
 .../solr/prometheus/exporter/SolrExporter.java  |  254 +
 .../solr/prometheus/exporter/package-info.java  |   21 +
 .../solr/prometheus/scraper/SolrScraper.java    |  214 +
 .../solr/prometheus/scraper/package-info.java   |   21 +
 .../prometheus-exporter/src/java/overview.html  |   26 +
 .../src/test-files/conf/log4j.properties        |   22 +
 .../test-files/conf/solr-exporter-config.xml    | 1806 +++++++
 .../configsets/collection1/conf/managed-schema  |  412 ++
 .../configsets/collection1/conf/solrconfig.xml  |  232 +
 .../configsets/collection1/conf/stopwords.txt   |   14 +
 .../configsets/collection1/conf/synonyms.txt    |   29 +
 .../test-files/exampledocs/gb18030-example.xml  |   32 +
 .../src/test-files/exampledocs/hd.xml           |   56 +
 .../src/test-files/exampledocs/ipod_other.xml   |   60 +
 .../src/test-files/exampledocs/ipod_video.xml   |   40 +
 .../test-files/exampledocs/manufacturers.xml    |   75 +
 .../src/test-files/exampledocs/mem.xml          |   77 +
 .../src/test-files/exampledocs/money.xml        |   65 +
 .../src/test-files/exampledocs/monitor.xml      |   34 +
 .../src/test-files/exampledocs/monitor2.xml     |   33 +
 .../src/test-files/exampledocs/mp500.xml        |   43 +
 .../src/test-files/exampledocs/sample.html      |   13 +
 .../src/test-files/exampledocs/sd500.xml        |   38 +
 .../src/test-files/exampledocs/solr.xml         |   38 +
 .../src/test-files/exampledocs/utf8-example.xml |   42 +
 .../src/test-files/exampledocs/vidcard.xml      |   62 +
 .../prometheus/collector/SolrCollectorTest.java |   94 +
 .../prometheus/exporter/SolrExporterTest.java   |   99 +
 .../exporter/SolrExporterTestBase.java          |   53 +
 solr/licenses/argparse4j-0.8.1.jar.sha1         |    1 +
 solr/licenses/argparse4j-LICENSE-MIT.txt        |   23 +
 solr/licenses/argparse4j-NOTICE.txt             |    0
 solr/licenses/jackson-jq-0.0.8.jar.sha1         |    1 +
 solr/licenses/jackson-jq-LICENSE-ASL.txt        |   16 +
 solr/licenses/jackson-jq-NOTICE.txt             |    0
 solr/licenses/simpleclient-0.2.0.jar.sha1       |    1 +
 solr/licenses/simpleclient-LICENSE-ASL.txt      |  201 +
 solr/licenses/simpleclient-NOTICE.txt           |   11 +
 .../licenses/simpleclient_common-0.2.0.jar.sha1 |    1 +
 .../simpleclient_common-LICENSE-ASL.txt         |  201 +
 solr/licenses/simpleclient_common-NOTICE.txt    |   11 +
 .../simpleclient_httpserver-0.2.0.jar.sha1      |    1 +
 .../simpleclient_httpserver-LICENSE-ASL.txt     |  201 +
 .../licenses/simpleclient_httpserver-NOTICE.txt |   11 +
 .../grafana-solr-dashboard.png                  |  Bin 0 -> 808611 bytes
 .../solr-exporter-diagram.png                   |  Bin 0 -> 29070 bytes
 ...toring-solr-with-prometheus-and-grafana.adoc |  288 ++
 solr/solr-ref-guide/src/monitoring-solr.adoc    |    4 +-
 69 files changed, 12264 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/961269aa/dev-tools/idea/.idea/ant.xml
----------------------------------------------------------------------
diff --git a/dev-tools/idea/.idea/ant.xml b/dev-tools/idea/.idea/ant.xml
index 6c7bc8c..172c265 100644
--- a/dev-tools/idea/.idea/ant.xml
+++ b/dev-tools/idea/.idea/ant.xml
@@ -47,6 +47,7 @@
     <buildFile url="file://$PROJECT_DIR$/solr/contrib/dataimporthandler/build.xml" />
     <buildFile url="file://$PROJECT_DIR$/solr/contrib/extraction/build.xml" />
     <buildFile url="file://$PROJECT_DIR$/solr/contrib/langid/build.xml" />
+    <buildFile url="file://$PROJECT_DIR$/solr/contrib/prometheus-exporter/build.xml" />
     <buildFile url="file://$PROJECT_DIR$/solr/contrib/uima/build.xml" />
     <buildFile url="file://$PROJECT_DIR$/solr/contrib/velocity/build.xml" />
     <buildFile url="file://$PROJECT_DIR$/solr/solrj/build.xml" />

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/961269aa/dev-tools/idea/.idea/libraries/Solr_prometheus_exporter_library.xml
----------------------------------------------------------------------
diff --git a/dev-tools/idea/.idea/libraries/Solr_prometheus_exporter_library.xml b/dev-tools/idea/.idea/libraries/Solr_prometheus_exporter_library.xml
new file mode 100644
index 0000000..0fd8670
--- /dev/null
+++ b/dev-tools/idea/.idea/libraries/Solr_prometheus_exporter_library.xml
@@ -0,0 +1,10 @@
+<component name="libraryTable">
+  <library name="Solr prometheus exporter library">
+    <CLASSES>
+      <root url="file://$PROJECT_DIR$/solr/contrib/prometheus-exporter/lib" />
+    </CLASSES>
+    <JAVADOC />
+    <SOURCES />
+    <jarDirectory url="file://$PROJECT_DIR$/solr/contrib/prometheus-exporter/lib" recursive="false" />
+  </library>
+</component>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/961269aa/dev-tools/idea/.idea/modules.xml
----------------------------------------------------------------------
diff --git a/dev-tools/idea/.idea/modules.xml b/dev-tools/idea/.idea/modules.xml
index 4df1000..207a675 100644
--- a/dev-tools/idea/.idea/modules.xml
+++ b/dev-tools/idea/.idea/modules.xml
@@ -57,6 +57,7 @@
       <module group="Solr/Contrib" filepath="$PROJECT_DIR$/solr/contrib/extraction/extraction.iml" />
       <module group="Solr/Contrib" filepath="$PROJECT_DIR$/solr/contrib/langid/langid.iml" />
       <module group="Solr/Contrib" filepath="$PROJECT_DIR$/solr/contrib/ltr/ltr.iml" />
+      <module group="Solr/Contrib" filepath="$PROJECT_DIR$/solr/contrib/prometheus-exporter/prometheus-exporter.iml" />
       <module group="Solr/Contrib" filepath="$PROJECT_DIR$/solr/contrib/uima/uima.iml" />
       <module group="Solr/Contrib" filepath="$PROJECT_DIR$/solr/contrib/velocity/velocity.iml" />
     </modules>

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/961269aa/dev-tools/idea/.idea/workspace.xml
----------------------------------------------------------------------
diff --git a/dev-tools/idea/.idea/workspace.xml b/dev-tools/idea/.idea/workspace.xml
index 11794af..ba9a383 100644
--- a/dev-tools/idea/.idea/workspace.xml
+++ b/dev-tools/idea/.idea/workspace.xml
@@ -324,6 +324,14 @@
       <option name="TEST_SEARCH_SCOPE"><value defaultName="singleModule" /></option>
       <patterns><pattern testClass=".*\.Test[^.]*|.*\.[^.]*Test" /></patterns>
     </configuration>
+    <configuration default="false" name="Solr prometheus-exporter contrib" type="JUnit" factoryName="JUnit">
+      <module name="prometheus-exporter" />
+      <option name="TEST_OBJECT" value="pattern" />
+      <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/idea-build/solr/contrib/prometheus-exporter" />
+      <option name="VM_PARAMETERS" value="-ea" />
+      <option name="TEST_SEARCH_SCOPE"><value defaultName="singleModule" /></option>
+      <patterns><pattern testClass=".*\.Test[^.]*|.*\.[^.]*Test" /></patterns>
+    </configuration>
     <configuration default="false" name="Solr uima contrib" type="JUnit" factoryName="JUnit">
       <module name="uima" />
       <option name="TEST_OBJECT" value="pattern" />
@@ -382,8 +390,9 @@
       <item index="37" class="java.lang.String" itemvalue="JUnit.Solr extraction contrib" />
       <item index="38" class="java.lang.String" itemvalue="JUnit.Solr langid contrib" />
       <item index="39" class="java.lang.String" itemvalue="JUnit.Solr ltr contrib" />
-      <item index="40" class="java.lang.String" itemvalue="JUnit.Solr uima contrib" />
-      <item index="41" class="java.lang.String" itemvalue="JUnit.Solr velocity contrib" />
+      <item index="40" class="java.lang.String" itemvalue="JUnit.Solr prometheus-exporter contrib" />
+      <item index="41" class="java.lang.String" itemvalue="JUnit.Solr uima contrib" />
+      <item index="42" class="java.lang.String" itemvalue="JUnit.Solr velocity contrib" />
     </list>
   </component>
 </project>

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/961269aa/dev-tools/idea/solr/contrib/prometheus-exporter/prometheus-exporter.iml
----------------------------------------------------------------------
diff --git a/dev-tools/idea/solr/contrib/prometheus-exporter/prometheus-exporter.iml b/dev-tools/idea/solr/contrib/prometheus-exporter/prometheus-exporter.iml
new file mode 100644
index 0000000..b3d115b
--- /dev/null
+++ b/dev-tools/idea/solr/contrib/prometheus-exporter/prometheus-exporter.iml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" inherit-compiler-output="false">
+    <output url="file://$MODULE_DIR$/../../../idea-build/solr/contrib/prometheus-exporter/classes/java" />
+    <output-test url="file://$MODULE_DIR$/../../../idea-build/solr/contrib/prometheus-exporter/classes/test" />
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src/test" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test-files" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/java" isTestSource="false" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="library" scope="TEST" name="JUnit" level="project" />
+    <orderEntry type="library" name="Solr core library" level="project" />
+    <orderEntry type="library" name="Solrj library" level="project" />
+    <orderEntry type="module-library" scope="TEST">
+      <library>
+        <CLASSES>
+          <root url="file://$MODULE_DIR$/lib" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+        <jarDirectory url="file://$MODULE_DIR$/lib" recursive="false" />
+      </library>
+    </orderEntry>
+    <orderEntry type="module" scope="TEST" module-name="lucene-test-framework" />
+    <orderEntry type="module" scope="TEST" module-name="solr-test-framework" />
+    <orderEntry type="library" name="Solr core library" level="project" />
+    <orderEntry type="library" name="Solrj library" level="project" />
+    <orderEntry type="library" name="Solr prometheus exporter library" level="project" />
+    <orderEntry type="module" module-name="lucene-core" />
+    <orderEntry type="module" module-name="solr-core" />
+    <orderEntry type="module" module-name="solrj" />
+    <orderEntry type="module" module-name="analysis-common" />
+  </component>
+</module>

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/961269aa/dev-tools/maven/solr/contrib/pom.xml.template
----------------------------------------------------------------------
diff --git a/dev-tools/maven/solr/contrib/pom.xml.template b/dev-tools/maven/solr/contrib/pom.xml.template
index fec3385..733e308 100644
--- a/dev-tools/maven/solr/contrib/pom.xml.template
+++ b/dev-tools/maven/solr/contrib/pom.xml.template
@@ -39,6 +39,7 @@
     <module>extraction</module>
     <module>langid</module>
     <module>ltr</module>
+    <module>prometheus-exporter</module>
     <module>uima</module>
     <module>velocity</module>
   </modules>

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/961269aa/dev-tools/maven/solr/contrib/prometheus-exporter/pom.xml.template
----------------------------------------------------------------------
diff --git a/dev-tools/maven/solr/contrib/prometheus-exporter/pom.xml.template b/dev-tools/maven/solr/contrib/prometheus-exporter/pom.xml.template
new file mode 100644
index 0000000..1d2d508
--- /dev/null
+++ b/dev-tools/maven/solr/contrib/prometheus-exporter/pom.xml.template
@@ -0,0 +1,80 @@
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.solr</groupId>
+    <artifactId>solr-parent</artifactId>
+    <version>@version@</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+  <groupId>org.apache.solr</groupId>
+  <artifactId>solr-prometheus-exporter</artifactId>
+  <packaging>jar</packaging>
+  <name>Apache Solr Prometheus Exporter Package</name>
+  <description>
+    Apache Solr Prometheus Exporter Package
+  </description>
+  <properties>
+    <module-directory>solr/contrib/prometheus-exporter</module-directory>
+    <relative-top-level>../../../..</relative-top-level>
+    <module-path>${relative-top-level}/${module-directory}</module-path>
+  </properties>
+  <scm>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
+  </scm>
+  <dependencies>
+    <dependency>
+      <!-- lucene-test-framework dependency must be declared before lucene-core -->
+      <!-- This dependency cannot be put into solr-parent, because local        -->
+      <!-- dependencies are always ordered before inherited dependencies.       -->
+      <groupId>org.apache.lucene</groupId>
+      <artifactId>lucene-test-framework</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.solr</groupId>
+      <artifactId>solr-test-framework</artifactId>
+      <scope>test</scope>
+    </dependency>
+    @solr-prometheus-exporter.internal.dependencies@
+    @solr-prometheus-exporter.external.dependencies@
+    @solr-prometheus-exporter.internal.test.dependencies@
+    @solr-prometheus-exporter.external.test.dependencies@
+  </dependencies>
+  <build>
+    <sourceDirectory>${module-path}/src/java</sourceDirectory>
+    <testSourceDirectory>${module-path}/src/test</testSourceDirectory>
+    <testResources>
+      <testResource>
+        <directory>${module-path}/src/test-files</directory>
+      </testResource>
+      <testResource>
+        <directory>${top-level}/dev-tools/maven/solr</directory>
+        <includes>
+          <include>maven.testlogging.properties</include>
+        </includes>
+      </testResource>
+    </testResources>
+  </build>
+</project>

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/961269aa/lucene/ivy-versions.properties
----------------------------------------------------------------------
diff --git a/lucene/ivy-versions.properties b/lucene/ivy-versions.properties
index 5ab36dd..05955e4 100644
--- a/lucene/ivy-versions.properties
+++ b/lucene/ivy-versions.properties
@@ -70,6 +70,11 @@ io.dropwizard.metrics.version = 3.2.2
 io.netty.netty-all.version = 4.0.36.Final
 /io.netty/netty-all = ${io.netty.netty-all.version}
 
+io.prometheus.version = 0.2.0
+/io.prometheus/simpleclient = ${io.prometheus.version}
+/io.prometheus/simpleclient_common = ${io.prometheus.version}
+/io.prometheus/simpleclient_httpserver = ${io.prometheus.version}
+
 /javax.activation/activation = 1.1.1
 /javax.servlet/javax.servlet-api = 3.1.0
 /javax.servlet/servlet-api = 2.4
@@ -82,7 +87,15 @@ io.netty.netty-all.version = 4.0.36.Final
 /net.bytebuddy/byte-buddy = 1.6.2
 /net.hydromatic/eigenbase-properties = 1.1.5
 /net.sf.ehcache/ehcache-core = 2.4.4
+
+net.sourceforge.argparse4j.version = 0.8.1
+/net.sourceforge.argparse4j/argparse4j = ${net.sourceforge.argparse4j.version}
+
 /net.sourceforge.nekohtml/nekohtml = 1.9.17
+
+net.thisptr.version = 0.0.8
+/net.thisptr/jackson-jq = ${net.thisptr.version}
+
 /org.antlr/antlr4-runtime = 4.5.1-1
 
 /org.apache.ant/ant = 1.8.2
@@ -288,7 +301,6 @@ org.slf4j.version = 1.7.24
 /org.tallison/jmatio = 1.2
 /org.tukaani/xz = 1.6
 
-
 ua.net.nlp.morfologik-ukrainian-search.version = 3.9.0
 /ua.net.nlp/morfologik-ukrainian-search = ${ua.net.nlp.morfologik-ukrainian-search.version}
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/961269aa/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 8ce9b36..58d1435 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -150,6 +150,8 @@ New Features
 
 * SOLR-12006: Add a '*_t' and '*_t_sort' dynamic field for single valued text fields (Varun Thacker)
 
+* SOLR-11795: Add Solr metrics exporter for Prometheus (Minoru Osuka via koji)
+
 Bug Fixes
 ----------------------
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/961269aa/solr/build.xml
----------------------------------------------------------------------
diff --git a/solr/build.xml b/solr/build.xml
index 400c711..3f0596f 100644
--- a/solr/build.xml
+++ b/solr/build.xml
@@ -571,19 +571,19 @@
       <tarfileset dir="."
                   prefix="${fullnamever}"
                   includes="LICENSE.txt NOTICE.txt CHANGES.txt README.txt SYSTEM_REQUIREMENTS.txt
-                            bin/** server/** example/** contrib/**/lib/** contrib/**/README.txt 
+                            bin/** server/** example/** contrib/**/lib/** contrib/**/conf/** contrib/**/README.txt
                             licenses/**"
                   excludes="licenses/README.committers.txt **/data/ **/logs/* 
                             **/classes/ **/*.sh **/ivy.xml **/build.xml
                             **/bin/ **/*.iml **/*.ipr **/*.iws **/pom.xml 
-                            **/*pom.xml.template server/etc/test/" />
+                            **/*pom.xml.template server/etc/test/ contrib/**/src/" />
       <tarfileset dir="${dest}/contrib-lucene-libs-to-package"
                   prefix="${fullnamever}"
                   includes="**" />
       <tarfileset dir="."
                   filemode="755"
                   prefix="${fullnamever}"
-                  includes="bin/** server/**/*.sh example/**/*.sh example/**/bin/"
+                  includes="bin/** server/**/*.sh example/**/*.sh example/**/bin/ contrib/**/bin/**"
                   excludes="server/etc/test/**" />
       <tarfileset dir="."
                   prefix="${fullnamever}"

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/961269aa/solr/contrib/prometheus-exporter/README.md
----------------------------------------------------------------------
diff --git a/solr/contrib/prometheus-exporter/README.md b/solr/contrib/prometheus-exporter/README.md
new file mode 100644
index 0000000..888f237
--- /dev/null
+++ b/solr/contrib/prometheus-exporter/README.md
@@ -0,0 +1,21 @@
+Welcome to Apache Solr Prometheus Exporter
+========
+
+Apache Solr Prometheus Exporter (solr-exporter) provides a way for you to expose metrics for Solr to Prometheus.
+
+# Getting Started With Solr Prometheus Exporter
+
+For information on how to get started with solr-exporter please see:
+ * [Solr Reference Guide's section on Monitoring Solr with Prometheus and Grafana](https://lucene.apache.org/solr/guide/monitoring-solr-with-prometheus-and-grafana.html)
+
+# Getting Started With Solr
+
+For information on how to get started with solr please see:
+ * [solr/README.txt](../../README.txt)
+ * [Solr Tutorial](https://lucene.apache.org/solr/guide/solr-tutorial.html)
+
+# How To Contribute
+
+For information on how to contribute see:
+ * http://wiki.apache.org/lucene-java/HowToContribute
+ * http://wiki.apache.org/solr/HowToContribute

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/961269aa/solr/contrib/prometheus-exporter/README.txt
----------------------------------------------------------------------
diff --git a/solr/contrib/prometheus-exporter/README.txt b/solr/contrib/prometheus-exporter/README.txt
new file mode 100644
index 0000000..42061c0
--- /dev/null
+++ b/solr/contrib/prometheus-exporter/README.txt
@@ -0,0 +1 @@
+README.md
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/961269aa/solr/contrib/prometheus-exporter/bin/solr-exporter
----------------------------------------------------------------------
diff --git a/solr/contrib/prometheus-exporter/bin/solr-exporter b/solr/contrib/prometheus-exporter/bin/solr-exporter
new file mode 100755
index 0000000..bf28488
--- /dev/null
+++ b/solr/contrib/prometheus-exporter/bin/solr-exporter
@@ -0,0 +1,122 @@
+#!/bin/sh
+
+#
+# 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.
+#
+
+BASEDIR=`dirname $0`/..
+BASEDIR=`(cd "$BASEDIR"; pwd)`
+
+# OS specific support.  $var _must_ be set to either true or false.
+cygwin=false;
+darwin=false;
+case "`uname`" in
+  CYGWIN*) cygwin=true ;;
+  Darwin*) darwin=true
+           if [ -z "$JAVA_VERSION" ] ; then
+             JAVA_VERSION="CurrentJDK"
+           else
+             echo "Using Java version: $JAVA_VERSION"
+           fi
+           if [ -z "$JAVA_HOME" ] ; then
+             JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Home
+           fi
+           ;;
+esac
+
+if [ -z "$JAVA_HOME" ] ; then
+  if [ -r /etc/gentoo-release ] ; then
+    JAVA_HOME=`java-config --jre-home`
+  fi
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+  [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+  [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+fi
+
+# If a specific java binary isn't specified search for the standard 'java' binary
+if [ -z "$JAVACMD" ] ; then
+  if [ -n "$JAVA_HOME"  ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+      # IBM's JDK on AIX uses strange locations for the executables
+      JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+      JAVACMD="$JAVA_HOME/bin/java"
+    fi
+  else
+    JAVACMD=`which java`
+  fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+  echo "Error: JAVA_HOME is not defined correctly."
+  echo "  We cannot execute $JAVACMD"
+  exit 1
+fi
+
+if [ -z "$REPO" ]
+then
+  REPO="$BASEDIR"/lib
+fi
+
+CLASSPATH=$CLASSPATH_PREFIX
+for JAR in $(find "$REPO" -name '*.jar')
+do
+  CLASSPATH="$CLASSPATH":"$JAR"
+done
+for JAR in $(find "$BASEDIR"/../../dist/solrj-lib -name '*.jar')
+do
+  CLASSPATH="$CLASSPATH":"$JAR"
+done
+for JAR in $(find "$BASEDIR"/../../dist -name 'solr-core-*.jar')
+do
+  CLASSPATH="$CLASSPATH":"$JAR"
+done
+for JAR in $(find "$BASEDIR"/../../dist -name 'solr-solrj-*.jar')
+do
+  CLASSPATH="$CLASSPATH":"$JAR"
+done
+for JAR in $(find "$BASEDIR"/../../dist -name 'solr-prometheus-exporter-*.jar')
+do
+  CLASSPATH="$CLASSPATH":"$JAR"
+done
+for JAR in $(find "$BASEDIR"/lucene-libs -name '*.jar')
+do
+  CLASSPATH="$CLASSPATH":"$JAR"
+done
+
+EXTRA_JVM_ARGUMENTS="-Xmx512m -Dlog4j.configuration=file:"$BASEDIR"/conf/log4j.properties"
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+  [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+  [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
+  [ -n "$HOME" ] && HOME=`cygpath --path --windows "$HOME"`
+  [ -n "$BASEDIR" ] && BASEDIR=`cygpath --path --windows "$BASEDIR"`
+  [ -n "$REPO" ] && REPO=`cygpath --path --windows "$REPO"`
+fi
+
+exec "$JAVACMD" $JAVA_OPTS \
+  $EXTRA_JVM_ARGUMENTS \
+  -classpath "$CLASSPATH" \
+  -Dapp.name="solr-exporter" \
+  -Dapp.pid="$$" \
+  -Dapp.repo="$REPO" \
+  -Dbasedir="$BASEDIR" \
+  org.apache.solr.prometheus.exporter.SolrExporter \
+  "$@"

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/961269aa/solr/contrib/prometheus-exporter/bin/solr-exporter.cmd
----------------------------------------------------------------------
diff --git a/solr/contrib/prometheus-exporter/bin/solr-exporter.cmd b/solr/contrib/prometheus-exporter/bin/solr-exporter.cmd
new file mode 100644
index 0000000..05d8275
--- /dev/null
+++ b/solr/contrib/prometheus-exporter/bin/solr-exporter.cmd
@@ -0,0 +1,104 @@
+@REM
+@REM  Licensed to the Apache Software Foundation (ASF) under one or more
+@REM  contributor license agreements.  See the NOTICE file distributed with
+@REM  this work for additional information regarding copyright ownership.
+@REM  The ASF licenses this file to You under the Apache License, Version 2.0
+@REM  (the "License"); you may not use this file except in compliance with
+@REM  the License.  You may obtain a copy of the License at
+@REM
+@REM      http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM  Unless required by applicable law or agreed to in writing, software
+@REM  distributed under the License is distributed on an "AS IS" BASIS,
+@REM  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@REM  See the License for the specific language governing permissions and
+@REM  limitations under the License.
+
+@echo off
+
+set ERROR_CODE=0
+
+:init
+@REM Decide how to startup depending on the version of windows
+
+@REM -- Win98ME
+if NOT "%OS%"=="Windows_NT" goto Win9xArg
+
+@REM set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" @setlocal
+
+@REM -- 4NT shell
+if "%eval[2+2]" == "4" goto 4NTArgs
+
+@REM -- Regular WinNT shell
+set CMD_LINE_ARGS=%*
+goto WinNTGetScriptDir
+
+@REM The 4NT Shell from jp software
+:4NTArgs
+set CMD_LINE_ARGS=%$
+goto WinNTGetScriptDir
+
+:Win9xArg
+@REM Slurp the command line arguments.  This loop allows for an unlimited number
+@REM of agruments (up to the command line limit, anyway).
+set CMD_LINE_ARGS=
+:Win9xApp
+if %1a==a goto Win9xGetScriptDir
+set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
+shift
+goto Win9xApp
+
+:Win9xGetScriptDir
+set SAVEDIR=%CD%
+%0\
+cd %0\..\.. 
+set BASEDIR=%CD%
+cd %SAVEDIR%
+set SAVE_DIR=
+goto repoSetup
+
+:WinNTGetScriptDir
+set BASEDIR=%~dp0\..
+
+:repoSetup
+
+
+if "%JAVACMD%"=="" set JAVACMD=java
+
+if "%REPO%"=="" set REPO=%BASEDIR%\lib
+
+set CLASSPATH="%CLASSPATH%";"%REPO%\*;%BASEDIR%\..\..\dist\solrj-lib\*;%BASEDIR%\..\..\dist\solr-core-*;%BASEDIR%\..\..\dist\solr-solrj-*;%BASEDIR%\..\..\dist\solr-prometheus-exporter-*;%BASEDIR%\lib\*"
+set EXTRA_JVM_ARGUMENTS=-Xmx512m -Dlog4j.configuration=file:%BASEDIR%/conf/log4j.properties
+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%" com.github.mosuka.solr.prometheus.exporter.SolrExporter %CMD_LINE_ARGS%
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+if "%OS%"=="Windows_NT" @endlocal
+set ERROR_CODE=1
+
+:end
+@REM set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" goto endNT
+
+@REM For old DOS remove the set variables from ENV - we assume they were not set
+@REM before we started - at least we don't leave any baggage around
+set CMD_LINE_ARGS=
+goto postExec
+
+:endNT
+@endlocal
+
+:postExec
+
+if "%FORCE_EXIT_ON_ERROR%" == "on" (
+  if %ERROR_CODE% NEQ 0 exit %ERROR_CODE%
+)
+
+exit /B %ERROR_CODE%

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/961269aa/solr/contrib/prometheus-exporter/build.xml
----------------------------------------------------------------------
diff --git a/solr/contrib/prometheus-exporter/build.xml b/solr/contrib/prometheus-exporter/build.xml
new file mode 100644
index 0000000..3c6ce7e
--- /dev/null
+++ b/solr/contrib/prometheus-exporter/build.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0"?>
+
+<!--
+    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.
+ -->
+
+<project name="solr-prometheus-exporter" default="default">
+
+  <description>
+    Prometheus exporter for exposing metrics from Solr using Metrics API and Search API.
+  </description>
+
+  <import file="../contrib-build.xml"/>
+
+  <path id="common.analysis.lucene.libs">
+    <pathelement path="${analyzers-common.jar}"/>
+  </path>
+
+  <path id="classpath">
+    <path refid="common.analysis.lucene.libs"/>
+    <path refid="solr.base.classpath"/>
+  </path>
+
+  <target name="module-jars-to-solr" depends="-module-jars-to-solr-not-for-package,-module-jars-to-solr-package"/>
+
+  <target name="-module-jars-to-solr-not-for-package" unless="called.from.create-package">
+    <antcall target="jar-analyzers-common" inheritall="true"/>
+    <property name="analyzers-common.uptodate" value="true"/>
+    <mkdir dir="${build.dir}/lucene-libs"/>
+    <copy todir="${build.dir}/lucene-libs" preservelastmodified="true" flatten="true" failonerror="true" overwrite="true">
+      <fileset file="${analyzers-common.jar}"/>
+    </copy>
+  </target>
+
+  <target name="-module-jars-to-solr-package" if="called.from.create-package">
+    <antcall target="-unpack-lucene-tgz" inheritall="true"/>
+    <pathconvert property="relative.common.analysis.lucene.libs" pathsep=",">
+      <path refid="common.analysis.lucene.libs"/>
+      <globmapper from="${common.build.dir}/*" to="*" handledirsep="true"/>
+    </pathconvert>
+    <mkdir dir="${build.dir}/lucene-libs"/>
+    <copy todir="${build.dir}/lucene-libs" preservelastmodified="true" flatten="true" failonerror="true" overwrite="true">
+      <fileset dir="${lucene.tgz.unpack.dir}/lucene-${version}" includes="${relative.common.analysis.lucene.libs}"/>
+    </copy>
+  </target>
+
+  <target name="compile-core" depends="jar-analyzers-common, solr-contrib-build.compile-core"/>
+
+  <target name="dist" depends="module-jars-to-solr, common-solr.dist"/>
+
+</project>