Skip to content

Commit

Permalink
Upgrade to Elasticsearch 7.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
duxet committed Apr 16, 2019
1 parent d52c619 commit deb496d
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 18 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ It collects all relevant metrics and makes them available to Prometheus via the

## Compatibility matrix

### Version 7.X

| Elasticsearch | Plugin | Release date |
| -------------- | -------------- | ------------ |
| 7.0.0 | 7.0.0.0 | Apr 11, 2019 |

### Version 6.X

| Elasticsearch | Plugin | Release date |
Expand Down Expand Up @@ -114,6 +120,9 @@ It collects all relevant metrics and makes them available to Prometheus via the

## Install

- Since Elasticsearch 7.0.0 :
`./bin/elasticsearch-plugin install -b https://distfiles.compuscene.net/elasticsearch/elasticsearch-prometheus-exporter-7.0.0.0.zip`

- Since Elasticsearch 6.0.0 :
`./bin/elasticsearch-plugin install -b https://distfiles.compuscene.net/elasticsearch/elasticsearch-prometheus-exporter-6.7.1.0.zip`

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath "org.elasticsearch.gradle:build-tools:6.7.1" // How can we use ${versions.elasticsearch} here ???
classpath "org.elasticsearch.gradle:build-tools:7.0.0" // How can we use ${versions.elasticsearch} here ???
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'
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
group = org.elasticsearch.plugin.prometheus

version = 6.7.1.0-SNAPSHOT
version = 7.0.0.0-SNAPSHOT

pluginName = prometheus-exporter
pluginClassname = org.elasticsearch.plugin.prometheus.PrometheusExporterPlugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@
*/
package org.elasticsearch.action;

import org.elasticsearch.client.ElasticsearchClient;
import org.elasticsearch.common.io.stream.Writeable;

/**
* Action class for Prometheus Exporter plugin.
*/
public class NodePrometheusMetricsAction extends Action<NodePrometheusMetricsRequest, NodePrometheusMetricsResponse,
NodePrometheusRequestBuilder> {
public class NodePrometheusMetricsAction extends Action<NodePrometheusMetricsResponse> {
public static final NodePrometheusMetricsAction INSTANCE = new NodePrometheusMetricsAction();
public static final String NAME = "cluster:monitor/prometheus/metrics";

Expand All @@ -37,11 +35,6 @@ public NodePrometheusMetricsResponse newResponse() {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}

@Override
public NodePrometheusRequestBuilder newRequestBuilder(ElasticsearchClient client) {
return new NodePrometheusRequestBuilder(client, this);
}

@Override
public Writeable.Reader<NodePrometheusMetricsResponse> getResponseReader() {
return NodePrometheusMetricsResponse::new;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.elasticsearch.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;
Expand All @@ -31,12 +33,11 @@
import org.elasticsearch.action.support.HandledTransportAction;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.Requests;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
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.threadpool.ThreadPool;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.transport.TransportService;

/**
Expand All @@ -52,22 +53,22 @@ public class TransportNodePrometheusMetricsAction extends HandledTransportAction
private final Settings settings;
private final ClusterSettings clusterSettings;
private final PrometheusSettings prometheusSettings;
private final Logger logger = LogManager.getLogger(getClass());

@Inject
public TransportNodePrometheusMetricsAction(Settings settings, ThreadPool threadPool, Client client,
public TransportNodePrometheusMetricsAction(Settings settings, Client client,
TransportService transportService, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver,
ClusterSettings clusterSettings) {
super(settings, NodePrometheusMetricsAction.NAME, threadPool, transportService, actionFilters,
indexNameExpressionResolver, NodePrometheusMetricsRequest::new);
super(NodePrometheusMetricsAction.NAME, transportService, actionFilters,
NodePrometheusMetricsRequest::new);
this.client = client;
this.settings = settings;
this.clusterSettings = clusterSettings;
this.prometheusSettings = new PrometheusSettings(settings, clusterSettings);
}

@Override
protected void doExecute(NodePrometheusMetricsRequest request, ActionListener<NodePrometheusMetricsResponse> listener) {
protected void doExecute(Task task, NodePrometheusMetricsRequest request, ActionListener<NodePrometheusMetricsResponse> listener) {
new AsyncAction(listener).start();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
import static org.elasticsearch.action.NodePrometheusMetricsAction.INSTANCE;
import static org.elasticsearch.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.inject.Inject;
import org.elasticsearch.common.network.NetworkAddress;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.*;
Expand All @@ -40,6 +43,7 @@
public class RestPrometheusMetricsAction extends BaseRestHandler {

private final PrometheusSettings prometheusSettings;
private final Logger logger = LogManager.getLogger(getClass());

@Inject
public RestPrometheusMetricsAction(Settings settings, ClusterSettings clusterSettings, RestController controller) {
Expand All @@ -58,8 +62,9 @@ public String getName() {
@Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) {
if (logger.isTraceEnabled()) {
String remoteAddress = NetworkAddress.format(request.getHttpChannel().getRemoteAddress());
logger.trace(String.format(Locale.ENGLISH, "Received request for Prometheus metrics from %s",
request.getRemoteAddress().toString()));
remoteAddress));
}

NodePrometheusMetricsRequest metricsRequest = new NodePrometheusMetricsRequest();
Expand Down

0 comments on commit deb496d

Please sign in to comment.