Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
java: [17,21]
java: [21]
name: Build and Test Plugin Template
runs-on: ${{ matrix.os }}
permissions:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: '17'
java-version: '21'

# Build the project
- name: Build project
Expand Down Expand Up @@ -77,4 +77,4 @@ jobs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: prometheus-exporter-${{ steps.properties.outputs.version }}.zip
asset_name: prometheus-exporter-${{ steps.properties.outputs.version }}.zip
asset_content_type: application/zip
asset_content_type: application/zip
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ NOTE: OpenSearch plugins much match _exactly_ in major.minor.path version to the

| OpenSearch | Plugin | Release date |
|-----------:|------------:|--------------:|
| 3.1.0 | 3.1.0.0 | 2025-07-08 |
| 2.19.2 | 2.19.2.0 | 2025-06-04 |
| 2.19.0 | 2.19.0.0 | 2025-11-14 |
| 2.18.0 | 2.18.0.0 | 2025-01-02 |
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ buildscript {
"prometheus": "0.16.0"
]

bwcPluginDownloadLink = 'https://github.com/Virtimo/prometheus-exporter-plugin-for-opensearch/releases/download/v' +
bwcPluginDownloadLink = 'https://github.com/sapcc/prometheus-exporter-plugin-for-opensearch/releases/download/v' +
project.BWCversion + '/prometheus-exporter-' + project.BWCPluginVersion + '.zip'
baseName = "bwcCluster"
bwcFilePath = "src/test/resources/org/opensearch/prometheus-exporter/bwc/"
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#group = org.opensearch.plugin.prometheus

# An actual version of plugin
version = 2.19.2.0
version = 3.1.0.0

# Leave this property empty, it is assigned during the gradle build execution (yes, it is a hack! see issue #324)
opensearch_version =

# A version of OpenSearch cluster to run BWC tests against
BWCversion = 2.19.1
BWCversion = 2.19.2

# A version of plugin to deploy to BWC clusters
BWCPluginVersion = 2.19.1.0
BWCPluginVersion = 2.19.2.0

pluginName = prometheus-exporter
pluginClassname = org.opensearch.plugin.prometheus.PrometheusExporterPlugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@
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.core.action.ActionListener;
import org.opensearch.tasks.Task;
import org.opensearch.transport.TransportService;
import org.opensearch.client.node.NodeClient;

/**
* Transport action class for Prometheus Exporter plugin.
Expand All @@ -53,24 +52,23 @@
*/
public class TransportNodePrometheusMetricsAction extends HandledTransportAction<NodePrometheusMetricsRequest,
NodePrometheusMetricsResponse> {
private final Client client;
private final Settings settings;
private final ClusterSettings clusterSettings;
private final PrometheusSettings prometheusSettings;
private final Logger logger = LogManager.getLogger(getClass());
private final NodeClient client;

/**
* A constructor.
* @param settings Settings
* @param client Cluster client
* @param client Node client
* @param transportService Transport service
* @param actionFilters Action filters
* @param clusterSettings Cluster settings
*/
@Inject
public TransportNodePrometheusMetricsAction(Settings settings, Client client,
TransportService transportService, ActionFilters actionFilters,
ClusterSettings clusterSettings) {
public TransportNodePrometheusMetricsAction(Settings settings, NodeClient client, TransportService transportService,
ActionFilters actionFilters, ClusterSettings clusterSettings) {
super(NodePrometheusMetricsAction.NAME, transportService, actionFilters,
NodePrometheusMetricsRequest::new);
this.client = client;
Expand Down Expand Up @@ -119,17 +117,12 @@ private class AsyncAction {
private AsyncAction(ActionListener<NodePrometheusMetricsResponse> listener) {
this.listener = 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
this.healthRequest = Requests.clusterHealthRequest().local(true);
this.healthRequest = new ClusterHealthRequest().local(true);
this.healthRequest.level(ClusterHealthRequest.Level.SHARDS);

// We want to get only the most minimal static info from local node (cluster name, node name and nodeID).
this.localNodesInfoRequest = Requests.nodesInfoRequest("_local").clear();
this.localNodesInfoRequest = new NodesInfoRequest("_local").clear();

this.nodesStatsRequest = Requests.nodesStatsRequest(prometheusNodesFilter).clear().all();
this.nodesStatsRequest = new NodesStatsRequest(prometheusNodesFilter).clear().all();

// Indices stats request is not "node-specific", it does not support any "_local" notion
// it is broad-casted to all cluster nodes.
Expand All @@ -144,8 +137,7 @@ private AsyncAction(ActionListener<NodePrometheusMetricsResponse> listener) {

// Cluster settings are get via ClusterStateRequest (see elasticsearch 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;
this.clusterStateRequest = isPrometheusClusterSettings ? new ClusterStateRequest().clear().metadata(true).local(false) : null;
}

private void gatherRequests() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
import org.compuscene.metrics.prometheus.PrometheusSettings;
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.Setting;
import org.opensearch.common.settings.Settings;
import org.opensearch.core.rest.RestStatus;
import org.opensearch.rest.*;
import org.opensearch.rest.action.RestResponseListener;
import org.opensearch.client.node.NodeClient;

import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -91,8 +91,6 @@ public String getName() {
return "prometheus_metrics_action";
}

// This method does not throw any IOException because there are no request parameters to be parsed
// and processed. This may change in the future.
@Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) {
if (logger.isTraceEnabled()) {
Expand Down Expand Up @@ -120,7 +118,6 @@ public RestResponse buildResponse(NodePrometheusMetricsResponse response) throws
PrometheusMetricsCollector collector;
String textContent;
try {
// PrometheusMetricsCatalog catalog = new PrometheusMetricsCatalog(clusterName, nodeName, nodeId, metricPrefix);
PrometheusMetricsCatalog catalog = new PrometheusMetricsCatalog(clusterName, metricPrefix);
collector = new PrometheusMetricsCollector(
catalog,
Expand All @@ -133,20 +130,9 @@ public RestResponse buildResponse(NodePrometheusMetricsResponse response) throws
response.getIndicesStats(), response.getClusterStatsData());
textContent = collector.getTextContent();
} catch (Exception ex) {
// We use try-catch block to catch exception from Prometheus catalog and collector processing
// and dump it into the log, otherwise client needs to know how to configure logging to output
// exceptions that are thrown from
// "RestResponseListener.buildResponse(Response response) throws Exception".
// This is useful when metric_prefix value is not valid or when metric collector fails
// generating text content. We may be able to get rid of this try-catch pattern
// once we implement robust verification of custom metric prefix.
// See https://github.com/aiven/prometheus-exporter-plugin-for-opensearch/issues/11
logger.debug("Prometheus metric catalog processing failed", ex);
throw ex;
}
// Prometheus' metrics are exposed similarly the Pushgateway example except no real gateway
// is used and the metrics are exposed directly via OpenSearch HTTP API instead.
// See https://github.com/prometheus/client_java#exporting-to-a-pushgateway
return new BytesRestResponse(RestStatus.OK, textContent);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
*/
public class PluginBackwardsCompatibilityIT extends OpenSearchRestTestCase {

public static final Version BWCVersion = Version.V_2_19_1;
public static final Version NewVersion = Version.V_2_19_2;
public static final Version BWCVersion = Version.V_2_19_2;
public static final Version NewVersion = Version.V_3_1_0;

private static final ClusterType CLUSTER_TYPE = ClusterType.parse(System.getProperty("tests.rest.bwcsuite"));
private static final String CLUSTER_NAME = System.getProperty("tests.clustername");
Expand Down
Loading