From dbd13a18f15f135ef4db4053e46733e256a34f97 Mon Sep 17 00:00:00 2001 From: Alberto Paro Date: Thu, 24 Jun 2021 23:30:54 +0200 Subject: [PATCH] Migrated to opendistro 1.0.0-rc1 --- .gitignore | 2 + README.md | 94 +++---------------- build.gradle | 18 ++-- gradle.properties | 12 +-- .../prometheus/PrometheusMetricsCatalog.java | 2 +- .../PrometheusMetricsCollector.java | 50 +++++----- .../prometheus/PrometheusSettings.java | 10 +- .../action/ClusterStatsData.java | 42 ++++----- .../action/NodePrometheusMetricsAction.java | 2 +- .../action/NodePrometheusMetricsRequest.java | 6 +- .../action/NodePrometheusMetricsResponse.java | 22 ++--- .../action/NodePrometheusRequestBuilder.java | 8 +- .../TransportNodePrometheusMetricsAction.java | 52 +++++----- .../indices/stats/PackageAccessHelper.java | 4 +- .../admin/indices/stats/package-info.java | 2 +- .../action/package-info.java | 2 +- .../prometheus/PrometheusExporterPlugin.java | 26 ++--- .../plugin/prometheus/package-info.java | 2 +- .../RestPrometheusMetricsAction.java | 22 ++--- .../rest/prometheus/package-info.java | 2 +- ...theusRestHandlerClientYamlTestSuiteIT.java | 12 +-- .../rest/package-info.java | 2 +- 22 files changed, 166 insertions(+), 228 deletions(-) rename src/main/java/org/{elasticsearch => opensearch}/action/ClusterStatsData.java (81%) rename src/main/java/org/{elasticsearch => opensearch}/action/NodePrometheusMetricsAction.java (96%) rename src/main/java/org/{elasticsearch => opensearch}/action/NodePrometheusMetricsRequest.java (87%) rename src/main/java/org/{elasticsearch => opensearch}/action/NodePrometheusMetricsResponse.java (79%) rename src/main/java/org/{elasticsearch => opensearch}/action/NodePrometheusRequestBuilder.java (77%) rename src/main/java/org/{elasticsearch => opensearch}/action/TransportNodePrometheusMetricsAction.java (83%) rename src/main/java/org/{elasticsearch => opensearch}/action/admin/indices/stats/PackageAccessHelper.java (91%) rename src/main/java/org/{elasticsearch => opensearch}/action/admin/indices/stats/package-info.java (92%) rename src/main/java/org/{elasticsearch => opensearch}/action/package-info.java (95%) rename src/main/java/org/{elasticsearch => opensearch}/plugin/prometheus/PrometheusExporterPlugin.java (77%) rename src/main/java/org/{elasticsearch => opensearch}/plugin/prometheus/package-info.java (93%) rename src/main/java/org/{elasticsearch => opensearch}/rest/prometheus/RestPrometheusMetricsAction.java (86%) rename src/main/java/org/{elasticsearch => opensearch}/rest/prometheus/package-info.java (94%) rename src/test/java/org/{elasticsearch => opensearch}/rest/PrometheusRestHandlerClientYamlTestSuiteIT.java (76%) rename src/test/java/org/{elasticsearch => opensearch}/rest/package-info.java (95%) diff --git a/.gitignore b/.gitignore index 0e107e1..a8e997d 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,5 @@ gradle-wrapper.properties # Mac .DS_Store +.metals/ +.vscode/ diff --git a/README.md b/README.md index fa266e6..177af69 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,7 @@ -![CI](https://github.com/vvanholl/elasticsearch-prometheus-exporter/workflows/CI/badge.svg?branch=master) +# Prometheus Exporter Plugin for OpenSearch -# Prometheus Exporter Plugin for Elasticsearch - -This is a builtin exporter from Elasticsearch to Prometheus. -It collects all relevant metrics and makes them available to Prometheus via the Elasticsearch REST API. +This is a builtin exporter from OpenSearch to Prometheus based on the code of Vincent Van Hollebeke and others at https://github.com/vvanholl/elasticsearch-prometheus-exporter . +It collects all relevant metrics and makes them available to Prometheus via the OpenSearch REST API. **Currently, the available metrics are:** @@ -19,54 +17,19 @@ It collects all relevant metrics and makes them available to Prometheus via the - File System - Circuit Breaker - Indices status -- Cluster settings (selected [disk allocation settings](https://www.elastic.co/guide/en/elasticsearch/reference/master/disk-allocator.html) only) +- Cluster settings ## Compatibility matrix -### Version 7.X - -| Elasticsearch | Plugin | Release date | -| -------------- | -------------- | ------------ | -| 7.13.2 | 7.13.2.0 | Jun 15, 2021 | -| 7.13.1 | 7.13.1.0 | Jun 12, 2021 | -| 7.13.0 | 7.13.0.0 | May 27, 2021 | -| 7.12.1 | 7.12.1.0 | May 01, 2021 | -| 7.12.0 | 7.12.0.0 | Apr 04, 2021 | -| 7.11.2 | 7.11.2.0 | Mar 20, 2021 | -| 7.11.1 | 7.11.1.0 | Feb 22, 2021 | -| 7.10.2 | 7.10.2.0 | Jan 24, 2021 | -| 7.10.1 | 7.10.1.0 | Dec 13, 2020 | -| 7.10.0 | 7.10.0.0 | Nov 15, 2020 | -| 7.9.3 | 7.9.3.0 | Oct 22, 2020 | -| 7.9.2 | 7.9.2.0 | Oct 04, 2020 | -| 7.9.1 | 7.9.1.0 | Sep 06, 2020 | -| 7.9.0 | 7.9.0.0 | Aug 18, 2020 | -| 7.8.1 | 7.8.1.0 | Aug 10, 2020 | -| 7.8.0 | 7.8.0.0 | Jun 22, 2020 | -| 7.7.1 | 7.7.1.0 | Jun 04, 2020 | -| 7.7.0 | 7.7.0.0 | May 14, 2020 | -| 7.6.2 | 7.6.2.0 | Apr 6, 2020 | -| 7.6.1 | 7.6.1.0 | Mar 30, 2020 | -| 7.6.0 | 7.6.0.0 | Feb 12, 2020 | -| 7.5.2 | 7.5.2.0 | Jan 25, 2020 | -| 7.5.1 | 7.5.1.0 | Jan 21, 2020 | -| 7.5.0 | 7.5.0.0 | Jan 16, 2020 | -| 7.4.2 | 7.4.2.0 | Jan 13, 2020 | -| 7.4.1 | 7.4.1.0 | Jan 13, 2020 | -| 7.4.0 | 7.4.0.0 | Jan 07, 2020 | -| 7.3.2 | 7.3.2.0 | Oct 05, 2019 | -| 7.3.1 | 7.3.1.0 | Sep 18, 2019 | -| 7.3.0 | 7.3.0.0 | Sep 17, 2019 | -| 7.2.1 | 7.2.1.0 | Jul 31, 2019 | -| 7.2.0 | 7.2.0.0 | Jul 12, 2019 | -| 7.1.1 | 7.1.1.0 | May 31, 2019 | -| 7.1.0 | 7.1.0.0 | May 23, 2019 | -| 7.0.1 | 7.0.1.0 | May 08, 2019 | -| 7.0.0 | 7.0.0.0 | Apr 11, 2019 | +### Versions + +| OpenSearch | Plugin | Release date | +| ----------- | -------------- | ------------ | +| 1.0.0-RC1 | 1.0.0-RC1 | Jun 24, 2021 | ## Install -`./bin/elasticsearch-plugin install -b https://github.com/vvanholl/elasticsearch-prometheus-exporter/releases/download/7.13.2.0/prometheus-exporter-7.13.2.0.zip` +`./bin/opensearch-plugin install -b https://github.com/aparo/opensearch-prometheus-exporter/releases/download/1.0.0-RC1/prometheus-exporter-1.0.0-RC1.zip` **Do not forget to restart the node after the installation!** @@ -87,11 +50,11 @@ To disable exporting cluster settings use: prometheus.cluster.settings: false ``` -These settings can be also [updated dynamically](https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html). +These settings can be also [updated dynamically](https://www.elastic.co/guide/en/opensearch/reference/master/cluster-update-settings.html). ## Uninstall -`./bin/elasticsearch-plugin remove prometheus-exporter` +`./bin/opensearch-plugin remove prometheus-exporter` Do not forget to restart the node after installation! @@ -99,7 +62,7 @@ Do not forget to restart the node after installation! Metrics are directly available at: - http://:9200/_prometheus/metrics + http://:9200/_prometheus/metrics As a sample result, you get: @@ -134,7 +97,7 @@ On your Prometheus servers, configure a new job as usual. For example, if you have a cluster of 3 nodes: ```YAML -- job_name: elasticsearch +- job_name: opensearch scrape_interval: 10s metrics_path: "/_prometheus/metrics" static_configs: @@ -148,34 +111,7 @@ Of course, you could use the service discovery service instead of a static confi Just keep in mind that `metrics_path` must be `/_prometheus/metrics`, otherwise Prometheus will find no metric. -## Project sources - -The Maven project site is available at [GitHub](https://github.com/vvanholl/elasticsearch-prometheus-exporter). - -## Testing - -Project contains [integration tests](src/test/resources/rest-api-spec) implemented using -[rest layer](https://github.com/elastic/elasticsearch/blob/master/TESTING.asciidoc#testing-the-rest-layer) -framework. - -To run everything similar to the GitHub Actions pipeline you can do: -``` -docker run -v $(pwd):/home/gradle gradle:7.0.2-jdk16 su gradle -c 'gradle check' -``` -NOTE: Please keep version in sync with .github/workflows/ci.yml - - -Complete test suite is run using: -``` -gradle clean check -``` - -To run individual test file use: -``` -gradle :integTest \ - -Dtests.class=org.elasticsearch.rest.PrometheusRestHandlerClientYamlTestSuiteIT \ - -Dtests.method="test {yaml=resthandler/20_metrics/Prometheus metrics can be pulled}" -``` +If you enable security in OpenSearch, remember to set up the credentials also in Prometheus configuration. ## Credits diff --git a/build.gradle b/build.gradle index 5cd9da6..6504728 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ buildscript { } dependencies { - classpath "org.elasticsearch.gradle:build-tools:${es_version}" + classpath "org.opensearch.gradle:build-tools:${es_version}" classpath group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0' classpath group: 'com.sun.xml.bind', name: 'jaxb-core', version: '2.3.0' classpath group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.3.0' @@ -27,9 +27,9 @@ plugins { apply plugin: 'java' apply plugin: 'idea' -apply plugin: 'elasticsearch.esplugin' -apply plugin: 'elasticsearch.rest-resources' -apply plugin: 'elasticsearch.testclusters' +apply plugin: 'opensearch.opensearchplugin' +apply plugin: 'opensearch.rest-resources' +apply plugin: 'opensearch.testclusters' // Uncomment if you want to use: System.out.println("Emergency!"); // Logs are found in build/testcluster/integTest-*/logs/ folder. @@ -43,7 +43,7 @@ licenseFile = rootProject.file('LICENSE.txt') noticeFile = rootProject.file('NOTICE.txt') // POM validation can be enabled -validateElasticPom.enabled = false +validatePom.enabled = false // No unit tests in this plugin test.enabled = false @@ -60,7 +60,7 @@ repositories { ext { versions = [ - "elasticsearch": es_version, + "opensearch": es_version, "prometheus" : "0.8.0", "log4j" : "2.11.1", "junit" : "4.12" @@ -71,14 +71,14 @@ configurations { runtime releaseJars { extendsFrom runtime - exclude group: "org.elasticsearch" + exclude group: "org.opensearch" exclude group: "com.fasterxml.jackson.core", module: "jackson-core" exclude group: "org.apache.logging.log4j" } } dependencies { - api "org.elasticsearch:elasticsearch:${versions.elasticsearch}" + api "org.opensearch:opensearch:${versions.opensearch}" api "io.prometheus:simpleclient:${versions.prometheus}" api "io.prometheus:simpleclient_common:${versions.prometheus}" api "org.apache.logging.log4j:log4j-api:${versions.log4j}" @@ -92,7 +92,7 @@ tasks.withType(JavaCompile) { options.compilerArgs << "-Xlint:unchecked,deprecation" } -esplugin { +opensearchplugin { licenseFile rootProject.file('LICENSE.txt') noticeFile rootProject.file('NOTICE.txt') name pluginName diff --git a/gradle.properties b/gradle.properties index c50df36..ae38de8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,11 +1,11 @@ -group = org.elasticsearch.plugin.prometheus +group = org.opensearch.plugin.prometheus -version = 7.13.2.1-SNAPSHOT +version = 1.0.0-rc1 pluginName = prometheus-exporter -pluginClassname = org.elasticsearch.plugin.prometheus.PrometheusExporterPlugin -pluginDescription = Export Elasticsearch metrics to Prometheus +pluginClassname = org.opensearch.plugin.prometheus.PrometheusExporterPlugin +pluginDescription = Export OpenSearch metrics to Prometheus github_token = secret -github_owner = vvanholl -github_repo = elasticsearch-prometheus-exporter +github_owner = aparo +github_repo = opensearch-prometheus-exporter diff --git a/src/main/java/org/compuscene/metrics/prometheus/PrometheusMetricsCatalog.java b/src/main/java/org/compuscene/metrics/prometheus/PrometheusMetricsCatalog.java index f4dd050..982118e 100644 --- a/src/main/java/org/compuscene/metrics/prometheus/PrometheusMetricsCatalog.java +++ b/src/main/java/org/compuscene/metrics/prometheus/PrometheusMetricsCatalog.java @@ -19,7 +19,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.elasticsearch.rest.prometheus.RestPrometheusMetricsAction; +import org.opensearch.rest.prometheus.RestPrometheusMetricsAction; import java.io.IOException; import java.io.StringWriter; diff --git a/src/main/java/org/compuscene/metrics/prometheus/PrometheusMetricsCollector.java b/src/main/java/org/compuscene/metrics/prometheus/PrometheusMetricsCollector.java index 4e0394c..edb9fe4 100644 --- a/src/main/java/org/compuscene/metrics/prometheus/PrometheusMetricsCollector.java +++ b/src/main/java/org/compuscene/metrics/prometheus/PrometheusMetricsCollector.java @@ -17,26 +17,26 @@ package org.compuscene.metrics.prometheus; -import org.elasticsearch.action.ClusterStatsData; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; -import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; -import org.elasticsearch.action.admin.indices.stats.CommonStats; -import org.elasticsearch.action.admin.indices.stats.IndexStats; -import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse; -import org.elasticsearch.cluster.health.ClusterIndexHealth; -import org.elasticsearch.cluster.node.DiscoveryNodeRole; -import org.elasticsearch.http.HttpStats; -import org.elasticsearch.indices.NodeIndicesStats; -import org.elasticsearch.indices.breaker.AllCircuitBreakerStats; -import org.elasticsearch.indices.breaker.CircuitBreakerStats; -import org.elasticsearch.ingest.IngestStats; -import org.elasticsearch.monitor.fs.FsInfo; -import org.elasticsearch.monitor.jvm.JvmStats; -import org.elasticsearch.monitor.os.OsStats; -import org.elasticsearch.monitor.process.ProcessStats; -import org.elasticsearch.script.ScriptStats; -import org.elasticsearch.threadpool.ThreadPoolStats; -import org.elasticsearch.transport.TransportStats; +import org.opensearch.action.ClusterStatsData; +import org.opensearch.action.admin.cluster.health.ClusterHealthResponse; +import org.opensearch.action.admin.cluster.node.stats.NodeStats; +import org.opensearch.action.admin.indices.stats.CommonStats; +import org.opensearch.action.admin.indices.stats.IndexStats; +import org.opensearch.action.admin.indices.stats.IndicesStatsResponse; +import org.opensearch.cluster.health.ClusterIndexHealth; +import org.opensearch.cluster.node.DiscoveryNodeRole; +import org.opensearch.http.HttpStats; +import org.opensearch.indices.NodeIndicesStats; +import org.opensearch.indices.breaker.AllCircuitBreakerStats; +import org.opensearch.indices.breaker.CircuitBreakerStats; +import org.opensearch.ingest.IngestStats; +import org.opensearch.monitor.fs.FsInfo; +import org.opensearch.monitor.jvm.JvmStats; +import org.opensearch.monitor.os.OsStats; +import org.opensearch.monitor.process.ProcessStats; +import org.opensearch.script.ScriptStats; +import org.opensearch.threadpool.ThreadPoolStats; +import org.opensearch.transport.TransportStats; import java.util.HashMap; import java.util.List; @@ -130,7 +130,7 @@ private void registerNodeMetrics() { private void updateNodeMetrics(NodeStats ns) { if (ns != null) { - // Plugins can introduce custom node roles from 7.3.0: https://github.com/elastic/elasticsearch/pull/43175 + // Plugins can introduce custom node roles from 7.3.0: https://github.com/elastic/opensearch/pull/43175 // TODO(lukas-vlcek): List of node roles can not be static but needs to be created dynamically. Map roles = new HashMap<>(); @@ -413,7 +413,7 @@ private void registerPerIndexMetrics() { catalog.registerClusterGauge("index_fielddata_evictions_count", "Count of evictions in field data cache", "index", "context"); // Percolator cache was removed in ES 5.x - // See https://github.com/elastic/elasticsearch/commit/80fee8666ff5dd61ba29b175857cf42ce3b9eab9 + // See https://github.com/elastic/opensearch/commit/80fee8666ff5dd61ba29b175857cf42ce3b9eab9 catalog.registerClusterGauge("index_completion_size_bytes", "Size of completion suggest statistics", "index", "context"); @@ -530,7 +530,7 @@ private void updatePerIndexContextMetrics(String indexName, String context, Comm catalog.setClusterGauge("index_fielddata_evictions_count", idx.getFieldData().getEvictions(), indexName, context); // Percolator cache was removed in ES 5.x - // See https://github.com/elastic/elasticsearch/commit/80fee8666ff5dd61ba29b175857cf42ce3b9eab9 + // See https://github.com/elastic/opensearch/commit/80fee8666ff5dd61ba29b175857cf42ce3b9eab9 catalog.setClusterGauge("index_completion_size_bytes", idx.getCompletion().getSizeInBytes(), indexName, context); @@ -902,8 +902,8 @@ private void registerESSettings() { private void updateESSettings(ClusterStatsData stats) { if (stats != null) { catalog.setClusterGauge("cluster_routing_allocation_disk_threshold_enabled", Boolean.TRUE.equals(stats.getThresholdEnabled()) ? 1 : 0); - // According to Elasticsearch documentation the following settings must be set either in pct or bytes size. - // Mixing is not allowed. We rely on Elasticsearch to do all necessary checks and we simply + // According to OpenSearch documentation the following settings must be set either in pct or bytes size. + // Mixing is not allowed. We rely on OpenSearch to do all necessary checks and we simply // output all those metrics that are not null. If this will lead to mixed metric then we do not // consider it our fault. if (stats.getDiskLowInBytes() != null) { catalog.setClusterGauge("cluster_routing_allocation_disk_watermark_low_bytes", stats.getDiskLowInBytes()); } diff --git a/src/main/java/org/compuscene/metrics/prometheus/PrometheusSettings.java b/src/main/java/org/compuscene/metrics/prometheus/PrometheusSettings.java index 69f59e0..3810ef1 100644 --- a/src/main/java/org/compuscene/metrics/prometheus/PrometheusSettings.java +++ b/src/main/java/org/compuscene/metrics/prometheus/PrometheusSettings.java @@ -17,20 +17,20 @@ package org.compuscene.metrics.prometheus; -import org.elasticsearch.common.settings.ClusterSettings; -import org.elasticsearch.common.settings.Setting; -import org.elasticsearch.common.settings.Settings; +import org.opensearch.common.settings.ClusterSettings; +import org.opensearch.common.settings.Setting; +import org.opensearch.common.settings.Settings; /** * A container to keep settings for prometheus up to date with cluster setting changes. * * In order to make the settings dynamically updatable we took some inspiration from implementation - * and use of DiskThresholdSettings class in Elasticsearch. + * and use of DiskThresholdSettings class in OpenSearch. */ public class PrometheusSettings { // These settings become part of cluster state available via HTTP at - // curl /_cluster/settings?include_defaults=true&filter_path=defaults.prometheus + // curl /_cluster/settings?include_defaults=true&filter_path=defaults.prometheus // It is important to keep it under reasonable namespace to avoid collision with // other plugins or future/commercial parts of Elastic Stack itself. // Namespace "prometheus" sounds like safe bet for now. diff --git a/src/main/java/org/elasticsearch/action/ClusterStatsData.java b/src/main/java/org/opensearch/action/ClusterStatsData.java similarity index 81% rename from src/main/java/org/elasticsearch/action/ClusterStatsData.java rename to src/main/java/org/opensearch/action/ClusterStatsData.java index 2e25f9c..c4a00a0 100644 --- a/src/main/java/org/elasticsearch/action/ClusterStatsData.java +++ b/src/main/java/org/opensearch/action/ClusterStatsData.java @@ -14,32 +14,32 @@ * limitations under the License. * */ -package org.elasticsearch.action; +package org.opensearch.action; -import static org.elasticsearch.cluster.routing.allocation.DiskThresholdSettings.*; +import static org.opensearch.cluster.routing.allocation.DiskThresholdSettings.*; -import org.elasticsearch.ElasticsearchParseException; -import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; -import org.elasticsearch.cluster.metadata.Metadata; -import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.settings.ClusterSettings; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.settings.SettingsException; -import org.elasticsearch.common.unit.RatioValue; +import org.opensearch.OpenSearchParseException; +import org.opensearch.action.admin.cluster.state.ClusterStateResponse; +import org.opensearch.cluster.metadata.Metadata; +import org.opensearch.common.Nullable; +import org.opensearch.common.io.stream.StreamInput; +import org.opensearch.common.io.stream.StreamOutput; +import org.opensearch.common.settings.ClusterSettings; +import org.opensearch.common.settings.Settings; +import org.opensearch.common.settings.SettingsException; +import org.opensearch.common.unit.RatioValue; import java.io.IOException; /** - * Selected settings from Elasticsearch cluster settings. + * Selected settings from OpenSearch cluster settings. * - * Disk-based shard allocation [1] settings play important role in how Elasticsearch decides where to allocate + * Disk-based shard allocation [1] settings play important role in how OpenSearch decides where to allocate * new shards or if existing shards are relocated to different nodes. The tricky part about these settings is * that they can be expressed either in percent or bytes value (they cannot be mixed) and they can be updated on the fly. * - * [1] https://www.elastic.co/guide/en/elasticsearch/reference/master/disk-allocator.html#disk-allocator + * [1] https://www.elastic.co/guide/en/opensearch/reference/master/disk-allocator.html#disk-allocator * * In order to make it easy for Prometheus to consume the data we expose these settings in both formats (pct and bytes) * and we do our best in determining if they are currently set as pct or bytes filling appropriate variables with data @@ -83,12 +83,12 @@ public ClusterStatsData(StreamInput in) throws IOException { ClusterStatsData(ClusterStateResponse clusterStateResponse, Settings settings, ClusterSettings clusterSettings) { Metadata m = clusterStateResponse.getState().getMetadata(); - // There are several layers of cluster settings in Elasticsearch each having different priority. + // There are several layers of cluster settings in OpenSearch each having different priority. // We need to traverse them from the top priority down to find relevant value of each setting. - // See https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html#_order_of_precedence + // See https://www.elastic.co/guide/en/opensearch/reference/master/cluster-update-settings.html#_order_of_precedence for (Settings s : new Settings[]{ // See: RestClusterGetSettingsAction#response - // or: https://github.com/elastic/elasticsearch/pull/33247/files + // or: https://github.com/elastic/opensearch/pull/33247/files // We do not filter the settings, but we use the clusterSettings.diff() // In the end we expose just a few selected settings ATM. m.transientSettings(), @@ -116,7 +116,7 @@ public ClusterStatsData(StreamInput in) throws IOException { * Try to extract and parse value from settings for given key. * First it tries to parse it as a RatioValue (pct) then as byte size value. * It assigns parsed value to corresponding argument references (passed via array hack). - * If parsing fails the method fires exception, however, this should not happen - we rely on Elasticsearch + * If parsing fails the method fires exception, however, this should not happen - we rely on OpenSearch * to already have parsed and validated these values before. Unless we screwed something up... */ private void parseValue(Settings s, String key, Long[] bytesPointer, Double[] pctPointer) { @@ -124,11 +124,11 @@ private void parseValue(Settings s, String key, Long[] bytesPointer, Double[] pc if (value != null && pctPointer[0] == null) { try { pctPointer[0] = RatioValue.parseRatioValue(s.get(key, null)).getAsPercent(); - } catch (SettingsException | ElasticsearchParseException | NullPointerException e1) { + } catch (SettingsException | OpenSearchParseException | NullPointerException e1) { if (bytesPointer[0] == null) { try { bytesPointer[0] = s.getAsBytesSize(key, null).getBytes(); - } catch (SettingsException | ElasticsearchParseException | NullPointerException e2) { + } catch (SettingsException | OpenSearchParseException | NullPointerException e2) { // TODO(lvlcek): log.debug("This went wrong, but 'Keep Calm and Carry On'") // We should avoid using logs in this class (due to perf impact), instead we should // consider moving this logic to some static helper class/method going forward. diff --git a/src/main/java/org/elasticsearch/action/NodePrometheusMetricsAction.java b/src/main/java/org/opensearch/action/NodePrometheusMetricsAction.java similarity index 96% rename from src/main/java/org/elasticsearch/action/NodePrometheusMetricsAction.java rename to src/main/java/org/opensearch/action/NodePrometheusMetricsAction.java index 0be98fd..29490a7 100644 --- a/src/main/java/org/elasticsearch/action/NodePrometheusMetricsAction.java +++ b/src/main/java/org/opensearch/action/NodePrometheusMetricsAction.java @@ -14,7 +14,7 @@ * limitations under the License. * */ -package org.elasticsearch.action; +package org.opensearch.action; /** * Action class for Prometheus Exporter plugin. diff --git a/src/main/java/org/elasticsearch/action/NodePrometheusMetricsRequest.java b/src/main/java/org/opensearch/action/NodePrometheusMetricsRequest.java similarity index 87% rename from src/main/java/org/elasticsearch/action/NodePrometheusMetricsRequest.java rename to src/main/java/org/opensearch/action/NodePrometheusMetricsRequest.java index dc3aca6..0806ace 100644 --- a/src/main/java/org/elasticsearch/action/NodePrometheusMetricsRequest.java +++ b/src/main/java/org/opensearch/action/NodePrometheusMetricsRequest.java @@ -15,10 +15,10 @@ * */ -package org.elasticsearch.action; +package org.opensearch.action; -import org.elasticsearch.action.support.master.MasterNodeReadRequest; -import org.elasticsearch.common.io.stream.StreamInput; +import org.opensearch.action.support.master.MasterNodeReadRequest; +import org.opensearch.common.io.stream.StreamInput; import java.io.IOException; diff --git a/src/main/java/org/elasticsearch/action/NodePrometheusMetricsResponse.java b/src/main/java/org/opensearch/action/NodePrometheusMetricsResponse.java similarity index 79% rename from src/main/java/org/elasticsearch/action/NodePrometheusMetricsResponse.java rename to src/main/java/org/opensearch/action/NodePrometheusMetricsResponse.java index b75205f..5766af5 100644 --- a/src/main/java/org/elasticsearch/action/NodePrometheusMetricsResponse.java +++ b/src/main/java/org/opensearch/action/NodePrometheusMetricsResponse.java @@ -15,18 +15,18 @@ * */ -package org.elasticsearch.action; +package org.opensearch.action; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; -import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; -import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; -import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse; -import org.elasticsearch.action.admin.indices.stats.PackageAccessHelper; -import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.settings.ClusterSettings; -import org.elasticsearch.common.settings.Settings; +import org.opensearch.action.admin.cluster.health.ClusterHealthResponse; +import org.opensearch.action.admin.cluster.node.stats.NodeStats; +import org.opensearch.action.admin.cluster.state.ClusterStateResponse; +import org.opensearch.action.admin.indices.stats.IndicesStatsResponse; +import org.opensearch.action.admin.indices.stats.PackageAccessHelper; +import org.opensearch.common.Nullable; +import org.opensearch.common.io.stream.StreamInput; +import org.opensearch.common.io.stream.StreamOutput; +import org.opensearch.common.settings.ClusterSettings; +import org.opensearch.common.settings.Settings; import java.io.IOException; diff --git a/src/main/java/org/elasticsearch/action/NodePrometheusRequestBuilder.java b/src/main/java/org/opensearch/action/NodePrometheusRequestBuilder.java similarity index 77% rename from src/main/java/org/elasticsearch/action/NodePrometheusRequestBuilder.java rename to src/main/java/org/opensearch/action/NodePrometheusRequestBuilder.java index c82cac5d..640250e 100644 --- a/src/main/java/org/elasticsearch/action/NodePrometheusRequestBuilder.java +++ b/src/main/java/org/opensearch/action/NodePrometheusRequestBuilder.java @@ -15,17 +15,17 @@ * */ -package org.elasticsearch.action; +package org.opensearch.action; -import org.elasticsearch.action.support.master.MasterNodeReadOperationRequestBuilder; -import org.elasticsearch.client.ElasticsearchClient; +import org.opensearch.action.support.master.MasterNodeReadOperationRequestBuilder; +import org.opensearch.client.OpenSearchClient; /** * Request builder class for Prometheus Exporter plugin. */ public class NodePrometheusRequestBuilder extends MasterNodeReadOperationRequestBuilder { - public NodePrometheusRequestBuilder(ElasticsearchClient client, NodePrometheusMetricsAction action) { + public NodePrometheusRequestBuilder(OpenSearchClient client, NodePrometheusMetricsAction action) { super(client, action, new NodePrometheusMetricsRequest().local(true)); } } diff --git a/src/main/java/org/elasticsearch/action/TransportNodePrometheusMetricsAction.java b/src/main/java/org/opensearch/action/TransportNodePrometheusMetricsAction.java similarity index 83% rename from src/main/java/org/elasticsearch/action/TransportNodePrometheusMetricsAction.java rename to src/main/java/org/opensearch/action/TransportNodePrometheusMetricsAction.java index 270adc6..58b99ff 100644 --- a/src/main/java/org/elasticsearch/action/TransportNodePrometheusMetricsAction.java +++ b/src/main/java/org/opensearch/action/TransportNodePrometheusMetricsAction.java @@ -15,30 +15,30 @@ * */ -package org.elasticsearch.action; +package org.opensearch.action; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.compuscene.metrics.prometheus.PrometheusSettings; -import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; -import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest; -import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse; -import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest; -import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; -import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequest; -import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse; -import org.elasticsearch.action.support.ActionFilters; -import org.elasticsearch.action.support.HandledTransportAction; -import org.elasticsearch.client.Client; -import org.elasticsearch.client.Requests; -import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.ClusterSettings; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.tasks.Task; -import org.elasticsearch.transport.TransportService; +import org.opensearch.OpenSearchException; +import org.opensearch.action.admin.cluster.health.ClusterHealthRequest; +import org.opensearch.action.admin.cluster.health.ClusterHealthResponse; +import org.opensearch.action.admin.cluster.node.stats.NodesStatsRequest; +import org.opensearch.action.admin.cluster.node.stats.NodesStatsResponse; +import org.opensearch.action.admin.cluster.state.ClusterStateRequest; +import org.opensearch.action.admin.cluster.state.ClusterStateResponse; +import org.opensearch.action.admin.indices.stats.IndicesStatsRequest; +import org.opensearch.action.admin.indices.stats.IndicesStatsResponse; +import org.opensearch.action.support.ActionFilters; +import org.opensearch.action.support.HandledTransportAction; +import org.opensearch.client.Client; +import org.opensearch.client.Requests; +import org.opensearch.common.Nullable; +import org.opensearch.common.inject.Inject; +import org.opensearch.common.settings.ClusterSettings; +import org.opensearch.common.settings.Settings; +import org.opensearch.tasks.Task; +import org.opensearch.transport.TransportService; /** * Transport action class for Prometheus Exporter plugin. @@ -107,7 +107,7 @@ private AsyncAction(ActionListener listener) { // Note: when using ClusterHealthRequest in Java, it pulls data at the shards level, according to ES source // code comment this is "so it is backward compatible with the transport client behaviour". // hence we are explicit about ClusterHealthRequest level and do not rely on defaults. - // https://www.elastic.co/guide/en/elasticsearch/reference/6.4/cluster-health.html#request-params + // https://www.elastic.co/guide/en/opensearch/reference/6.4/cluster-health.html#request-params this.healthRequest = Requests.clusterHealthRequest().local(true); this.healthRequest.level(ClusterHealthRequest.Level.SHARDS); @@ -117,7 +117,7 @@ private AsyncAction(ActionListener listener) { // it is broad-casted to all cluster nodes. this.indicesStatsRequest = isPrometheusIndices ? new IndicesStatsRequest() : null; - // Cluster settings are get via ClusterStateRequest (see elasticsearch RestClusterGetSettingsAction for details) + // Cluster settings are get via ClusterStateRequest (see opensearch RestClusterGetSettingsAction for details) // We prefer to send it to master node (hence local=false; it should be set by default but we want to be sure). this.clusterStateRequest = isPrometheusClusterSettings ? Requests.clusterStateRequest() .clear().metadata(true).local(false) : null; @@ -138,7 +138,7 @@ public void onResponse(ClusterStateResponse response) { @Override public void onFailure(Exception e) { - listener.onFailure(new ElasticsearchException("Cluster state request failed", e)); + listener.onFailure(new OpenSearchException("Cluster state request failed", e)); } }; @@ -156,7 +156,7 @@ public void onResponse(IndicesStatsResponse response) { @Override public void onFailure(Exception e) { - listener.onFailure(new ElasticsearchException("Indices stats request failed", e)); + listener.onFailure(new OpenSearchException("Indices stats request failed", e)); } }; @@ -174,7 +174,7 @@ public void onResponse(NodesStatsResponse nodeStats) { @Override public void onFailure(Exception e) { - listener.onFailure(new ElasticsearchException("Nodes stats request failed", e)); + listener.onFailure(new OpenSearchException("Nodes stats request failed", e)); } }; @@ -188,7 +188,7 @@ public void onResponse(ClusterHealthResponse response) { @Override public void onFailure(Exception e) { - listener.onFailure(new ElasticsearchException("Cluster health request failed", e)); + listener.onFailure(new OpenSearchException("Cluster health request failed", e)); } }; diff --git a/src/main/java/org/elasticsearch/action/admin/indices/stats/PackageAccessHelper.java b/src/main/java/org/opensearch/action/admin/indices/stats/PackageAccessHelper.java similarity index 91% rename from src/main/java/org/elasticsearch/action/admin/indices/stats/PackageAccessHelper.java rename to src/main/java/org/opensearch/action/admin/indices/stats/PackageAccessHelper.java index 8ad9eb5..8edb16a 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/stats/PackageAccessHelper.java +++ b/src/main/java/org/opensearch/action/admin/indices/stats/PackageAccessHelper.java @@ -14,9 +14,9 @@ * limitations under the License. * */ -package org.elasticsearch.action.admin.indices.stats; +package org.opensearch.action.admin.indices.stats; -import org.elasticsearch.common.io.stream.StreamInput; +import org.opensearch.common.io.stream.StreamInput; import java.io.IOException; diff --git a/src/main/java/org/elasticsearch/action/admin/indices/stats/package-info.java b/src/main/java/org/opensearch/action/admin/indices/stats/package-info.java similarity index 92% rename from src/main/java/org/elasticsearch/action/admin/indices/stats/package-info.java rename to src/main/java/org/opensearch/action/admin/indices/stats/package-info.java index 22e0f1d..5804a6c 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/stats/package-info.java +++ b/src/main/java/org/opensearch/action/admin/indices/stats/package-info.java @@ -18,4 +18,4 @@ /** * Utility classes. */ -package org.elasticsearch.action.admin.indices.stats; +package org.opensearch.action.admin.indices.stats; diff --git a/src/main/java/org/elasticsearch/action/package-info.java b/src/main/java/org/opensearch/action/package-info.java similarity index 95% rename from src/main/java/org/elasticsearch/action/package-info.java rename to src/main/java/org/opensearch/action/package-info.java index f5287dd..612d2ba 100644 --- a/src/main/java/org/elasticsearch/action/package-info.java +++ b/src/main/java/org/opensearch/action/package-info.java @@ -18,4 +18,4 @@ /** * Classes used for Prometheus Exporter plugin transport actions. */ -package org.elasticsearch.action; +package org.opensearch.action; diff --git a/src/main/java/org/elasticsearch/plugin/prometheus/PrometheusExporterPlugin.java b/src/main/java/org/opensearch/plugin/prometheus/PrometheusExporterPlugin.java similarity index 77% rename from src/main/java/org/elasticsearch/plugin/prometheus/PrometheusExporterPlugin.java rename to src/main/java/org/opensearch/plugin/prometheus/PrometheusExporterPlugin.java index d9e0ae5..b4aa218 100644 --- a/src/main/java/org/elasticsearch/plugin/prometheus/PrometheusExporterPlugin.java +++ b/src/main/java/org/opensearch/plugin/prometheus/PrometheusExporterPlugin.java @@ -15,25 +15,25 @@ * */ -package org.elasticsearch.plugin.prometheus; +package org.opensearch.plugin.prometheus; import static java.util.Collections.singletonList; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.compuscene.metrics.prometheus.PrometheusSettings; -import org.elasticsearch.action.ActionRequest; -import org.elasticsearch.action.ActionResponse; -import org.elasticsearch.action.NodePrometheusMetricsAction; -import org.elasticsearch.action.TransportNodePrometheusMetricsAction; -import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; -import org.elasticsearch.cluster.node.DiscoveryNodes; -import org.elasticsearch.common.settings.*; -import org.elasticsearch.plugins.ActionPlugin; -import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestHandler; -import org.elasticsearch.rest.prometheus.RestPrometheusMetricsAction; +import org.opensearch.action.ActionRequest; +import org.opensearch.action.ActionResponse; +import org.opensearch.action.NodePrometheusMetricsAction; +import org.opensearch.action.TransportNodePrometheusMetricsAction; +import org.opensearch.cluster.metadata.IndexNameExpressionResolver; +import org.opensearch.cluster.node.DiscoveryNodes; +import org.opensearch.common.settings.*; +import org.opensearch.plugins.ActionPlugin; +import org.opensearch.plugins.Plugin; +import org.opensearch.rest.RestController; +import org.opensearch.rest.RestHandler; +import org.opensearch.rest.prometheus.RestPrometheusMetricsAction; import java.util.Arrays; import java.util.Collections; diff --git a/src/main/java/org/elasticsearch/plugin/prometheus/package-info.java b/src/main/java/org/opensearch/plugin/prometheus/package-info.java similarity index 93% rename from src/main/java/org/elasticsearch/plugin/prometheus/package-info.java rename to src/main/java/org/opensearch/plugin/prometheus/package-info.java index 448e41b..82dbf53 100644 --- a/src/main/java/org/elasticsearch/plugin/prometheus/package-info.java +++ b/src/main/java/org/opensearch/plugin/prometheus/package-info.java @@ -18,4 +18,4 @@ /** * Prometheus Exporter plugin main classes. */ -package org.elasticsearch.plugin.prometheus; +package org.opensearch.plugin.prometheus; diff --git a/src/main/java/org/elasticsearch/rest/prometheus/RestPrometheusMetricsAction.java b/src/main/java/org/opensearch/rest/prometheus/RestPrometheusMetricsAction.java similarity index 86% rename from src/main/java/org/elasticsearch/rest/prometheus/RestPrometheusMetricsAction.java rename to src/main/java/org/opensearch/rest/prometheus/RestPrometheusMetricsAction.java index 8c4d2c4..a902d7a 100644 --- a/src/main/java/org/elasticsearch/rest/prometheus/RestPrometheusMetricsAction.java +++ b/src/main/java/org/opensearch/rest/prometheus/RestPrometheusMetricsAction.java @@ -15,24 +15,24 @@ * */ -package org.elasticsearch.rest.prometheus; +package org.opensearch.rest.prometheus; -import static org.elasticsearch.action.NodePrometheusMetricsAction.INSTANCE; -import static org.elasticsearch.rest.RestRequest.Method.GET; +import static org.opensearch.action.NodePrometheusMetricsAction.INSTANCE; +import static org.opensearch.rest.RestRequest.Method.GET; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.compuscene.metrics.prometheus.PrometheusMetricsCatalog; import org.compuscene.metrics.prometheus.PrometheusMetricsCollector; import org.compuscene.metrics.prometheus.PrometheusSettings; -import org.elasticsearch.action.NodePrometheusMetricsRequest; -import org.elasticsearch.action.NodePrometheusMetricsResponse; -import org.elasticsearch.client.node.NodeClient; -import org.elasticsearch.common.network.NetworkAddress; -import org.elasticsearch.common.settings.ClusterSettings; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.rest.*; -import org.elasticsearch.rest.action.RestResponseListener; +import org.opensearch.action.NodePrometheusMetricsRequest; +import org.opensearch.action.NodePrometheusMetricsResponse; +import org.opensearch.client.node.NodeClient; +import org.opensearch.common.network.NetworkAddress; +import org.opensearch.common.settings.ClusterSettings; +import org.opensearch.common.settings.Settings; +import org.opensearch.rest.*; +import org.opensearch.rest.action.RestResponseListener; import java.util.List; import java.util.Locale; diff --git a/src/main/java/org/elasticsearch/rest/prometheus/package-info.java b/src/main/java/org/opensearch/rest/prometheus/package-info.java similarity index 94% rename from src/main/java/org/elasticsearch/rest/prometheus/package-info.java rename to src/main/java/org/opensearch/rest/prometheus/package-info.java index c4fb009..bdbb452 100644 --- a/src/main/java/org/elasticsearch/rest/prometheus/package-info.java +++ b/src/main/java/org/opensearch/rest/prometheus/package-info.java @@ -18,4 +18,4 @@ /** * Classes used for Prometheus Exporter plugin REST actions. */ -package org.elasticsearch.rest.prometheus; +package org.opensearch.rest.prometheus; diff --git a/src/test/java/org/elasticsearch/rest/PrometheusRestHandlerClientYamlTestSuiteIT.java b/src/test/java/org/opensearch/rest/PrometheusRestHandlerClientYamlTestSuiteIT.java similarity index 76% rename from src/test/java/org/elasticsearch/rest/PrometheusRestHandlerClientYamlTestSuiteIT.java rename to src/test/java/org/opensearch/rest/PrometheusRestHandlerClientYamlTestSuiteIT.java index d0647ab..592101e 100644 --- a/src/test/java/org/elasticsearch/rest/PrometheusRestHandlerClientYamlTestSuiteIT.java +++ b/src/test/java/org/opensearch/rest/PrometheusRestHandlerClientYamlTestSuiteIT.java @@ -15,17 +15,17 @@ * */ -package org.elasticsearch.rest; +package org.opensearch.rest; import com.carrotsearch.randomizedtesting.annotations.Name; import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; -import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; -import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; +import org.opensearch.test.rest.yaml.ClientYamlTestCandidate; +import org.opensearch.test.rest.yaml.OpenSearchClientYamlSuiteTestCase; /** - * Needed class to enable esplugin rest api tests. + * Needed class to enable opensearchplugin rest api tests. */ -public class PrometheusRestHandlerClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase { +public class PrometheusRestHandlerClientYamlTestSuiteIT extends OpenSearchClientYamlSuiteTestCase { public PrometheusRestHandlerClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) { super(testCandidate); @@ -33,6 +33,6 @@ public PrometheusRestHandlerClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCa @ParametersFactory public static Iterable parameters() throws Exception { - return ESClientYamlSuiteTestCase.createParameters(); + return OpenSearchClientYamlSuiteTestCase.createParameters(); } } diff --git a/src/test/java/org/elasticsearch/rest/package-info.java b/src/test/java/org/opensearch/rest/package-info.java similarity index 95% rename from src/test/java/org/elasticsearch/rest/package-info.java rename to src/test/java/org/opensearch/rest/package-info.java index ef518de..7c9967b 100644 --- a/src/test/java/org/elasticsearch/rest/package-info.java +++ b/src/test/java/org/opensearch/rest/package-info.java @@ -18,4 +18,4 @@ /** * Classes used for testing. */ -package org.elasticsearch.rest; +package org.opensearch.rest;