-
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
Merged
Merged
Add logsdb telemetry #115994
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bcd6e04
logsdb usage
dnhatn f568efa
Update docs/changelog/115994.yaml
dnhatn 5dc58e6
renaming
dnhatn bb784da
Merge remote-tracking branch 'elastic/main' into logsdb-usage
dnhatn 0f1a943
Merge remote-tracking branch 'dnhatn/logsdb-usage' into logsdb-usage
dnhatn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...in/core/src/main/java/org/elasticsearch/xpack/core/application/LogsDBFeatureSetUsage.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...plugin/logsdb/src/main/java/org/elasticsearch/xpack/logsdb/LogsDBInfoTransportAction.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...lugin/logsdb/src/main/java/org/elasticsearch/xpack/logsdb/LogsDBUsageTransportAction.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* 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 numIndicesWithSyntheticSources = 0; | ||
for (IndexMetadata indexMetadata : state.metadata()) { | ||
if (indexMetadata.getIndexMode() == IndexMode.LOGSDB) { | ||
numIndices++; | ||
if (INDEX_MAPPER_SOURCE_MODE_SETTING.get(indexMetadata.getSettings()) == SourceFieldMapper.Mode.SYNTHETIC) { | ||
numIndicesWithSyntheticSources++; | ||
} | ||
} | ||
} | ||
final boolean enabled = LogsDBPlugin.CLUSTER_LOGSDB_ENABLED.get(clusterService.getSettings()); | ||
listener.onResponse( | ||
new XPackUsageFeatureResponse(new LogsDBFeatureSetUsage(true, enabled, numIndices, numIndicesWithSyntheticSources)) | ||
); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.