Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.elasticsearch.xpack.core.downsample.DownsampleShardPersistentTaskState;
import org.elasticsearch.xpack.core.downsample.DownsampleShardTask;

import java.util.Collection;
import java.util.List;
import java.util.function.Predicate;
import java.util.function.Supplier;
Expand All @@ -49,6 +50,13 @@ public class Downsample extends Plugin implements ActionPlugin, PersistentTaskPl
private static final int DOWNSAMPLE_TASK_THREAD_POOL_QUEUE_SIZE = 256;
public static final String DOWNSAMPLE_MIN_NUMBER_OF_REPLICAS_NAME = "downsample.min_number_of_replicas";

@Override
public Collection<?> createComponents(PluginServices services) {
var metrics = new DownsampleMetrics(services.telemetryProvider().getMeterRegistry());

return List.of(metrics);
}

@Override
public List<ExecutorBuilder<?>> getExecutorBuilders(Settings settings) {
final FixedExecutorBuilder downsample = new FixedExecutorBuilder(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

package org.elasticsearch.xpack.downsample;

import org.elasticsearch.telemetry.metric.LongCounter;
import org.elasticsearch.telemetry.metric.LongHistogram;
import org.elasticsearch.telemetry.metric.MeterRegistry;

public class DownsampleMetrics {
public static final String SUCCESS = "es.tsdb.downsample.success.total";
public static final String FAILURE = "es.tsdb.downsample.failure.total";

private final LongCounter downsampleSuccess;
private final LongCounter downsampleFailure;

public DownsampleMetrics(MeterRegistry meterRegistry) {
this(
meterRegistry.registerLongCounter(
SUCCESS,
"Number of successful downsample operations",
"count"
),
meterRegistry.registerLongCounter(
FAILURE,
"Number of failed downsample operations",
"count"
)
);
}

public DownsampleMetrics(LongCounter downsampleSuccess, LongCounter downsampleFailure) {
this.downsampleSuccess = downsampleSuccess;
this.downsampleFailure = downsampleFailure;
}

public LongCounter getDownsampleSuccess() {
return downsampleSuccess;
}

public LongCounter getDownsampleFailure() {
return downsampleFailure;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public class TransportDownsampleAction extends AcknowledgedTransportMasterNodeAc
private final IndexScopedSettings indexScopedSettings;
private final ThreadContext threadContext;
private final PersistentTasksService persistentTasksService;
private final DownsampleMetrics metrics;

private static final Set<String> FORBIDDEN_SETTINGS = Set.of(
IndexSettings.DEFAULT_PIPELINE.getKey(),
Expand Down Expand Up @@ -153,7 +154,8 @@ public TransportDownsampleAction(
ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver,
IndexScopedSettings indexScopedSettings,
PersistentTasksService persistentTasksService
PersistentTasksService persistentTasksService,
DownsampleMetrics metrics
) {
super(
DownsampleAction.NAME,
Expand All @@ -173,6 +175,7 @@ public TransportDownsampleAction(
this.threadContext = threadPool.getThreadContext();
this.taskQueue = clusterService.createTaskQueue("downsample", Priority.URGENT, STATE_UPDATE_TASK_EXECUTOR);
this.persistentTasksService = persistentTasksService;
this.metrics = metrics;
}

@Override
Expand Down