This feature is considered experimental, meaning future improvements may break compatibility.

The Prometheus exporter is included in Solr as a contrib, and is located in contrib/prometheus-exporter in your Solr instance.

There are three aspects to running solr-exporter:

Modify the solr-exporter-config.xml to define the data to collect. Solr has a default configuration you can use, but if you would like to modify it before running the exporter the first time, see the section below Exporter Configuration.

Command Line Parameters

The port where Prometheus will listen for new data. This port will be used to configure Prometheus. It can be any port not already in use on your server. The default is 9983.

-b, --baseurl

The Solr base URL (such as http://localhost:8983/solr) when Solr is running in Standalone mode. If you are running Solr in SolrCloud mode, do not specify this parameter. If neither the -b parameter nor the -z parameter are defined, the default is -b http://localhost:8983/solr.

-z, --zkhost

The ZooKeeper connect string (such as localhost:8983, or localhost:2181/solr) when Solr is running in SolrCloud mode. If you are running Solr in Standalone mode, do not specify this parameter. If neither the -b parameter nor the -z parameter are defined, the -b parameter default is used.

-f, --config-file

The path to the configuration file that defines the Solr metrics to read. The default is contrib/prometheus-exporter/conf/solr-exporter-config.xml.

-n, --num-threads

The number of threads. The solr-exporter creates thread pools for requests to Solr. Request latency can be improved by increasing the number of threads. The default is 1.

The Solr’s metrics exposed by solr-exporter can be seen at: http://localhost:9983/solr/admin/metrics.

Exporter Configuration

The configuration for the solr-exporter defines the data to get from Solr. This includes the metrics, but can also include queries to the PingRequestHandler, the Collections API, and a query to any query request handler.

A default example configuration is in contrib/prometheus-exporter/config/solr-exporter-config.xml. Below is a slightly shortened version of it:

Configuration Tags and Elements

The solr-exporter works by making a request to Solr according to the definitions in the configuration file, scraping the response, and converting it to a JSON structure Prometheus can understand. The configuration file defines the elements to request, how to scrape them, and where to place the extracted data in the JSON template.

The solr-exporter configuration file always starts and closes with two simple elements:

<config><rules></rules></config>

Between these elements, the data the solr-exporter should request is defined. There are several possible types of requests to make:

Within each of these types, we need to define the query and how to work with the response. To do this, we define two additional elements:

<query>

Defines the query parameter(s) used for the request. This section uses several additional properties to define your query:

collection

The collection to issue the query against. Only used in SolrCloud mode.

core

The core to issue the query against. Only used in Standalone mode.

path

The path to the query endpoint where the request will be sent. Examples include admin/metrics or /select or admin/collections.

params

Additional query parameters. These will vary depending on the request type and the endpoint. For example, if using the Metrics endpoint, you can add parameters to limit the query to a certain group and/or prefix. If you’re using the Collections API, the command you want to use would be a parameter.

<jsonQueries>

This is an array that defines one or more JSON Queries in jq syntax. For more details about how to structure these queries, see the jq user manual.

If you already have a section for scrape_configs, you can add the job_name and other values in the same section.

When you apply the settings to Prometheus, it will start to pull Solr’s metrics from solr-exporter.

Sample Grafana Dashboard

A Grafana sample dashboard is provided in the following JSON file: contrib/prometheus-exporter/conf/grafana-solr-dashboard.json.
You can place this with your other Grafana dashboard configurations and modify it as necessary depending on any customization you’ve done for the solr-exporter configuration.