Skip to main content

OpenSearch

Monitor OpenSearch cluster health, indexing throughput, search latency, and JVM usage using the prometheus-exporter plugin. Keep your search infrastructure observable alongside the rest of your stack in xScaler.

Pattern: OpenSearch prometheus-exporter plugin → Prometheus scrape → xScaler remote_write


Prerequisites

  • OpenSearch 1.0 or later
  • prometheus-exporter plugin installed on each node
  • xScaler tenant credentials (token + tenant ID)

Option A — Prometheus Exporter

Install the prometheus-exporter plugin on each OpenSearch node, then restart the service:

bin/opensearch-plugin install prometheus-exporter
# Restart OpenSearch after installation
sudo systemctl restart opensearch

OpenSearch will now expose metrics at :9200/_prometheus/metrics. Configure Prometheus to scrape and remote_write:

scrape_configs:
- job_name: opensearch
metrics_path: /_prometheus/metrics
static_configs:
- targets: ["localhost:9200"]

remote_write:
- url: https://euw1-01.m.xscalerlabs.com/api/v1/push
authorization:
type: Bearer
credentials: <token>
headers:
X-Scope-OrgID: "<tenant-id>"

Option B — Grafana Alloy

prometheus.scrape "opensearch" {
targets = [{
"__address__" = "localhost:9200",
"__metrics_path__" = "/_prometheus/metrics",
}]
forward_to = [prometheus.remote_write.xscaler.receiver]
}

prometheus.remote_write "xscaler" {
endpoint {
url = "https://euw1-01.m.xscalerlabs.com/api/v1/push"
authorization {
type = "Bearer"
credentials = "<token>"
}
headers = { "X-Scope-OrgID" = "<tenant-id>" }
}
}

Option C — OpenTelemetry Collector

receivers:
elasticsearch:
endpoint: http://localhost:9200
username: admin
password: <password>
collection_interval: 30s

processors:
batch: {}

exporters:
otlphttp/xscaler:
endpoint: https://euw1-01.m.xscalerlabs.com
headers:
Authorization: "Bearer <token>"
X-Scope-OrgID: "<tenant-id>"
compression: gzip

service:
pipelines:
metrics:
receivers: [elasticsearch]
processors: [batch]
exporters: [otlphttp/xscaler]

Logs

Collect OpenSearch server and slow log files. Add the following to your Alloy config:

local.file_match "opensearch_logs" {
path_targets = [{
__address__ = "localhost",
__path__ = "/var/log/opensearch/*.log",
instance = constants.hostname,
job = "integrations/opensearch",
}]
}

loki.source.file "opensearch_logs" {
targets = local.file_match.opensearch_logs.targets
forward_to = [loki.write.xscaler.receiver]
}

loki.write "xscaler" {
endpoint {
url = "https://euw1-01.l.xscalerlabs.com/api/v1/logs/push"

http_client_config {
authorization {
type = "Bearer"
credentials = env("XSCALER_TOKEN")
}
}

headers = { "X-Scope-OrgID" = env("XSCALER_TENANT_ID") }
}
}

Key metrics

MetricDescription
opensearch_cluster_statusCluster health status (0 = green, 1 = yellow, 2 = red)
opensearch_indices_docs_countTotal number of documents across all indices
opensearch_indices_store_size_bytesTotal on-disk size of all indices in bytes
opensearch_jvm_mem_heap_used_percentJVM heap memory used as a percentage of the configured maximum
opensearch_thread_pool_queue_countNumber of tasks queued in each thread pool
opensearch_search_query_time_secondsCumulative time spent executing search queries