Skip to content

Commit 6d4e11d

Browse files
authored
Add logsdb telemetry (#115994)
This PR adds telemetry for logsdb. However, this change only tracks the count of indices using logsdb and those that use synthetic source. Additional stats, such as shard, indexing, and search stats, will be added in a follow-up, as they require reaching out to data nodes.
1 parent d93d333 commit 6d4e11d

File tree

15 files changed

+277
-13
lines changed

15 files changed

+277
-13
lines changed

docs/changelog/115994.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 115994
2+
summary: Add logsdb telemetry
3+
area: Logs
4+
type: enhancement
5+
issues: []

docs/reference/rest-api/info.asciidoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ Example response:
172172
"universal_profiling": {
173173
"available": true,
174174
"enabled": true
175+
},
176+
"logsdb": {
177+
"available": true,
178+
"enabled": false
175179
}
176180
},
177181
"tagline" : "You know, for X"

docs/reference/rest-api/usage.asciidoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,12 @@ GET /_xpack/usage
518518
"universal_profiling" : {
519519
"available" : true,
520520
"enabled" : true
521+
},
522+
"logsdb": {
523+
"available": true,
524+
"enabled": false,
525+
"indices_count": 0,
526+
"indices_with_synthetic_source": 0
521527
}
522528
}
523529
------------------------------------------------------------

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ static TransportVersion def(int id) {
186186
public static final TransportVersion CPU_STAT_STRING_PARSING = def(8_781_00_0);
187187
public static final TransportVersion QUERY_RULES_RETRIEVER = def(8_782_00_0);
188188
public static final TransportVersion ESQL_CCS_EXEC_INFO_WITH_FAILURES = def(8_783_00_0);
189+
public static final TransportVersion LOGSDB_TELEMETRY = def(8_784_00_0);
189190

190191
/*
191192
* STOP! READ THIS FIRST! No, really,

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.elasticsearch.xpack.core.aggregatemetric.AggregateMetricFeatureSetUsage;
2626
import org.elasticsearch.xpack.core.analytics.AnalyticsFeatureSetUsage;
2727
import org.elasticsearch.xpack.core.application.EnterpriseSearchFeatureSetUsage;
28+
import org.elasticsearch.xpack.core.application.LogsDBFeatureSetUsage;
2829
import org.elasticsearch.xpack.core.application.ProfilingUsage;
2930
import org.elasticsearch.xpack.core.archive.ArchiveFeatureSetUsage;
3031
import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata;
@@ -305,7 +306,8 @@ public List<NamedWriteableRegistry.Entry> getNamedWriteables() {
305306
PersistentTaskParams.class,
306307
SecurityMigrationTaskParams.TASK_NAME,
307308
SecurityMigrationTaskParams::new
308-
)
309+
),
310+
new NamedWriteableRegistry.Entry(XPackFeatureUsage.class, XPackField.LOGSDB, LogsDBFeatureSetUsage::new)
309311
).filter(Objects::nonNull).toList();
310312
}
311313

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackFeatures.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020
* Provides the XPack features that this version of the code supports
2121
*/
2222
public class XPackFeatures implements FeatureSpecification {
23+
public static final NodeFeature LOGSDB_TELEMETRY = new NodeFeature("logsdb_telemetry");
2324

2425
@Override
2526
public Set<NodeFeature> getFeatures() {
2627
return Set.of(
2728
NodesDataTiersUsageTransportAction.LOCALLY_PRECALCULATED_STATS_FEATURE, // Added in 8.12
28-
License.INDEPENDENT_TRIAL_VERSION_FEATURE // 8.14.0
29+
License.INDEPENDENT_TRIAL_VERSION_FEATURE, // 8.14.0
30+
LOGSDB_TELEMETRY
2931
);
3032
}
3133

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackField.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public final class XPackField {
9090
public static final String ENTERPRISE_GEOIP_DOWNLOADER = "enterprise_geoip_downloader";
9191
/** Name for Universal Profiling. */
9292
public static final String UNIVERSAL_PROFILING = "universal_profiling";
93+
public static final String LOGSDB = "logsdb";
9394

9495
private XPackField() {}
9596

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/XPackInfoFeatureAction.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class XPackInfoFeatureAction {
4848
public static final ActionType<XPackInfoFeatureResponse> ARCHIVE = xpackInfoFeatureAction(XPackField.ARCHIVE);
4949
public static final ActionType<XPackInfoFeatureResponse> ENTERPRISE_SEARCH = xpackInfoFeatureAction(XPackField.ENTERPRISE_SEARCH);
5050
public static final ActionType<XPackInfoFeatureResponse> UNIVERSAL_PROFILING = xpackInfoFeatureAction(XPackField.UNIVERSAL_PROFILING);
51+
public static final ActionType<XPackInfoFeatureResponse> LOGSDB = xpackInfoFeatureAction(XPackField.LOGSDB);
5152

5253
public static final List<ActionType<XPackInfoFeatureResponse>> ALL = List.of(
5354
SECURITY,
@@ -75,7 +76,8 @@ public class XPackInfoFeatureAction {
7576
AGGREGATE_METRIC,
7677
ARCHIVE,
7778
ENTERPRISE_SEARCH,
78-
UNIVERSAL_PROFILING
79+
UNIVERSAL_PROFILING,
80+
LOGSDB
7981
);
8082

8183
public static ActionType<XPackInfoFeatureResponse> xpackInfoFeatureAction(String suffix) {

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/XPackUsageFeatureAction.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ private XPackUsageFeatureAction() {/* no instances */}
5858
public static final ActionType<XPackUsageFeatureResponse> REMOTE_CLUSTERS = xpackUsageFeatureAction(XPackField.REMOTE_CLUSTERS);
5959
public static final ActionType<XPackUsageFeatureResponse> ENTERPRISE_SEARCH = xpackUsageFeatureAction(XPackField.ENTERPRISE_SEARCH);
6060
public static final ActionType<XPackUsageFeatureResponse> UNIVERSAL_PROFILING = xpackUsageFeatureAction(XPackField.UNIVERSAL_PROFILING);
61+
public static final ActionType<XPackUsageFeatureResponse> LOGSDB = xpackUsageFeatureAction(XPackField.LOGSDB);
6162

6263
static final List<ActionType<XPackUsageFeatureResponse>> ALL = List.of(
6364
AGGREGATE_METRIC,
@@ -88,7 +89,8 @@ private XPackUsageFeatureAction() {/* no instances */}
8889
HEALTH,
8990
REMOTE_CLUSTERS,
9091
ENTERPRISE_SEARCH,
91-
UNIVERSAL_PROFILING
92+
UNIVERSAL_PROFILING,
93+
LOGSDB
9294
);
9395

9496
public static ActionType<XPackUsageFeatureResponse> xpackUsageFeatureAction(String suffix) {
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
package org.elasticsearch.xpack.core.application;
8+
9+
import org.elasticsearch.TransportVersion;
10+
import org.elasticsearch.TransportVersions;
11+
import org.elasticsearch.common.io.stream.StreamInput;
12+
import org.elasticsearch.common.io.stream.StreamOutput;
13+
import org.elasticsearch.xcontent.XContentBuilder;
14+
import org.elasticsearch.xpack.core.XPackFeatureUsage;
15+
import org.elasticsearch.xpack.core.XPackField;
16+
17+
import java.io.IOException;
18+
import java.util.Objects;
19+
20+
public final class LogsDBFeatureSetUsage extends XPackFeatureUsage {
21+
private final int indicesCount;
22+
private final int indicesWithSyntheticSource;
23+
24+
public LogsDBFeatureSetUsage(StreamInput input) throws IOException {
25+
super(input);
26+
indicesCount = input.readVInt();
27+
indicesWithSyntheticSource = input.readVInt();
28+
}
29+
30+
@Override
31+
public void writeTo(StreamOutput out) throws IOException {
32+
super.writeTo(out);
33+
out.writeVInt(indicesCount);
34+
out.writeVInt(indicesWithSyntheticSource);
35+
}
36+
37+
public LogsDBFeatureSetUsage(boolean available, boolean enabled, int indicesCount, int indicesWithSyntheticSource) {
38+
super(XPackField.LOGSDB, available, enabled);
39+
this.indicesCount = indicesCount;
40+
this.indicesWithSyntheticSource = indicesWithSyntheticSource;
41+
}
42+
43+
@Override
44+
public TransportVersion getMinimalSupportedVersion() {
45+
return TransportVersions.LOGSDB_TELEMETRY;
46+
}
47+
48+
@Override
49+
protected void innerXContent(XContentBuilder builder, Params params) throws IOException {
50+
super.innerXContent(builder, params);
51+
builder.field("indices_count", indicesCount);
52+
builder.field("indices_with_synthetic_source", indicesWithSyntheticSource);
53+
}
54+
55+
@Override
56+
public int hashCode() {
57+
return Objects.hash(available, enabled, indicesCount, indicesWithSyntheticSource);
58+
}
59+
60+
@Override
61+
public boolean equals(Object obj) {
62+
if (obj == null) {
63+
return false;
64+
}
65+
if (getClass() != obj.getClass()) {
66+
return false;
67+
}
68+
LogsDBFeatureSetUsage other = (LogsDBFeatureSetUsage) obj;
69+
return Objects.equals(available, other.available)
70+
&& Objects.equals(enabled, other.enabled)
71+
&& Objects.equals(indicesCount, other.indicesCount)
72+
&& Objects.equals(indicesWithSyntheticSource, other.indicesWithSyntheticSource);
73+
}
74+
}

0 commit comments

Comments
 (0)