This is an automated email from the ASF dual-hosted git repository.
janhoy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new 81c4470da5f SOLR-18536: OTel Collector config (#5244)
81c4470da5f is described below
commit 81c4470da5fec97d71b956097a9aa76e8f4991bb
Author: Jan Høydahl <[email protected]>
AuthorDate: Sun Nov 22 00:53:07 2026 +0100
SOLR-18536: OTel Collector config (#5244)
---
.../SOLR-18536-otel-collector-config.yml | 10 +
solr/.gitignore | 2 +
solr/monitoring/README.md | 59 ++++-
solr/monitoring/dev/docker-compose.yml | 70 +++++-
solr/monitoring/dev/inspect-metrics.py | 242 +++++++++++++++++++++
solr/monitoring/dev/otel-collector-native.yaml | 34 +++
.../monitoring/dev/prometheus/prometheus-local.yml | 16 ++
solr/monitoring/dev/prometheus/prometheus.yml | 18 ++
solr/monitoring/dev/stack.sh | 14 +-
solr/monitoring/otel-collector-config.yaml | 72 ++++++
.../deployment-guide/pages/metrics-reporting.adoc | 33 +--
.../monitoring-with-prometheus-and-grafana.adoc | 39 +++-
12 files changed, 556 insertions(+), 53 deletions(-)
diff --git a/changelog/unreleased/SOLR-18536-otel-collector-config.yml
b/changelog/unreleased/SOLR-18536-otel-collector-config.yml
new file mode 100644
index 00000000000..bf8669fa715
--- /dev/null
+++ b/changelog/unreleased/SOLR-18536-otel-collector-config.yml
@@ -0,0 +1,10 @@
+title: >
+ Add an example OpenTelemetry Collector configuration that re-exposes Solr's
OTLP metric push in
+ Prometheus format, under the same metric names as `/solr/admin/metrics`.
+type: added
+authors:
+ - name: Jan Høydahl
+ url: https://home.apache.org/phonebook.html?uid=janhoy
+links:
+ - name: SOLR-18536
+ url: https://issues.apache.org/jira/browse/SOLR-18536
diff --git a/solr/.gitignore b/solr/.gitignore
index 8d643687405..f6a60135e16 100644
--- a/solr/.gitignore
+++ b/solr/.gitignore
@@ -24,3 +24,5 @@
lib/
test-lib/
+
+/monitoring/dev/.env
diff --git a/solr/monitoring/README.md b/solr/monitoring/README.md
index a9cf43b0ced..9123917dc47 100644
--- a/solr/monitoring/README.md
+++ b/solr/monitoring/README.md
@@ -16,25 +16,25 @@
-->
# Solr Monitoring
-This directory provides two ready-to-use monitoring artifacts for Solr that
you can drop into
+This directory provides three ready-to-use monitoring artifacts for Solr that
you can drop into
your existing Prometheus + Grafana installation:
| File | Description |
|---|---|
| **`grafana-solr-dashboard.json`** | Grafana dashboard — import directly into
Grafana |
| **`prometheus-solr-alerts.yml`** | Prometheus alert rules — reference from
your `prometheus.yml` |
+| **`otel-collector-config.yaml`** | Example OpenTelemetry Collector config —
receives Solr's OTLP push and exposes the metrics in Prometheus format under
the same metric names as `/solr/admin/metrics`; a starting point to adapt, not
a production setup |
These are the **main artifacts**. Everything else in this directory supports
their creation
or testing.
| File / Directory | Description |
|---|---|
-| `mixin/` | Jsonnet source (single source of truth used to regenerate the
artifacts above) |
+| `mixin/` | Jsonnet source (single source of truth used to regenerate the
dashboard and alert rules) |
| `dev/` | **Developer convenience only** — docker-compose stack for testing
changes to the artifacts |
> **The dashboard is still a placeholder**, enough to exercise the build
> pipeline. The real one
-> arrives in [SOLR-18534](https://issues.apache.org/jira/browse/SOLR-18534)
and OTLP push support
-> in [SOLR-18536](https://issues.apache.org/jira/browse/SOLR-18536). The alert
rules are complete.
+> arrives in [SOLR-18534](https://issues.apache.org/jira/browse/SOLR-18534).
The alert rules are complete.
For the full integration guide see the Solr Reference Guide:
**[Monitoring Solr with Prometheus and
Grafana](../solr-ref-guide/modules/deployment-guide/pages/monitoring-with-prometheus-and-grafana.adoc)**
@@ -94,6 +94,15 @@ with `aggregateNodeLevelMetricsEnabled` emits a node rollup
under the same metri
---
+## Scraping via the OpenTelemetry Collector
+
+Nodes can push metrics over OTLP to a Collector running
`otel-collector-config.yaml`, which you
+then scrape instead of the nodes. Its `transform` processor keeps the metric
names identical to a
+direct scrape, so the dashboard and alert rules work either way. See the
Reference Guide page
+linked above for the setup.
+
+---
+
## Customizing
All tunable settings live in `mixin/config.libsonnet`:
@@ -192,9 +201,9 @@ and the MiB units of the index-size gauge — so run `make
test` after editing `
## Developer Convenience Stack
The `dev/` directory contains a docker-compose stack that starts a local Solr
+ Prometheus
-+ Grafana + Alertmanager environment. **This is solely for contributors who
want to
-visually test changes to the two artifacts above.** It is not a reference
deployment
-or a recommended production setup, and is excluded from the source release.
++ Grafana + Alertmanager + OpenTelemetry Collector + Aspire Dashboard
environment. **This is solely for
+contributors who want to visually test changes to the artifacts above.** It is
not a reference
+deployment or a recommended production setup, and is excluded from the source
release.
```bash
cd dev
@@ -203,22 +212,48 @@ cd dev
./stack.sh --down # stop and remove everything
```
+The bundled Solr nodes always push metrics and traces to the Collector, which
forwards both to
+Aspire (`:18888`) for a raw view. Prometheus scrapes both collection routes at
once — the nodes
+directly as job `solr`, the Collector as job `solr-otlp` — so the two can be
compared without
+reconfiguring anything. The shipped dashboard and alert rules select
`job="solr"`, so only the
+direct route drives them. `inspect-metrics.py` reads both, with the stack up
and the trafficgen
+running:
+
+```bash
+./inspect-metrics.py parity # do both routes deliver the same names? exit
1 if not
+./inspect-metrics.py list # every name, and which routes have it
+./inspect-metrics.py list --otel # the OpenTelemetry names Solr pushes, before
translation
+```
+
+Run `parity` after changing the Collector config, or after a Solr,
OpenTelemetry SDK or Collector
+upgrade — the `_ratio` suffix the config exists to undo arrived in an SDK
upgrade exactly that
+way. It waits for both jobs to stop producing new names before comparing, so a
registry that
+appears late is not read as a difference.
+
+`list --otel` reads a second Collector endpoint added by the dev-only
+`dev/otel-collector-native.yaml`, which leaves the OpenTelemetry names
untranslated, so you can
+see what a name looked like before the Prometheus conventions reshaped it.
+
Use `stack.sh` rather than `docker compose up` directly: the bundled Solr
nodes sit behind the
`bundled-solr` compose profile, so a plain `docker compose up` would start the
monitoring services
with no Solr to scrape.
Services: Solr (`:8983`, `:8984`), Prometheus (`:9090`), Grafana (`:3000`),
Alertmanager
-(`:9093`). Grafana opens straight on the provisioned dashboard with no login —
anonymous viewing
+(`:9093`), OpenTelemetry Collector (OTLP in on `:4318`, Prometheus format out
on `:9464`, the
+same untranslated on `:9465`),
+Aspire Dashboard (`:18888`). Grafana opens straight on the provisioned
dashboard with no login — anonymous viewing
is enabled because this stack is local and throwaway; sign in as
`admin`/`admin` to edit. The
-Prometheus datasource is provisioned too, and Prometheus loads the alert
rules. Both artifacts are bind-mounted as single
-files, which the containers resolve once at start, so after regenerating one,
recreate them:
+Prometheus datasource is provisioned too, and Prometheus loads the alert
rules. The artifacts are
+bind-mounted as single files, which the containers resolve once at start, so
after regenerating or
+editing one, recreate them:
```bash
-docker compose up -d --force-recreate grafana prometheus
+docker compose up -d --force-recreate grafana prometheus otel-collector
```
The monitoring images are pinned for reproducibility. Override `SOLR_IMAGE`,
`PROMETHEUS_IMAGE`,
-`GRAFANA_IMAGE` or `ALERTMANAGER_IMAGE` to test against other versions:
+`GRAFANA_IMAGE`, `ALERTMANAGER_IMAGE`, `OTEL_COLLECTOR_IMAGE` or
`ASPIRE_IMAGE` to test against other
+versions:
```bash
GRAFANA_IMAGE=grafana/grafana:latest ./stack.sh
diff --git a/solr/monitoring/dev/docker-compose.yml
b/solr/monitoring/dev/docker-compose.yml
index 4af98d4691b..d7da6bc6f89 100644
--- a/solr/monitoring/dev/docker-compose.yml
+++ b/solr/monitoring/dev/docker-compose.yml
@@ -18,10 +18,11 @@
# ============================================================================
#
# This docker-compose stack is provided solely to make it easy for contributors
-# to view and test changes to the two generated monitoring artifacts:
+# to view and test changes to the three monitoring artifacts:
#
-# ../grafana-solr-dashboard.json — Grafana dashboard
-# ../prometheus-solr-alerts.yml — Prometheus alert rules
+# ../grafana-solr-dashboard.json — Grafana dashboard (generated)
+# ../prometheus-solr-alerts.yml — Prometheus alert rules (generated)
+# ../otel-collector-config.yaml — example OTel Collector config
(hand-written)
#
# It is NOT intended as a reference deployment or a recommended production
setup.
# For integrating the artifacts into your own Prometheus + Grafana
installation,
@@ -42,24 +43,52 @@
# Prometheus http://localhost:9090
# Grafana http://localhost:3000 (admin / admin)
# Alertmanager http://localhost:9093
+# otel-collector OTLP in on http://localhost:4318, Prometheus-format out on
http://localhost:9464,
+# the same untranslated on http://localhost:9465 (see
./otel-collector-native.yaml)
+# Aspire http://localhost:18888 (raw view of the metrics and traces
Solr pushed)
# trafficgen (no port — continuously indexes/searches the 'test'
collection)
#
+# The bundled Solr nodes always push metrics and traces over OTLP to
otel-collector,
+# which forwards both to the Aspire Dashboard. Prometheus scrapes both routes:
the
+# nodes directly as job "solr", and the collector as job "solr-otlp".
+#
# Environment variables (set by stack.sh, or override manually):
# PROMETHEUS_CONFIG Path to the prometheus config to mount (default:
./prometheus/prometheus.yml)
# SOLR_URL Solr base URL for trafficgen (default:
http://solr1:8983/solr)
-# SOLR_IMAGE Solr image for the bundled nodes (default: solr:10)
+# SOLR_IMAGE Solr image for the bundled nodes (default:
apache/solr-nightly:10.2.0-SNAPSHOT, tracks branch_10x)
# PROMETHEUS_IMAGE Prometheus image (default: pinned, see below)
# GRAFANA_IMAGE Grafana image (default: pinned, see below)
# ALERTMANAGER_IMAGE Alertmanager image (default: pinned, see below)
+# OTEL_COLLECTOR_IMAGE OpenTelemetry Collector image (default: pinned, see
below; must be a contrib build)
+# ASPIRE_IMAGE Aspire Dashboard image (default: pinned, see below)
#
# The monitoring images are pinned so a stack that worked yesterday still works
# today; override any of them to test against a newer release.
# ============================================================================
+name: solr-telemetry-dev
+
+# Push stays on whatever Prometheus scrapes, so the collector and Aspire
always have data.
+# OTEL_SERVICE_NAME activates the module's tracer, which pushes traces the
same way.
+x-solr-otlp-env: &solr-otlp-env
+ SOLR_MODULES: opentelemetry
+ SOLR_METRICS_OTLP_EXPORTER_ENABLED: "true"
+ SOLR_METRICS_OTLP_EXPORTER_PROTOCOL: http # explicit: Solr 10.0 defaults
to grpc
+ SOLR_METRICS_OTLP_EXPORTER_INTERVAL: "15000"
+ SOLR_METRICS_OTLP_HTTP_EXPORTER_ENDPOINT:
http://otel-collector:4318/v1/metrics
+ OTEL_SERVICE_NAME: solr
+ OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf
+ OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4318
+
services:
solr1:
- image: ${SOLR_IMAGE:-solr:10}
+ image: ${SOLR_IMAGE:-apache/solr-nightly:10.2.0-SNAPSHOT}
profiles: [bundled-solr]
+ environment:
+ <<: *solr-otlp-env
+ # Report the compose service name, not the container's random hostname,
so the identity
+ # Solr publishes matches the name Prometheus scrapes it by
+ SOLR_HOST_ADVERTISE: solr1
ports:
- "127.0.0.1:8983:8983"
- "127.0.0.1:9983:9983" # embedded ZooKeeper (Solr 10 default: ZK_PORT
= SOLR_PORT + 1000)
@@ -72,11 +101,13 @@ services:
start_period: 40s
solr2:
- image: ${SOLR_IMAGE:-solr:10}
+ image: ${SOLR_IMAGE:-apache/solr-nightly:10.2.0-SNAPSHOT}
profiles: [bundled-solr]
ports:
- "127.0.0.1:8984:8983"
environment:
+ <<: *solr-otlp-env
+ SOLR_HOST_ADVERTISE: solr2
ZK_HOST: "solr1:9983"
depends_on:
solr1:
@@ -139,6 +170,33 @@ services:
- ./alertmanager/alertmanager.yml:/etc/alertmanager/alertmanager.yml:ro
restart: unless-stopped
+ otel-collector:
+ image:
${OTEL_COLLECTOR_IMAGE:-otel/opentelemetry-collector-contrib:0.164.0}
+ ports:
+ - "127.0.0.1:4318:4318" # OTLP/HTTP in — a Solr on the host pushes
here with its defaults
+ - "127.0.0.1:9464:9464" # Prometheus-format out
+ - "127.0.0.1:9465:9465" # the same, with OpenTelemetry names left
untranslated
+ # Two --config files are merged, so the shipped example stays lean and the
+ # untranslated endpoint exists only here
+ command:
+ - --config=/etc/otelcol-contrib/config.yaml
+ - --config=/etc/otelcol-contrib/native.yaml
+ volumes:
+ - ../otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml:ro
+ - ./otel-collector-native.yaml:/etc/otelcol-contrib/native.yaml:ro
+ depends_on:
+ - aspire-dashboard
+ restart: unless-stopped
+
+ aspire-dashboard:
+ image: ${ASPIRE_IMAGE:-mcr.microsoft.com/aspire/dashboard:13.6.2}
+ ports:
+ - "127.0.0.1:18888:18888"
+ environment:
+ # Local throwaway stack: no login. Data is in-memory and gone on restart.
+ ASPIRE_DASHBOARD_UNSECURED_ALLOW_ANONYMOUS: "true"
+ restart: unless-stopped
+
trafficgen:
build: ./trafficgen
extra_hosts:
diff --git a/solr/monitoring/dev/inspect-metrics.py
b/solr/monitoring/dev/inspect-metrics.py
new file mode 100755
index 00000000000..2a5c95553e8
--- /dev/null
+++ b/solr/monitoring/dev/inspect-metrics.py
@@ -0,0 +1,242 @@
+#!/usr/bin/env python3
+#
+# 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.
+#
+"""Inspect the metrics the dev stack collects.
+
+The stack scrapes Solr directly as job "solr" and the OpenTelemetry Collector
the
+nodes push to as job "solr-otlp", and the Collector config transforms names so
the
+two agree. Run with the stack up (./stack.sh) and the trafficgen running:
+
+ ./inspect-metrics.py parity # do both routes deliver the same names?
+ ./inspect-metrics.py list # every name, and which routes have it
+ ./inspect-metrics.py list --otel # the OpenTelemetry names Solr pushes
+
+Exit code 0 on success, 1 when parity fails, 2 when the stack is not in a state
+where the question can be answered. Names only; values are never compared.
+"""
+
+import argparse
+import json
+import re
+import sys
+import time
+import urllib.error
+import urllib.parse
+import urllib.request
+
+SCRAPE_JOB = "solr"
+OTLP_JOB = "solr-otlp"
+
+# The collector's second endpoint, added by the dev-only
otel-collector-native.yaml overlay,
+# which leaves OpenTelemetry names untranslated. Dotted names only survive the
wire when the
+# reader says it accepts UTF-8, otherwise they come back escaped to
underscores.
+NATIVE_ACCEPT = "text/plain;version=0.0.4;escaping=allow-utf-8"
+TYPE_LINE = re.compile(r'^# TYPE "?([^"\s]+)"? ')
+
+# Added by Prometheus for every target rather than coming from Solr
+SYNTHETIC = {"up", "ALERTS", "ALERTS_FOR_STATE"}
+SYNTHETIC_PREFIX = "scrape_"
+
+# Differences that are currently expected, and why. Empty this as they are
fixed.
+KNOWN_DIFFERENCES = {
+ "target_info": "the Collector cannot emit it until Solr sends
service.instance.id (SOLR-18594)",
+}
+
+
+def die(message):
+ """Exit 2: the stack is not in a state where the question can be
answered."""
+ print(message, file=sys.stderr)
+ sys.exit(2)
+
+
+def query(base_url, path, params):
+ url = f"{base_url}/api/v1/{path}?{urllib.parse.urlencode(params,
doseq=True)}"
+ try:
+ with urllib.request.urlopen(url, timeout=30) as response:
+ payload = json.load(response)
+ except urllib.error.URLError as e:
+ die(f"Cannot reach Prometheus at {base_url}: {e.reason}\nIs the stack
up? ./stack.sh")
+ if payload.get("status") != "success":
+ die(f"Prometheus rejected {path}: {payload.get('error', payload)}")
+ return payload["data"]
+
+
+def metric_names(base_url, job):
+ """Metric names Prometheus holds for one job, Solr's own only."""
+ names = query(base_url, "label/__name__/values", {"match[]": '{job="%s"}'
% job})
+ return {
+ n for n in names if n not in SYNTHETIC and not
n.startswith(SYNTHETIC_PREFIX)
+ }
+
+
+def otel_metric_names(url):
+ """The names Solr pushes, before any Prometheus naming is applied."""
+ request = urllib.request.Request(url, headers={"Accept": NATIVE_ACCEPT})
+ try:
+ with urllib.request.urlopen(request, timeout=30) as response:
+ body = response.read().decode("utf-8")
+ except urllib.error.URLError as e:
+ die(
+ f"Cannot reach the collector's untranslated endpoint at {url}:
{e.reason}\n"
+ "It is added by otel-collector-native.yaml; is the stack up?
./stack.sh"
+ )
+ names = {m.group(1) for m in (TYPE_LINE.match(line) for line in
body.splitlines()) if m}
+ if not names:
+ die(f"No metrics at {url} yet; is Solr pushing?")
+ return names
+
+
+def check_targets(base_url, settle):
+ """Both jobs must have a healthy target, or the comparison is meaningless.
+
+ Retries, since Prometheus needs a scrape interval or two after start
before it has
+ targets at all, and the stack is usually only seconds old when this runs.
+ """
+ deadline = time.monotonic() + settle
+ while True:
+ targets = query(base_url, "targets", {"state":
"active"})["activeTargets"]
+ problems = []
+ for job in (SCRAPE_JOB, OTLP_JOB):
+ if any(t["labels"].get("job") == job and t["health"] == "up" for t
in targets):
+ continue
+ configured = [t for t in targets if t["labels"].get("job") == job]
+ if not configured:
+ problems.append(f"no target for job '{job}'")
+ else:
+ why = configured[0].get("lastError") or configured[0]["health"]
+ problems.append(f"job '{job}' has no healthy target: {why}")
+ if not problems:
+ return
+ if time.monotonic() >= deadline:
+ die(
+ "; ".join(problems)
+ + "\nIs this the dev stack's Prometheus, and is the stack up?
./stack.sh"
+ )
+ time.sleep(2)
+
+
+def collect(base_url, timeout, poll, stable_polls, verbose):
+ """Poll until both name sets stop growing, so late registries are not read
as differences."""
+ deadline = time.monotonic() + timeout
+ previous = None
+ unchanged = 0
+ while True:
+ current = (metric_names(base_url, SCRAPE_JOB), metric_names(base_url,
OTLP_JOB))
+ if verbose:
+ print(f" {SCRAPE_JOB}: {len(current[0])} {OTLP_JOB}:
{len(current[1])}")
+ unchanged = unchanged + 1 if current == previous else 0
+ previous = current
+ if unchanged >= stable_polls:
+ return current
+ if time.monotonic() >= deadline:
+ print(
+ f"Name counts still changing after {timeout}s; comparing
anyway.",
+ file=sys.stderr,
+ )
+ return current
+ time.sleep(poll)
+
+
+def add_common_arguments(parser):
+ parser.add_argument("--prometheus", default="http://localhost:9090",
help="Prometheus base URL")
+ parser.add_argument("--timeout", type=int, default=180, help="seconds to
wait for a stable set")
+ parser.add_argument("--poll", type=int, default=10, help="seconds between
polls")
+ parser.add_argument("--stable", type=int, default=3, help="unchanged polls
before comparing")
+ parser.add_argument("--settle", type=int, default=60, help="seconds to
wait for healthy targets")
+ parser.add_argument("-v", "--verbose", action="store_true", help="print
each poll")
+
+
+def both_routes(args):
+ """The names each route delivers, once both have stopped producing new
ones."""
+ base_url = args.prometheus.rstrip("/")
+ check_targets(base_url, args.settle)
+ print(f"Waiting for both jobs to settle (up to {args.timeout}s)...",
file=sys.stderr)
+ return collect(base_url, args.timeout, args.poll, args.stable,
args.verbose)
+
+
+def command_parity(args):
+ scraped, pushed = both_routes(args)
+ only_scraped = scraped - pushed
+ only_pushed = pushed - scraped
+ known = {n: KNOWN_DIFFERENCES[n] for n in only_scraped | only_pushed if n
in KNOWN_DIFFERENCES}
+ only_scraped -= known.keys()
+ only_pushed -= known.keys()
+
+ print(f"{len(scraped)} names via {SCRAPE_JOB}, {len(pushed)} via
{OTLP_JOB}")
+ for name, reason in sorted(known.items()):
+ print(f" known difference: {name} — {reason}")
+ for name in sorted(only_scraped):
+ print(f" only via {SCRAPE_JOB}: {name}")
+ for name in sorted(only_pushed):
+ print(f" only via {OTLP_JOB}: {name}")
+
+ if only_scraped or only_pushed:
+ print(
+ "\nThe routes disagree. Either the Collector config in "
+ "../otel-collector-config.yaml needs a transform, or one was made
obsolete "
+ "by a Solr, SDK or Collector upgrade."
+ )
+ return 1
+ print("\nParity OK: both routes deliver the same metric names.")
+ return 0
+
+
+def command_list(args):
+ if args.otel:
+ for name in sorted(otel_metric_names(args.collector_native)):
+ print(name)
+ return 0
+ scraped, pushed = both_routes(args)
+ for name in sorted(scraped | pushed):
+ where = "both" if name in scraped and name in pushed else (
+ SCRAPE_JOB if name in scraped else OTLP_JOB
+ )
+ print(f"{where:<10} {name}")
+ return 0
+
+
+def main():
+ parser = argparse.ArgumentParser(
+ description=__doc__.splitlines()[0],
+ epilog="Run a subcommand with --help for its options.",
+ )
+ subcommands = parser.add_subparsers(dest="command", required=True)
+
+ parity = subcommands.add_parser("parity", help="compare the names both
routes deliver")
+ add_common_arguments(parity)
+ parity.set_defaults(run=command_parity)
+
+ listing = subcommands.add_parser("list", help="print metric names
alphabetically")
+ add_common_arguments(listing)
+ listing.add_argument(
+ "--otel",
+ action="store_true",
+ help="the OpenTelemetry names Solr pushes, before any Prometheus
naming",
+ )
+ listing.add_argument(
+ "--collector-native",
+ default="http://localhost:9465/metrics",
+ help="collector endpoint serving untranslated OpenTelemetry names",
+ )
+ listing.set_defaults(run=command_list)
+
+ args = parser.parse_args()
+ return args.run(args)
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/solr/monitoring/dev/otel-collector-native.yaml
b/solr/monitoring/dev/otel-collector-native.yaml
new file mode 100644
index 00000000000..065cbb17a35
--- /dev/null
+++ b/solr/monitoring/dev/otel-collector-native.yaml
@@ -0,0 +1,34 @@
+# 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.
+#
+# otel-collector-native.yaml — dev-stack overlay, merged onto the shipped
+# ../otel-collector-config.yaml by passing both to the collector with --config.
+# Kept out of the shipped file so that stays a lean example.
+#
+# Exposes the same metrics a second time with their OpenTelemetry names left
+# alone, so ./inspect-metrics.py list --otel can show what Solr actually
+# sends, before any Prometheus naming is applied.
+
+exporters:
+ prometheus/native:
+ endpoint: 0.0.0.0:9465
+ translation_strategy: NoTranslation
+
+service:
+ pipelines:
+ metrics/native:
+ receivers: [otlp]
+ processors: [batch]
+ exporters: [prometheus/native]
diff --git a/solr/monitoring/dev/prometheus/prometheus-local.yml
b/solr/monitoring/dev/prometheus/prometheus-local.yml
index b3935124c3f..478cebf6bb4 100644
--- a/solr/monitoring/dev/prometheus/prometheus-local.yml
+++ b/solr/monitoring/dev/prometheus/prometheus-local.yml
@@ -46,3 +46,19 @@ scrape_configs:
scrape_interval: 15s
static_configs:
- targets: ['host.docker.internal:8983']
+
+ # The same metrics after a round trip through the collector, under a
separate job so
+ # the shipped dashboard and alert rules keep matching the direct scrape
only. Needs your Solr started with
+ # SOLR_MODULES=opentelemetry SOLR_METRICS_OTLP_EXPORTER_ENABLED=true. Compare
+ # the two to check the collector config reproduces Solr's metric names; see
../../README.md
+ - job_name: solr-otlp
+ # honor_labels keeps the instance label the collector derives from Solr's
resource
+ # attributes; it also keeps the collector's job="solr", so force the job
back here,
+ # or both routes would land in the same job and every rule would match
twice.
+ honor_labels: true
+ metric_relabel_configs:
+ - target_label: job
+ replacement: solr-otlp
+ scrape_interval: 15s
+ static_configs:
+ - targets: ['otel-collector:9464']
diff --git a/solr/monitoring/dev/prometheus/prometheus.yml
b/solr/monitoring/dev/prometheus/prometheus.yml
index 821ce876be7..46ac69428f5 100644
--- a/solr/monitoring/dev/prometheus/prometheus.yml
+++ b/solr/monitoring/dev/prometheus/prometheus.yml
@@ -18,6 +18,9 @@
# Used by docker-compose.yml in this directory. The job name must match the
# mixin's solrSelector (job="solr" by default), or the generated dashboard and
# alert rules will not match any series.
+#
+# Both collection routes are scraped at once: the nodes directly, and the OTel
+# collector they push to. See ../../otel-collector-config.yaml.
global:
scrape_interval: 15s
@@ -41,3 +44,18 @@ scrape_configs:
scrape_interval: 15s
static_configs:
- targets: ['solr1:8983', 'solr2:8983']
+
+ # The same metrics after a round trip through the collector, under a
separate job so
+ # the shipped dashboard and alert rules keep matching the direct scrape
only. Compare
+ # the two to check the collector config reproduces Solr's metric names; see
../../README.md
+ - job_name: solr-otlp
+ # honor_labels keeps the instance label the collector derives from Solr's
resource
+ # attributes; it also keeps the collector's job="solr", so force the job
back here,
+ # or both routes would land in the same job and every rule would match
twice.
+ honor_labels: true
+ metric_relabel_configs:
+ - target_label: job
+ replacement: solr-otlp
+ scrape_interval: 15s
+ static_configs:
+ - targets: ['otel-collector:9464']
diff --git a/solr/monitoring/dev/stack.sh b/solr/monitoring/dev/stack.sh
index 3d6129faef0..a6a5b0340de 100755
--- a/solr/monitoring/dev/stack.sh
+++ b/solr/monitoring/dev/stack.sh
@@ -28,6 +28,9 @@
#
# In --local-solr mode Prometheus uses prometheus/prometheus-local.yml which
scrapes
# host.docker.internal:8983. Edit that file to add further nodes or change
the port.
+#
+# Prometheus scrapes both collection routes: the nodes directly as job "solr",
and the
+# OTel collector they push to as job "solr-otlp".
set -euo pipefail
@@ -92,7 +95,7 @@ if $LOCAL_MODE; then
export SOLR_URL="http://host.docker.internal:8983/solr"
fi
- SERVICES="prometheus grafana alertmanager"
+ SERVICES="prometheus grafana alertmanager otel-collector aspire-dashboard"
if $WITH_TRAFFICGEN; then
SERVICES="$SERVICES trafficgen"
fi
@@ -102,7 +105,10 @@ if $LOCAL_MODE; then
echo ""
echo "Monitoring stack started in local-Solr mode."
- echo "Prometheus is scraping your local Solr via host.docker.internal"
+ echo "Prometheus is scraping your local Solr via host.docker.internal, as
job 'solr'."
+ echo "For the 'solr-otlp' job too, start it with:"
+ echo " SOLR_MODULES=opentelemetry SOLR_METRICS_OTLP_EXPORTER_ENABLED=true
bin/solr start"
+ echo "(the collector listens on localhost:4318, Solr's default OTLP/HTTP
endpoint)"
if $WITH_TRAFFICGEN; then
echo "Traffic generator is running against: $SOLR_URL"
fi
@@ -111,6 +117,8 @@ if $LOCAL_MODE; then
echo " Grafana: http://localhost:3000 (view without login; admin/admin
to edit)"
echo " Prometheus: http://localhost:9090"
echo " Alertmanager: http://localhost:9093"
+ echo " Collector: http://localhost:9464/metrics (what Solr pushed; :9465
untranslated)"
+ echo " Aspire: http://localhost:18888 (raw view of pushed metrics and
traces)"
echo ""
echo "Tip: edit prometheus/prometheus-local.yml to add further nodes or
change the port."
else
@@ -125,6 +133,8 @@ else
echo " Grafana: http://localhost:3000 (view without login;
admin/admin to edit)"
echo " Prometheus: http://localhost:9090"
echo " Alertmanager: http://localhost:9093"
+ echo " Collector: http://localhost:9464/metrics (what Solr pushed;
:9465 untranslated)"
+ echo " Aspire: http://localhost:18888 (raw view of pushed metrics
and traces)"
echo ""
echo "Tip: Prometheus may show scrape errors for the first 30-60 seconds
while Solr starts."
fi
diff --git a/solr/monitoring/otel-collector-config.yaml
b/solr/monitoring/otel-collector-config.yaml
new file mode 100644
index 00000000000..f23ae814b6f
--- /dev/null
+++ b/solr/monitoring/otel-collector-config.yaml
@@ -0,0 +1,72 @@
+# 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.
+#
+# otel-collector-config.yaml — example OpenTelemetry Collector configuration
for Solr,
+# to copy and adapt. Not a production setup.
+#
+# Receives Solr's OTLP push and re-exposes the metrics in Prometheus format on
:9464,
+# under the same names /solr/admin/metrics produces, so the dashboard and
alert rules
+# in this directory work against either. Also forwards the untransformed
metrics and
+# traces as a raw firehose to any OTLP endpoint; drop the otlp/raw parts if
you need none.
+#
+# Requires the collector "contrib" distribution
(otel/opentelemetry-collector-contrib).
+
+receivers:
+ otlp:
+ protocols:
+ grpc:
+ endpoint: 0.0.0.0:4317
+ http:
+ endpoint: 0.0.0.0:4318
+
+processors:
+ transform:
+ metric_statements:
+ # Without SOLR-18594 Solr sends the SDK default, which becomes
job="unknown_service:java"
+ - context: resource
+ statements:
+ - set(attributes["service.name"], "solr") where
attributes["service.name"] == "unknown_service:java"
+ # Solr's endpoint adds no suffix for the dimensionless unit "1"; the
collector appends "_ratio"
+ - context: metric
+ statements:
+ - set(unit, "") where unit == "1"
+ batch: {}
+
+exporters:
+ prometheus:
+ endpoint: 0.0.0.0:9464
+ send_timestamps: true
+ enable_open_metrics: true
+ # Raw firehose; the dev stack points it at an Aspire Dashboard to view the
data as-is
+ otlp/raw:
+ endpoint: aspire-dashboard:18889
+ tls:
+ insecure: true
+
+service:
+ pipelines:
+ metrics:
+ receivers: [otlp]
+ processors: [transform, batch]
+ exporters: [prometheus]
+ # Untransformed copies for the raw firehose; remove both pipelines if not
using it.
+ metrics/raw:
+ receivers: [otlp]
+ processors: [batch]
+ exporters: [otlp/raw]
+ traces:
+ receivers: [otlp]
+ processors: [batch]
+ exporters: [otlp/raw]
diff --git
a/solr/solr-ref-guide/modules/deployment-guide/pages/metrics-reporting.adoc
b/solr/solr-ref-guide/modules/deployment-guide/pages/metrics-reporting.adoc
index d47dd9ce630..8f593c0b54a 100644
--- a/solr/solr-ref-guide/modules/deployment-guide/pages/metrics-reporting.adoc
+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/metrics-reporting.adoc
@@ -381,41 +381,18 @@ Endpoint to send OTLP metrics to using the HTTP protocol.
=== OpenTelemetry Collector setup
-The https://opentelemetry.io/docs/collector/[OpenTelemetry Collector] is a
powerful process that allows users to decouple their metrics pipeline and route
to their preferred backend. It natively supports metrics being pushed to it via
OTLP and/or scraping the `/metrics` Prometheus endpoint supported by Solr. You
can push both metrics and traces to the collector via OTLP as a single pipeline.
+The https://opentelemetry.io/docs/collector/[OpenTelemetry Collector]
decouples the metrics pipeline from the backend: it receives Solr's OTLP push
and can forward to any backend, or expose the metrics in Prometheus format for
scraping.
+Solr ships an example Collector configuration for the latter,
`solr/monitoring/otel-collector-config.yaml`, that reproduces the metric names
of the `/metrics` endpoint; see
xref:monitoring-with-prometheus-and-grafana.adoc#otlp-push[Monitoring Solr with
Prometheus and Grafana].
+Traces can go through the same Collector; see xref:opentelemetry.adoc[].
-A simple setup to route metrics from Solr -> OpenTelemetry Collector ->
Prometheus can be configured with the following OpenTelemetry Collector
configuration file:
-
-[source,plain]
-----
-receivers:
- otlp:
- protocols:
- grpc:
- endpoint: 0.0.0.0:4317
- http:
- endpoint: 0.0.0.0:4318
-
-exporters:
- prometheus:
- endpoint: 0.0.0.0:9464
- send_timestamps: true
- enable_open_metrics: true
-
-service:
- pipelines:
- metrics:
- receivers: [otlp]
- exporters: [prometheus]
-----
-
-You can then request the metrics in Prometheus format from the collector:
+With that configuration the metrics are available from the Collector in
Prometheus format:
[source,bash]
----
curl 'localhost:9464/metrics'
----
-Or request OpenMetrics format to also see exemplars by passing the Accept
header:
+Or in OpenMetrics format, which also includes exemplars:
[source,bash]
----
diff --git
a/solr/solr-ref-guide/modules/deployment-guide/pages/monitoring-with-prometheus-and-grafana.adoc
b/solr/solr-ref-guide/modules/deployment-guide/pages/monitoring-with-prometheus-and-grafana.adoc
index 3103c2d41cf..4a6d79d2e60 100644
---
a/solr/solr-ref-guide/modules/deployment-guide/pages/monitoring-with-prometheus-and-grafana.adoc
+++
b/solr/solr-ref-guide/modules/deployment-guide/pages/monitoring-with-prometheus-and-grafana.adoc
@@ -18,15 +18,16 @@
====
Solr 10 removed the `solr-exporter` process and renamed the metrics, so
dashboards and alert rules made for Solr 9 and earlier do not work.
-The alert rules below are current. The dashboard is still a placeholder; the
real one arrives in
https://issues.apache.org/jira/browse/SOLR-18534[SOLR-18534] and OTLP Collector
guidance in https://issues.apache.org/jira/browse/SOLR-18536[SOLR-18536].
+The alert rules below are current. The dashboard is still a placeholder; the
real one arrives in
https://issues.apache.org/jira/browse/SOLR-18534[SOLR-18534].
====
-Solr ships two monitoring artifacts in `solr/monitoring/`:
+Solr ships three monitoring artifacts in `solr/monitoring/`:
* `grafana-solr-dashboard.json` — a Grafana dashboard
* `prometheus-solr-alerts.yml` — a set of Prometheus alert rules
+* `otel-collector-config.yaml` — an example OpenTelemetry Collector
configuration, for the <<otlp-push,OTLP push>> option
-Import these into your own Prometheus + Grafana installation.
+Import the first two into your own Prometheus + Grafana installation.
Solr exposes all metrics natively, so no exporter process is required.
For the full list of available metrics see xref:metrics-reporting.adoc[].
@@ -73,9 +74,35 @@ If metrics collection is switched off for a node, both
endpoints answer `HTTP 51
[[otlp-push]]
=== Option 2: OTLP Push via OpenTelemetry Collector
-When Solr's xref:opentelemetry.adoc[OpenTelemetry module] is enabled, Solr can
push metrics (and traces) via OTLP to an
https://opentelemetry.io/docs/collector/[OpenTelemetry Collector], which can
forward them to Prometheus or to any other OTLP-compatible backend.
+With the xref:opentelemetry.adoc[`opentelemetry` module] enabled and
`solr.metrics.otlpExporterEnabled=true` on every node (see
xref:metrics-reporting.adoc#otlp[OTLP]), each node pushes its metrics to an
https://opentelemetry.io/docs/collector/[OpenTelemetry Collector], and
Prometheus scrapes the Collector instead of the nodes.
+The Collector can forward the same stream to any other OTLP-compatible backend
as well.
-NOTE: An example Collector configuration, and the labelling needed to make
both paths produce identical series, will be documented here as part of
https://issues.apache.org/jira/browse/SOLR-18536[SOLR-18536].
+`solr/monitoring/otel-collector-config.yaml` is an example to adapt, and needs
the `otel/opentelemetry-collector-contrib` distribution.
+It receives OTLP on `:4317` (gRPC) and `:4318` (HTTP) and serves Prometheus
format on `:9464`.
+Its `transform` processor is what keeps the metric names identical to Option
1, by undoing the `_ratio` suffix the Collector adds to dimensionless metrics
and supplying `service.name=solr` where Solr sends the SDK default.
+
+Then scrape the Collector:
+
+[source,yaml]
+----
+scrape_configs:
+ - job_name: solr
+ honor_labels: true # <1>
+ scrape_interval: 15s
+ static_configs:
+ - targets: ['otel-collector:9464']
+----
+<1> Keep the `job` and `instance` labels the Collector derives from Solr's
`service.name` and `service.instance.id` resource attributes, rather than
Prometheus overwriting them with the Collector's own address.
+
+The series Prometheus stores then carry the same metric names, types and label
keys as a direct scrape.
+
+[NOTE]
+====
+Until https://issues.apache.org/jira/browse/SOLR-18594[SOLR-18594] makes Solr
send `service.instance.id`, every pushed series carries the Collector's
`instance` label rather than the node's.
+Per-node panels therefore merge into one series, no `target_info` is produced,
and <<alert-rules,`SolrNodeDown`>> reports the fleet rather than naming a node
— `up{job="solr"}` describes the Collector here.
+====
+
+The Collector can also push into Prometheus rather than be scraped, through
its `prometheusremotewrite` or `otlphttp` exporter; the name parity above is
only verified for the scrape setup.
[[alert-rules]]
== Alert Rules
@@ -167,6 +194,8 @@ cd solr/monitoring/dev
Grafana is then on `http://localhost:3000`, opening directly on the
provisioned dashboard, with Prometheus on `:9090` and Alertmanager on `:9093`.
`./stack.sh --local-solr` skips the bundled Solr nodes and scrapes a Solr you
are already running.
+Prometheus scrapes both of the options above at once, the nodes as job `solr`
and the Collector the nodes push to as job `solr-otlp`, so they can be compared
side by side.
+The Collector also forwards what it receives to an Aspire Dashboard on
`:18888`, a raw view of the OTLP data.
[[distributed-tracing]]
== Metrics and Tracing Together