Add Remote Info to data collection to monitor remote cluster connections - #1148
Add Remote Info to data collection to monitor remote cluster connections#1148rtkkroland wants to merge 2 commits into
Conversation
Signed-off-by: rtkkroland <ken.roland@arcticwolf.com>
3cc56ff to
dfb15d4
Compare
|
@sysadmind Moved to this new PR with all new code instead of dealing with #1099 which you were right and was based off old code. |
|
Would like to see this make it into a release |
|
It still looks like there are merge conflicts. Can you please resolve those so that I can do a review? |
Signed-off-by: Ken Roland <ken.roland@arcticwolf.com>
There was a problem hiding this comment.
Pull request overview
Adds a new collector to export Elasticsearch cross-cluster “remote info” connection stats (/_remote/info), enabling monitoring of remote cluster connectivity/connection counts, and resolves a metric name collision observed when running both indices and node-related collectors.
Changes:
- Introduces a new
collector.remote-infocollector that scrapes/_remote/infoand exports per-remote-cluster connection metrics. - Adds fixtures and unit tests for remote info across multiple ES versions (and empty response).
- Fixes a metric namespace/name collision by moving
indexing_is_throttledfromelasticsearch_indices_*toelasticsearch_index_stats_*in the indices collector (and updates tests accordingly).
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents the new collector.remote-info flag and required privileges; tidies related flag rows. |
| metrics.md | Adds the new remote info metrics to the metrics catalog. |
| fixtures/remote_info/empty.json | Fixture for empty /_remote/info response. |
| fixtures/remote_info/8.0.0.json | Fixture for ES 8.x-style remote info payload. |
| fixtures/remote_info/7.15.0.json | Fixture for ES 7.15 remote info payload with multiple remotes. |
| collector/remote_info.go | New collector implementation for /_remote/info and metric descriptors. |
| collector/remote_info_test.go | Tests collector output against fixtures and error scenarios. |
| collector/indices.go | Renames one metric to index_stats namespace to avoid collisions. |
| collector/indices_test.go | Updates expected output to match renamed metric. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Remote Info | ||
| for remoteCluster, remoteInfo := range rir { | ||
| for _, metric := range remoteInfoMetrics { | ||
| ch <- prometheus.MustNewConstMetric( | ||
| metric.Desc, | ||
| metric.Type, | ||
| metric.Value(remoteInfo), | ||
| metric.Labels(remoteCluster)..., | ||
| ) | ||
| } | ||
| } |
| func TestRemoteInfoError(t *testing.T) { | ||
| // Test error handling when endpoint is unavailable | ||
| ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| http.Error(w, "Internal Server Error", http.StatusInternalServerError) | ||
| })) | ||
| defer ts.Close() | ||
|
|
||
| u, err := url.Parse(ts.URL) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
||
| c, err := NewRemoteInfo(promslog.NewNopLogger(), u, http.DefaultClient) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
||
| expected := `` | ||
|
|
||
| if err := testutil.CollectAndCompare(wrapCollector{c}, strings.NewReader(expected)); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| } | ||
|
|
||
| func TestRemoteInfoJSONParseError(t *testing.T) { | ||
| // Test JSON parse error handling | ||
| ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| w.Write([]byte("invalid json")) | ||
| })) | ||
| defer ts.Close() | ||
|
|
||
| u, err := url.Parse(ts.URL) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
||
| c, err := NewRemoteInfo(promslog.NewNopLogger(), u, http.DefaultClient) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
||
| expected := `` | ||
|
|
||
| if err := testutil.CollectAndCompare(wrapCollector{c}, strings.NewReader(expected)); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| } |
|
@sysadmind Ready to go? |
Resolves #1128
Replaces #1099
Collect remote info from a cluster set up for cross-cluster search. Allows verification of number of connections from remotes.
NOTE: When running with:
elasticsearch_exporter --es.uri=https://localhost:9200 --es.ssl-skip-verify --es.indices --collector.snapshots --es.shards --collector.data-stream --es.timeout=60s --es.all --log.format=json --web.listen-address=:9114 --web.telemetry-path=/metricsI was getting a Panic about the duplicated metric with varying help and labels. Changing theindicestoindex_statsresolved it, but not sure if it was preferred to match the labels and help instead.