-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Add logsdb telemetry #115994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add logsdb telemetry #115994
Changes from 2 commits
bcd6e04
f568efa
5dc58e6
bb784da
0f1a943
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 115994 | ||
summary: Add logsdb telemetry | ||
area: Logs | ||
type: enhancement | ||
issues: [] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* 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.core.application; | ||
|
||
import org.elasticsearch.TransportVersion; | ||
import org.elasticsearch.TransportVersions; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
import org.elasticsearch.xcontent.XContentBuilder; | ||
import org.elasticsearch.xpack.core.XPackFeatureUsage; | ||
import org.elasticsearch.xpack.core.XPackField; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
public final class LogsDBFeatureSetUsage extends XPackFeatureUsage { | ||
private final int indicesCount; | ||
private final int indicesWithSyntheticSource; | ||
|
||
public LogsDBFeatureSetUsage(StreamInput input) throws IOException { | ||
super(input); | ||
indicesCount = input.readVInt(); | ||
indicesWithSyntheticSource = input.readVInt(); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeVInt(indicesCount); | ||
out.writeVInt(indicesWithSyntheticSource); | ||
} | ||
|
||
public LogsDBFeatureSetUsage(boolean available, boolean enabled, int indicesCount, int indicesWithSyntheticSource) { | ||
super(XPackField.LOGSDB, available, enabled); | ||
this.indicesCount = indicesCount; | ||
this.indicesWithSyntheticSource = indicesWithSyntheticSource; | ||
} | ||
|
||
@Override | ||
public TransportVersion getMinimalSupportedVersion() { | ||
return TransportVersions.LOGSDB_TELEMETRY; | ||
} | ||
|
||
@Override | ||
protected void innerXContent(XContentBuilder builder, Params params) throws IOException { | ||
super.innerXContent(builder, params); | ||
builder.field("indices_count", indicesCount); | ||
builder.field("indices_with_synthetic_source", indicesWithSyntheticSource); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(available, enabled, indicesCount, indicesWithSyntheticSource); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == null) { | ||
return false; | ||
} | ||
if (getClass() != obj.getClass()) { | ||
return false; | ||
} | ||
LogsDBFeatureSetUsage other = (LogsDBFeatureSetUsage) obj; | ||
return Objects.equals(available, other.available) | ||
&& Objects.equals(enabled, other.enabled) | ||
&& Objects.equals(indicesCount, other.indicesCount) | ||
&& Objects.equals(indicesWithSyntheticSource, other.indicesWithSyntheticSource); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* 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.logsdb; | ||
|
||
import org.elasticsearch.action.support.ActionFilters; | ||
import org.elasticsearch.cluster.service.ClusterService; | ||
import org.elasticsearch.injection.guice.Inject; | ||
import org.elasticsearch.transport.TransportService; | ||
import org.elasticsearch.xpack.core.XPackField; | ||
import org.elasticsearch.xpack.core.action.XPackInfoFeatureAction; | ||
import org.elasticsearch.xpack.core.action.XPackInfoFeatureTransportAction; | ||
|
||
public class LogsDBInfoTransportAction extends XPackInfoFeatureTransportAction { | ||
|
||
private final ClusterService clusterService; | ||
|
||
@Inject | ||
public LogsDBInfoTransportAction(TransportService transportService, ClusterService clusterService, ActionFilters actionFilters) { | ||
super(XPackInfoFeatureAction.LOGSDB.name(), transportService, actionFilters); | ||
this.clusterService = clusterService; | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return XPackField.LOGSDB; | ||
} | ||
|
||
@Override | ||
public boolean available() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean enabled() { | ||
return LogsDBPlugin.CLUSTER_LOGSDB_ENABLED.get(clusterService.getSettings()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* 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.logsdb; | ||
|
||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.action.support.ActionFilters; | ||
import org.elasticsearch.cluster.ClusterState; | ||
import org.elasticsearch.cluster.metadata.IndexMetadata; | ||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; | ||
import org.elasticsearch.cluster.service.ClusterService; | ||
import org.elasticsearch.index.IndexMode; | ||
import org.elasticsearch.index.mapper.SourceFieldMapper; | ||
import org.elasticsearch.injection.guice.Inject; | ||
import org.elasticsearch.protocol.xpack.XPackUsageRequest; | ||
import org.elasticsearch.tasks.Task; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
import org.elasticsearch.transport.TransportService; | ||
import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction; | ||
import org.elasticsearch.xpack.core.action.XPackUsageFeatureResponse; | ||
import org.elasticsearch.xpack.core.action.XPackUsageFeatureTransportAction; | ||
import org.elasticsearch.xpack.core.application.LogsDBFeatureSetUsage; | ||
|
||
import static org.elasticsearch.index.mapper.SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING; | ||
|
||
public class LogsDBUsageTransportAction extends XPackUsageFeatureTransportAction { | ||
private final ClusterService clusterService; | ||
|
||
@Inject | ||
public LogsDBUsageTransportAction( | ||
TransportService transportService, | ||
ClusterService clusterService, | ||
ThreadPool threadPool, | ||
ActionFilters actionFilters, | ||
IndexNameExpressionResolver indexNameExpressionResolver | ||
) { | ||
super( | ||
XPackUsageFeatureAction.LOGSDB.name(), | ||
transportService, | ||
clusterService, | ||
threadPool, | ||
actionFilters, | ||
indexNameExpressionResolver | ||
); | ||
this.clusterService = clusterService; | ||
} | ||
|
||
@Override | ||
protected void masterOperation( | ||
Task task, | ||
XPackUsageRequest request, | ||
ClusterState state, | ||
ActionListener<XPackUsageFeatureResponse> listener | ||
) { | ||
int numIndices = 0; | ||
int numSyntheticSources = 0; | ||
|
||
for (IndexMetadata indexMetadata : state.metadata()) { | ||
if (indexMetadata.getIndexMode() == IndexMode.LOGSDB) { | ||
numIndices++; | ||
if (INDEX_MAPPER_SOURCE_MODE_SETTING.get(indexMetadata.getSettings()) == SourceFieldMapper.Mode.SYNTHETIC) { | ||
numSyntheticSources++; | ||
} | ||
} | ||
} | ||
final boolean enabled = LogsDBPlugin.CLUSTER_LOGSDB_ENABLED.get(clusterService.getSettings()); | ||
listener.onResponse(new XPackUsageFeatureResponse(new LogsDBFeatureSetUsage(true, enabled, numIndices, numSyntheticSources))); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if this is the best place for this, but can we maybe in a follow up also track the number of indices without index mode that use synthetic source, the number of tsdb indices and how many of those tsdb indices use synthetic source? If you think this is a good idea. Maybe we should in this change rename the
indices_count
andindices_with_synthetic_source
fields in the response to be something likelogsdb_index_count
,logsdb_with_synthetic_source_index_count
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I considered this as well, but these fields don't seem to fit within logsdb. I think we'll need to add two separate usages: one for time_series and another for source_mode. I’ll add them in follow-up PRs.