Skip to content

Commit dbd13a1

Browse files
committed
Migrated to opendistro 1.0.0-rc1
1 parent ff86a44 commit dbd13a1

22 files changed

+166
-228
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ gradle-wrapper.properties
2121

2222
# Mac
2323
.DS_Store
24+
.metals/
25+
.vscode/

README.md

+15-79
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
![CI](https://github.com/vvanholl/elasticsearch-prometheus-exporter/workflows/CI/badge.svg?branch=master)
1+
# Prometheus Exporter Plugin for OpenSearch
22

3-
# Prometheus Exporter Plugin for Elasticsearch
4-
5-
This is a builtin exporter from Elasticsearch to Prometheus.
6-
It collects all relevant metrics and makes them available to Prometheus via the Elasticsearch REST API.
3+
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 .
4+
It collects all relevant metrics and makes them available to Prometheus via the OpenSearch REST API.
75

86
**Currently, the available metrics are:**
97

@@ -19,54 +17,19 @@ It collects all relevant metrics and makes them available to Prometheus via the
1917
- File System
2018
- Circuit Breaker
2119
- Indices status
22-
- Cluster settings (selected [disk allocation settings](https://www.elastic.co/guide/en/elasticsearch/reference/master/disk-allocator.html) only)
20+
- Cluster settings
2321

2422
## Compatibility matrix
2523

26-
### Version 7.X
27-
28-
| Elasticsearch | Plugin | Release date |
29-
| -------------- | -------------- | ------------ |
30-
| 7.13.2 | 7.13.2.0 | Jun 15, 2021 |
31-
| 7.13.1 | 7.13.1.0 | Jun 12, 2021 |
32-
| 7.13.0 | 7.13.0.0 | May 27, 2021 |
33-
| 7.12.1 | 7.12.1.0 | May 01, 2021 |
34-
| 7.12.0 | 7.12.0.0 | Apr 04, 2021 |
35-
| 7.11.2 | 7.11.2.0 | Mar 20, 2021 |
36-
| 7.11.1 | 7.11.1.0 | Feb 22, 2021 |
37-
| 7.10.2 | 7.10.2.0 | Jan 24, 2021 |
38-
| 7.10.1 | 7.10.1.0 | Dec 13, 2020 |
39-
| 7.10.0 | 7.10.0.0 | Nov 15, 2020 |
40-
| 7.9.3 | 7.9.3.0 | Oct 22, 2020 |
41-
| 7.9.2 | 7.9.2.0 | Oct 04, 2020 |
42-
| 7.9.1 | 7.9.1.0 | Sep 06, 2020 |
43-
| 7.9.0 | 7.9.0.0 | Aug 18, 2020 |
44-
| 7.8.1 | 7.8.1.0 | Aug 10, 2020 |
45-
| 7.8.0 | 7.8.0.0 | Jun 22, 2020 |
46-
| 7.7.1 | 7.7.1.0 | Jun 04, 2020 |
47-
| 7.7.0 | 7.7.0.0 | May 14, 2020 |
48-
| 7.6.2 | 7.6.2.0 | Apr 6, 2020 |
49-
| 7.6.1 | 7.6.1.0 | Mar 30, 2020 |
50-
| 7.6.0 | 7.6.0.0 | Feb 12, 2020 |
51-
| 7.5.2 | 7.5.2.0 | Jan 25, 2020 |
52-
| 7.5.1 | 7.5.1.0 | Jan 21, 2020 |
53-
| 7.5.0 | 7.5.0.0 | Jan 16, 2020 |
54-
| 7.4.2 | 7.4.2.0 | Jan 13, 2020 |
55-
| 7.4.1 | 7.4.1.0 | Jan 13, 2020 |
56-
| 7.4.0 | 7.4.0.0 | Jan 07, 2020 |
57-
| 7.3.2 | 7.3.2.0 | Oct 05, 2019 |
58-
| 7.3.1 | 7.3.1.0 | Sep 18, 2019 |
59-
| 7.3.0 | 7.3.0.0 | Sep 17, 2019 |
60-
| 7.2.1 | 7.2.1.0 | Jul 31, 2019 |
61-
| 7.2.0 | 7.2.0.0 | Jul 12, 2019 |
62-
| 7.1.1 | 7.1.1.0 | May 31, 2019 |
63-
| 7.1.0 | 7.1.0.0 | May 23, 2019 |
64-
| 7.0.1 | 7.0.1.0 | May 08, 2019 |
65-
| 7.0.0 | 7.0.0.0 | Apr 11, 2019 |
24+
### Versions
25+
26+
| OpenSearch | Plugin | Release date |
27+
| ----------- | -------------- | ------------ |
28+
| 1.0.0-RC1 | 1.0.0-RC1 | Jun 24, 2021 |
6629

6730
## Install
6831

69-
`./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`
32+
`./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`
7033

7134
**Do not forget to restart the node after the installation!**
7235

@@ -87,19 +50,19 @@ To disable exporting cluster settings use:
8750
prometheus.cluster.settings: false
8851
```
8952

90-
These settings can be also [updated dynamically](https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html).
53+
These settings can be also [updated dynamically](https://www.elastic.co/guide/en/opensearch/reference/master/cluster-update-settings.html).
9154

9255
## Uninstall
9356

94-
`./bin/elasticsearch-plugin remove prometheus-exporter`
57+
`./bin/opensearch-plugin remove prometheus-exporter`
9558

9659
Do not forget to restart the node after installation!
9760

9861
## Usage
9962

10063
Metrics are directly available at:
10164

102-
http://<your-elasticsearch-host>:9200/_prometheus/metrics
65+
http://<your-opensearch-host>:9200/_prometheus/metrics
10366

10467
As a sample result, you get:
10568

@@ -134,7 +97,7 @@ On your Prometheus servers, configure a new job as usual.
13497
For example, if you have a cluster of 3 nodes:
13598

13699
```YAML
137-
- job_name: elasticsearch
100+
- job_name: opensearch
138101
scrape_interval: 10s
139102
metrics_path: "/_prometheus/metrics"
140103
static_configs:
@@ -148,34 +111,7 @@ Of course, you could use the service discovery service instead of a static confi
148111
149112
Just keep in mind that `metrics_path` must be `/_prometheus/metrics`, otherwise Prometheus will find no metric.
150113

151-
## Project sources
152-
153-
The Maven project site is available at [GitHub](https://github.com/vvanholl/elasticsearch-prometheus-exporter).
154-
155-
## Testing
156-
157-
Project contains [integration tests](src/test/resources/rest-api-spec) implemented using
158-
[rest layer](https://github.com/elastic/elasticsearch/blob/master/TESTING.asciidoc#testing-the-rest-layer)
159-
framework.
160-
161-
To run everything similar to the GitHub Actions pipeline you can do:
162-
```
163-
docker run -v $(pwd):/home/gradle gradle:7.0.2-jdk16 su gradle -c 'gradle check'
164-
```
165-
NOTE: Please keep version in sync with .github/workflows/ci.yml
166-
167-
168-
Complete test suite is run using:
169-
```
170-
gradle clean check
171-
```
172-
173-
To run individual test file use:
174-
```
175-
gradle :integTest \
176-
-Dtests.class=org.elasticsearch.rest.PrometheusRestHandlerClientYamlTestSuiteIT \
177-
-Dtests.method="test {yaml=resthandler/20_metrics/Prometheus metrics can be pulled}"
178-
```
114+
If you enable security in OpenSearch, remember to set up the credentials also in Prometheus configuration.
179115

180116
## Credits
181117

build.gradle

+9-9
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ buildscript {
1212
}
1313

1414
dependencies {
15-
classpath "org.elasticsearch.gradle:build-tools:${es_version}"
15+
classpath "org.opensearch.gradle:build-tools:${es_version}"
1616
classpath group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'
1717
classpath group: 'com.sun.xml.bind', name: 'jaxb-core', version: '2.3.0'
1818
classpath group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.3.0'
@@ -27,9 +27,9 @@ plugins {
2727

2828
apply plugin: 'java'
2929
apply plugin: 'idea'
30-
apply plugin: 'elasticsearch.esplugin'
31-
apply plugin: 'elasticsearch.rest-resources'
32-
apply plugin: 'elasticsearch.testclusters'
30+
apply plugin: 'opensearch.opensearchplugin'
31+
apply plugin: 'opensearch.rest-resources'
32+
apply plugin: 'opensearch.testclusters'
3333

3434
// Uncomment if you want to use: System.out.println("Emergency!");
3535
// Logs are found in build/testcluster/integTest-*/logs/ folder.
@@ -43,7 +43,7 @@ licenseFile = rootProject.file('LICENSE.txt')
4343
noticeFile = rootProject.file('NOTICE.txt')
4444

4545
// POM validation can be enabled
46-
validateElasticPom.enabled = false
46+
validatePom.enabled = false
4747

4848
// No unit tests in this plugin
4949
test.enabled = false
@@ -60,7 +60,7 @@ repositories {
6060

6161
ext {
6262
versions = [
63-
"elasticsearch": es_version,
63+
"opensearch": es_version,
6464
"prometheus" : "0.8.0",
6565
"log4j" : "2.11.1",
6666
"junit" : "4.12"
@@ -71,14 +71,14 @@ configurations {
7171
runtime
7272
releaseJars {
7373
extendsFrom runtime
74-
exclude group: "org.elasticsearch"
74+
exclude group: "org.opensearch"
7575
exclude group: "com.fasterxml.jackson.core", module: "jackson-core"
7676
exclude group: "org.apache.logging.log4j"
7777
}
7878
}
7979

8080
dependencies {
81-
api "org.elasticsearch:elasticsearch:${versions.elasticsearch}"
81+
api "org.opensearch:opensearch:${versions.opensearch}"
8282
api "io.prometheus:simpleclient:${versions.prometheus}"
8383
api "io.prometheus:simpleclient_common:${versions.prometheus}"
8484
api "org.apache.logging.log4j:log4j-api:${versions.log4j}"
@@ -92,7 +92,7 @@ tasks.withType(JavaCompile) {
9292
options.compilerArgs << "-Xlint:unchecked,deprecation"
9393
}
9494

95-
esplugin {
95+
opensearchplugin {
9696
licenseFile rootProject.file('LICENSE.txt')
9797
noticeFile rootProject.file('NOTICE.txt')
9898
name pluginName

gradle.properties

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
group = org.elasticsearch.plugin.prometheus
1+
group = org.opensearch.plugin.prometheus
22

3-
version = 7.13.2.1-SNAPSHOT
3+
version = 1.0.0-rc1
44

55
pluginName = prometheus-exporter
6-
pluginClassname = org.elasticsearch.plugin.prometheus.PrometheusExporterPlugin
7-
pluginDescription = Export Elasticsearch metrics to Prometheus
6+
pluginClassname = org.opensearch.plugin.prometheus.PrometheusExporterPlugin
7+
pluginDescription = Export OpenSearch metrics to Prometheus
88

99
github_token = secret
10-
github_owner = vvanholl
11-
github_repo = elasticsearch-prometheus-exporter
10+
github_owner = aparo
11+
github_repo = opensearch-prometheus-exporter

src/main/java/org/compuscene/metrics/prometheus/PrometheusMetricsCatalog.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import org.apache.logging.log4j.LogManager;
2121
import org.apache.logging.log4j.Logger;
22-
import org.elasticsearch.rest.prometheus.RestPrometheusMetricsAction;
22+
import org.opensearch.rest.prometheus.RestPrometheusMetricsAction;
2323

2424
import java.io.IOException;
2525
import java.io.StringWriter;

src/main/java/org/compuscene/metrics/prometheus/PrometheusMetricsCollector.java

+25-25
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,26 @@
1717

1818
package org.compuscene.metrics.prometheus;
1919

20-
import org.elasticsearch.action.ClusterStatsData;
21-
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
22-
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
23-
import org.elasticsearch.action.admin.indices.stats.CommonStats;
24-
import org.elasticsearch.action.admin.indices.stats.IndexStats;
25-
import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
26-
import org.elasticsearch.cluster.health.ClusterIndexHealth;
27-
import org.elasticsearch.cluster.node.DiscoveryNodeRole;
28-
import org.elasticsearch.http.HttpStats;
29-
import org.elasticsearch.indices.NodeIndicesStats;
30-
import org.elasticsearch.indices.breaker.AllCircuitBreakerStats;
31-
import org.elasticsearch.indices.breaker.CircuitBreakerStats;
32-
import org.elasticsearch.ingest.IngestStats;
33-
import org.elasticsearch.monitor.fs.FsInfo;
34-
import org.elasticsearch.monitor.jvm.JvmStats;
35-
import org.elasticsearch.monitor.os.OsStats;
36-
import org.elasticsearch.monitor.process.ProcessStats;
37-
import org.elasticsearch.script.ScriptStats;
38-
import org.elasticsearch.threadpool.ThreadPoolStats;
39-
import org.elasticsearch.transport.TransportStats;
20+
import org.opensearch.action.ClusterStatsData;
21+
import org.opensearch.action.admin.cluster.health.ClusterHealthResponse;
22+
import org.opensearch.action.admin.cluster.node.stats.NodeStats;
23+
import org.opensearch.action.admin.indices.stats.CommonStats;
24+
import org.opensearch.action.admin.indices.stats.IndexStats;
25+
import org.opensearch.action.admin.indices.stats.IndicesStatsResponse;
26+
import org.opensearch.cluster.health.ClusterIndexHealth;
27+
import org.opensearch.cluster.node.DiscoveryNodeRole;
28+
import org.opensearch.http.HttpStats;
29+
import org.opensearch.indices.NodeIndicesStats;
30+
import org.opensearch.indices.breaker.AllCircuitBreakerStats;
31+
import org.opensearch.indices.breaker.CircuitBreakerStats;
32+
import org.opensearch.ingest.IngestStats;
33+
import org.opensearch.monitor.fs.FsInfo;
34+
import org.opensearch.monitor.jvm.JvmStats;
35+
import org.opensearch.monitor.os.OsStats;
36+
import org.opensearch.monitor.process.ProcessStats;
37+
import org.opensearch.script.ScriptStats;
38+
import org.opensearch.threadpool.ThreadPoolStats;
39+
import org.opensearch.transport.TransportStats;
4040

4141
import java.util.HashMap;
4242
import java.util.List;
@@ -130,7 +130,7 @@ private void registerNodeMetrics() {
130130
private void updateNodeMetrics(NodeStats ns) {
131131
if (ns != null) {
132132

133-
// Plugins can introduce custom node roles from 7.3.0: https://github.com/elastic/elasticsearch/pull/43175
133+
// Plugins can introduce custom node roles from 7.3.0: https://github.com/elastic/opensearch/pull/43175
134134
// TODO(lukas-vlcek): List of node roles can not be static but needs to be created dynamically.
135135
Map<String, Integer> roles = new HashMap<>();
136136

@@ -413,7 +413,7 @@ private void registerPerIndexMetrics() {
413413
catalog.registerClusterGauge("index_fielddata_evictions_count", "Count of evictions in field data cache", "index", "context");
414414

415415
// Percolator cache was removed in ES 5.x
416-
// See https://github.com/elastic/elasticsearch/commit/80fee8666ff5dd61ba29b175857cf42ce3b9eab9
416+
// See https://github.com/elastic/opensearch/commit/80fee8666ff5dd61ba29b175857cf42ce3b9eab9
417417

418418
catalog.registerClusterGauge("index_completion_size_bytes", "Size of completion suggest statistics", "index", "context");
419419

@@ -530,7 +530,7 @@ private void updatePerIndexContextMetrics(String indexName, String context, Comm
530530
catalog.setClusterGauge("index_fielddata_evictions_count", idx.getFieldData().getEvictions(), indexName, context);
531531

532532
// Percolator cache was removed in ES 5.x
533-
// See https://github.com/elastic/elasticsearch/commit/80fee8666ff5dd61ba29b175857cf42ce3b9eab9
533+
// See https://github.com/elastic/opensearch/commit/80fee8666ff5dd61ba29b175857cf42ce3b9eab9
534534

535535
catalog.setClusterGauge("index_completion_size_bytes", idx.getCompletion().getSizeInBytes(), indexName, context);
536536

@@ -902,8 +902,8 @@ private void registerESSettings() {
902902
private void updateESSettings(ClusterStatsData stats) {
903903
if (stats != null) {
904904
catalog.setClusterGauge("cluster_routing_allocation_disk_threshold_enabled", Boolean.TRUE.equals(stats.getThresholdEnabled()) ? 1 : 0);
905-
// According to Elasticsearch documentation the following settings must be set either in pct or bytes size.
906-
// Mixing is not allowed. We rely on Elasticsearch to do all necessary checks and we simply
905+
// According to OpenSearch documentation the following settings must be set either in pct or bytes size.
906+
// Mixing is not allowed. We rely on OpenSearch to do all necessary checks and we simply
907907
// output all those metrics that are not null. If this will lead to mixed metric then we do not
908908
// consider it our fault.
909909
if (stats.getDiskLowInBytes() != null) { catalog.setClusterGauge("cluster_routing_allocation_disk_watermark_low_bytes", stats.getDiskLowInBytes()); }

src/main/java/org/compuscene/metrics/prometheus/PrometheusSettings.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@
1717

1818
package org.compuscene.metrics.prometheus;
1919

20-
import org.elasticsearch.common.settings.ClusterSettings;
21-
import org.elasticsearch.common.settings.Setting;
22-
import org.elasticsearch.common.settings.Settings;
20+
import org.opensearch.common.settings.ClusterSettings;
21+
import org.opensearch.common.settings.Setting;
22+
import org.opensearch.common.settings.Settings;
2323

2424
/**
2525
* A container to keep settings for prometheus up to date with cluster setting changes.
2626
*
2727
* In order to make the settings dynamically updatable we took some inspiration from implementation
28-
* and use of DiskThresholdSettings class in Elasticsearch.
28+
* and use of DiskThresholdSettings class in OpenSearch.
2929
*/
3030
public class PrometheusSettings {
3131

3232
// These settings become part of cluster state available via HTTP at
33-
// curl <elasticsearch>/_cluster/settings?include_defaults=true&filter_path=defaults.prometheus
33+
// curl <opensearch>/_cluster/settings?include_defaults=true&filter_path=defaults.prometheus
3434
// It is important to keep it under reasonable namespace to avoid collision with
3535
// other plugins or future/commercial parts of Elastic Stack itself.
3636
// Namespace "prometheus" sounds like safe bet for now.

0 commit comments

Comments
 (0)