Skip to content

Commit

Permalink
Merge branch 'master' into issue-17185
Browse files Browse the repository at this point in the history
  • Loading branch information
ousmaneo authored Nov 14, 2023
2 parents 35bda58 + a95c74c commit 0a8da99
Show file tree
Hide file tree
Showing 24 changed files with 858 additions and 54 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/pr-17042.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type = "a"
message = "Including basic data node usage information in telemetry."

pulls = ["17042"]

5 changes: 5 additions & 0 deletions changelog/unreleased/pr-17070.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type = "added"
message = "Add index set field type management page"

issues = ["17160"]
pulls = ["17070"]
2 changes: 1 addition & 1 deletion data-node/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@

<plugins>
<plugin>
<groupId>com.googlecode.maven-download-plugin</groupId>
<groupId>org.graylog.repackaged</groupId>
<artifactId>download-maven-plugin</artifactId>
<version>${download-maven-plugin.version}</version>
<executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class TelemetryResponseFactory {
private static final String LICENSE = "license";
private static final String PLUGIN = "plugin";
private static final String SEARCH_CLUSTER = "search_cluster";
private static final String DATA_NODES = "data_nodes";

private static boolean isLeader(Map<String, Object> n) {
if (n.get(FIELD_IS_LEADER) instanceof Boolean isLeader) {
Expand All @@ -52,14 +53,16 @@ Map<String, Object> createTelemetryResponse(Map<String, Object> clusterInfo,
Map<String, Object> pluginInfo,
Map<String, Object> searchClusterInfo,
List<TelemetryLicenseStatus> licenseStatuses,
TelemetryUserSettings telemetryUserSettings) {
TelemetryUserSettings telemetryUserSettings,
Map<String, Object> dataNodeInfo) {
Map<String, Object> telemetryResponse = new LinkedHashMap<>();
telemetryResponse.put(CURRENT_USER, userInfo);
telemetryResponse.put(USER_TELEMETRY_SETTINGS, telemetryUserSettings);
telemetryResponse.put(CLUSTER, clusterInfo);
telemetryResponse.put(LICENSE, createLicenseInfo(licenseStatuses));
telemetryResponse.put(PLUGIN, pluginInfo);
telemetryResponse.put(SEARCH_CLUSTER, searchClusterInfo);
telemetryResponse.put(DATA_NODES, dataNodeInfo);
return telemetryResponse;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import com.google.common.hash.HashCode;
import org.graylog2.cluster.Node;
import org.graylog2.cluster.NodeService;
import org.graylog2.indexer.cluster.ClusterAdapter;
import org.graylog2.plugin.PluginMetaData;
import org.graylog2.plugin.database.users.User;
Expand Down Expand Up @@ -65,7 +67,7 @@ public class TelemetryService {
private final boolean isTelemetryEnabled;
private final TelemetryClusterService telemetryClusterService;
private final String installationSource;

private final NodeService nodeService;

@Inject
public TelemetryService(
Expand All @@ -80,7 +82,8 @@ public TelemetryService(
DBTelemetryUserSettingsService dbTelemetryUserSettingsService,
EventBus eventBus,
TelemetryClusterService telemetryClusterService,
@Named("installation_source") String installationSource) {
@Named("installation_source") String installationSource,
NodeService nodeService) {
this.isTelemetryEnabled = isTelemetryEnabled;
this.trafficCounterService = trafficCounterService;
this.enterpriseDataProvider = enterpriseDataProvider;
Expand All @@ -92,6 +95,7 @@ public TelemetryService(
this.dbTelemetryUserSettingsService = dbTelemetryUserSettingsService;
this.telemetryClusterService = telemetryClusterService;
this.installationSource = installationSource;
this.nodeService = nodeService;
eventBus.register(this);
}

Expand All @@ -108,7 +112,8 @@ public Map<String, Object> getTelemetryResponse(User currentUser) {
getPluginInfo(),
getSearchClusterInfo(),
licenseStatuses,
telemetryUserSettings);
telemetryUserSettings,
getDataNodeInfo());
} else {
return telemetryResponseFactory.createTelemetryDisabledResponse(telemetryUserSettings);
}
Expand Down Expand Up @@ -206,4 +211,11 @@ private Map<String, Object> getSearchClusterInfo() {
elasticsearchVersion.toString(),
nodesInfo);
}

private Map<String, Object> getDataNodeInfo() {
final var dataNodes = nodeService.allActive(Node.Type.DATANODE);
return Map.of(
"data_nodes_count", dataNodes.size()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.graylog2.telemetry.rest;

import com.google.common.eventbus.EventBus;
import org.graylog2.cluster.NodeService;
import org.graylog2.indexer.cluster.ClusterAdapter;
import org.graylog2.plugin.PluginMetaData;
import org.graylog2.plugin.database.users.User;
Expand Down Expand Up @@ -45,6 +46,7 @@
import static org.graylog2.shared.utilities.StringUtils.f;
import static org.graylog2.telemetry.rest.TelemetryTestHelper.CLUSTER;
import static org.graylog2.telemetry.rest.TelemetryTestHelper.CURRENT_USER;
import static org.graylog2.telemetry.rest.TelemetryTestHelper.DATA_NODES;
import static org.graylog2.telemetry.rest.TelemetryTestHelper.LICENSE;
import static org.graylog2.telemetry.rest.TelemetryTestHelper.PLUGIN;
import static org.graylog2.telemetry.rest.TelemetryTestHelper.SEARCH_CLUSTER;
Expand Down Expand Up @@ -77,6 +79,9 @@ public class TelemetryServiceTest {
@Mock
User user;

@Mock
NodeService nodeService;

@Test
void test_telemetry_is_disabled_globally() {
TelemetryService telemetryService = createTelemetryService(false);
Expand Down Expand Up @@ -177,7 +182,7 @@ private TelemetryLicenseStatus createLicense(String subject) {
}

private void assertThatAllTelemetryDataIsPresent(Map<String, Object> response) {
assertThat(response).containsOnlyKeys(USER_TELEMETRY_SETTINGS, CURRENT_USER, CLUSTER, LICENSE, PLUGIN, SEARCH_CLUSTER);
assertThat(response).containsOnlyKeys(USER_TELEMETRY_SETTINGS, CURRENT_USER, CLUSTER, LICENSE, PLUGIN, SEARCH_CLUSTER, DATA_NODES);
}

private TelemetryService createTelemetryService(boolean isTelemetryEnabled) {
Expand All @@ -193,7 +198,8 @@ private TelemetryService createTelemetryService(boolean isTelemetryEnabled) {
dbTelemetryUserSettingsService,
eventBus,
telemetryClusterService,
"unknown");
"unknown",
nodeService);
}

private void mockUserTelemetryEnabled(boolean isTelemetryEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.google.common.eventbus.EventBus;
import org.graylog.testing.mongodb.MongoDBInstance;
import org.graylog2.bindings.providers.MongoJackObjectMapperProvider;
import org.graylog2.cluster.NodeService;
import org.graylog2.cluster.leader.LeaderElectionService;
import org.graylog2.indexer.cluster.ClusterAdapter;
import org.graylog2.plugin.PluginMetaData;
Expand Down Expand Up @@ -50,6 +51,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.graylog2.telemetry.rest.TelemetryTestHelper.CLUSTER;
import static org.graylog2.telemetry.rest.TelemetryTestHelper.CURRENT_USER;
import static org.graylog2.telemetry.rest.TelemetryTestHelper.DATA_NODES;
import static org.graylog2.telemetry.rest.TelemetryTestHelper.LICENSE;
import static org.graylog2.telemetry.rest.TelemetryTestHelper.PLUGIN;
import static org.graylog2.telemetry.rest.TelemetryTestHelper.SEARCH_CLUSTER;
Expand Down Expand Up @@ -88,6 +90,9 @@ public class TelemetryServiceWithDbTest {
@Mock
LeaderElectionService leaderElectionService;

@Mock
NodeService nodeService;

TelemetryService telemetryService;

@Before
Expand All @@ -111,7 +116,8 @@ public void setUp() {
new DBTelemetryUserSettingsService(mongodb.mongoConnection(), mongoJackObjectMapperProvider),
eventBus,
telemetryClusterService,
"unknown");
"unknown",
nodeService);
}

@Test
Expand Down Expand Up @@ -153,7 +159,7 @@ public void test_all_telemetry_data_is_present() {
telemetryService.updateTelemetryClusterData();
Map<String, Object> telemetryResponse = telemetryService.getTelemetryResponse(saveUserSettings(true));

assertThat(telemetryResponse).containsOnlyKeys(USER_TELEMETRY_SETTINGS, CURRENT_USER, CLUSTER, LICENSE, PLUGIN, SEARCH_CLUSTER);
assertThat(telemetryResponse).containsOnlyKeys(USER_TELEMETRY_SETTINGS, CURRENT_USER, CLUSTER, LICENSE, PLUGIN, SEARCH_CLUSTER, DATA_NODES);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public class TelemetryTestHelper {
static final String PLUGIN = "plugin";
static final String SEARCH_CLUSTER = "search_cluster";

static final String DATA_NODES = "data_nodes";

public static void mockTrafficData(TrafficCounterService trafficCounterService1) {
when(trafficCounterService1.clusterTrafficOfLastDays(any(), any())).thenReturn(TelemetryTestHelper.TRAFFIC_HISTOGRAM);
}
Expand Down
Loading

0 comments on commit 0a8da99

Please sign in to comment.