Skip to content

Commit

Permalink
WIP - tel
Browse files Browse the repository at this point in the history
  • Loading branch information
dnhatn committed Oct 31, 2024
1 parent bf21bd3 commit b387bdc
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 5 deletions.
4 changes: 4 additions & 0 deletions docs/reference/rest-api/info.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ Example response:
"universal_profiling": {
"available": true,
"enabled": true
},
"logsdb": {
"available": true,
"enabled": true
}
},
"tagline" : "You know, for X"
Expand Down
6 changes: 6 additions & 0 deletions docs/reference/rest-api/usage.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,12 @@ GET /_xpack/usage
"universal_profiling" : {
"available" : true,
"enabled" : true
},
"logsdb": {
"available": true,
"enabled": true,
"indices_count": 0,
"indices_with_synthetic_source": 0
}
}
------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ public List<NamedWriteableRegistry.Entry> getNamedWriteables() {
PersistentTaskParams.class,
SecurityMigrationTaskParams.TASK_NAME,
SecurityMigrationTaskParams::new
)
),
new NamedWriteableRegistry.Entry(XPackFeatureUsage.class, XPackField.LOGSDB, LogstashFeatureSetUsage::new)
).filter(Objects::nonNull).toList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
* Provides the XPack features that this version of the code supports
*/
public class XPackFeatures implements FeatureSpecification {
public static final NodeFeature LOGSDB_TELEMETRY = new NodeFeature("logsdb_telemetry");

@Override
public Set<NodeFeature> getFeatures() {
return Set.of(
NodesDataTiersUsageTransportAction.LOCALLY_PRECALCULATED_STATS_FEATURE, // Added in 8.12
License.INDEPENDENT_TRIAL_VERSION_FEATURE // 8.14.0
License.INDEPENDENT_TRIAL_VERSION_FEATURE, // 8.14.0
LOGSDB_TELEMETRY
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
package org.elasticsearch.xpack.logsdb;
package org.elasticsearch.xpack.core.application;

import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
Expand All @@ -17,7 +17,7 @@
import java.io.IOException;
import java.util.Objects;

public class LogsDBFeatureSetUsage extends XPackFeatureUsage {
public final class LogsDBFeatureSetUsage extends XPackFeatureUsage {

private final int indicesCount;
private final int indicesWithSyntheticSource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,25 @@

package org.elasticsearch.xpack.logsdb;

import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexSettingProvider;
import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.xpack.core.XPackPlugin;
import org.elasticsearch.xpack.core.action.XPackInfoFeatureAction;
import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import static org.elasticsearch.xpack.logsdb.SyntheticSourceLicenseService.FALLBACK_SETTING;

public class LogsDBPlugin extends Plugin {
public class LogsDBPlugin extends Plugin implements ActionPlugin {

private final Settings settings;
private final SyntheticSourceLicenseService licenseService;
Expand Down Expand Up @@ -66,4 +72,12 @@ public Collection<IndexSettingProvider> getAdditionalIndexSettingProviders(Index
public List<Setting<?>> getSettings() {
return List.of(FALLBACK_SETTING, CLUSTER_LOGSDB_ENABLED);
}

@Override
public List<ActionPlugin.ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
List<ActionPlugin.ActionHandler<? extends ActionRequest, ? extends ActionResponse>> actions = new ArrayList<>();
actions.add(new ActionPlugin.ActionHandler<>(XPackUsageFeatureAction.LOGSDB, LogsDBUsageTransportAction.class));
actions.add(new ActionPlugin.ActionHandler<>(XPackInfoFeatureAction.LOGSDB, LogsDBInfoTransportAction.class));
return actions;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
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;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
logsdb usage:
- requires:
cluster_features: ["logsdb_telemetry"]
reason: "requires logsdb telemetry"
- do:
indices.create:
index: test1
body:
settings:
index:
mode: logsdb

- do: {xpack.usage: {}}
- match: { logsdb.available: true }
- match: { logsdb.enabled: true }
- match: { logsdb.indices_count: 1 }
- match: { logsdb.indices_with_synthetic_source: 1 }

- do:
indices.create:
index: test2

- do: {xpack.usage: {}}
- match: { logsdb.available: true }
- match: { logsdb.enabled: true }
- match: { logsdb.indices_count: 2 }
- match: { logsdb.indices_with_synthetic_source: 1 }

- do:
indices.create:
index: test3
body:
settings:
index:
mode: logsdb
mapping.source.mode: stored

- do: {xpack.usage: {}}
- match: { logsdb.available: true }
- match: { logsdb.enabled: true }
- match: { logsdb.indices_count: 2 }
- match: { logsdb.indices_with_synthetic_source: 1 }
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
logsdb usage:
- do:
indices.create:
index: test1
body:
settings:
index:
mode: logsdb

- do: {xpack.usage: {}}
- match: { logsdb.available: true }
- match: { logsdb.enabled: true }
- match: { logsdb.indices_count: 1 }
- match: { logsdb.indices_with_synthetic_source: 1 }

- do:
indices.create:
index: test2

- do: {xpack.usage: {}}
- match: { logsdb.available: true }
- match: { logsdb.enabled: true }
- match: { logsdb.indices_count: 2 }
- match: { logsdb.indices_with_synthetic_source: 1 }

- do:
indices.create:
index: test3
body:
settings:
index:
mode: logsdb
mapping.source.mode: stored

- do: {xpack.usage: {}}
- match: { logsdb.available: true }
- match: { logsdb.enabled: true }
- match: { logsdb.indices_count: 2 }
- match: { logsdb.indices_with_synthetic_source: 1 }

0 comments on commit b387bdc

Please sign in to comment.