Skip to content

Commit

Permalink
Merge branch 'main' into overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkyle authored Nov 13, 2024
2 parents 961219b + c05a87a commit 84c6296
Show file tree
Hide file tree
Showing 32 changed files with 595 additions and 354 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/113194.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 113194
summary: Add Search Phase APM metrics
area: Search
type: enhancement
issues: []
5 changes: 5 additions & 0 deletions docs/changelog/116357.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 116357
summary: Add tracking for query rule types
area: Relevance
type: enhancement
issues: []
12 changes: 11 additions & 1 deletion docs/reference/query-rules/apis/list-query-rulesets.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ PUT _query_rules/ruleset-3
},
{
"rule_id": "rule-3",
"type": "pinned",
"type": "exclude",
"criteria": [
{
"type": "fuzzy",
Expand Down Expand Up @@ -178,6 +178,9 @@ A sample response:
"rule_total_count": 1,
"rule_criteria_types_counts": {
"exact": 1
},
"rule_type_counts": {
"pinned": 1
}
},
{
Expand All @@ -186,6 +189,9 @@ A sample response:
"rule_criteria_types_counts": {
"exact": 1,
"fuzzy": 1
},
"rule_type_counts": {
"pinned": 2
}
},
{
Expand All @@ -194,6 +200,10 @@ A sample response:
"rule_criteria_types_counts": {
"exact": 1,
"fuzzy": 2
},
"rule_type_counts": {
"pinned": 2,
"exclude": 1
}
}
]
Expand Down
5 changes: 5 additions & 0 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ tests:
- class: org.elasticsearch.snapshots.SnapshotShutdownIT
method: testRestartNodeDuringSnapshot
issue: https://github.com/elastic/elasticsearch/issues/116730
- class: org.elasticsearch.action.search.SearchRequestTests
method: testSerializationConstants
issue: https://github.com/elastic/elasticsearch/issues/116752
- class: org.elasticsearch.xpack.security.authc.ldap.ActiveDirectoryGroupsResolverTests
issue: https://github.com/elastic/elasticsearch/issues/116182

# Examples:
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@

package org.elasticsearch.cluster.routing.allocation.allocator;

import org.elasticsearch.cluster.ClusterInfoService;
import org.elasticsearch.cluster.ClusterInfoServiceUtils;
import org.elasticsearch.cluster.InternalClusterInfoService;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.util.CollectionUtils;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.telemetry.TestTelemetryPlugin;
Expand Down Expand Up @@ -56,8 +60,15 @@ public void testDesiredBalanceGaugeMetricsAreOnlyPublishedByCurrentMaster() thro
public void testDesiredBalanceMetrics() {
internalCluster().startNodes(2);
prepareCreate("test").setSettings(indexSettings(2, 1)).get();
indexRandom(randomBoolean(), "test", between(50, 100));
ensureGreen();

indexRandom(randomBoolean(), "test", between(50, 100));
flush("test");
// Make sure new cluster info is available
final var infoService = (InternalClusterInfoService) internalCluster().getCurrentMasterNodeInstance(ClusterInfoService.class);
ClusterInfoServiceUtils.setUpdateFrequency(infoService, TimeValue.timeValueMillis(200));
assertNotNull("info should not be null", ClusterInfoServiceUtils.refresh(infoService));

final var telemetryPlugin = getTelemetryPlugin(internalCluster().getMasterName());
telemetryPlugin.collect();
assertThat(telemetryPlugin.getLongGaugeMeasurement(DesiredBalanceMetrics.UNASSIGNED_SHARDS_METRIC_NAME), not(empty()));
Expand All @@ -73,7 +84,7 @@ public void testDesiredBalanceMetrics() {
);
assertThat(desiredBalanceNodeWeightsMetrics.size(), equalTo(2));
for (var nodeStat : desiredBalanceNodeWeightsMetrics) {
assertThat(nodeStat.value().doubleValue(), greaterThanOrEqualTo(0.0));
assertTrue(nodeStat.isDouble());
assertThat((String) nodeStat.attributes().get("node_id"), is(in(nodeIds)));
assertThat((String) nodeStat.attributes().get("node_name"), is(in(nodeNames)));
}
Expand Down Expand Up @@ -122,15 +133,16 @@ public void testDesiredBalanceMetrics() {
assertThat((String) nodeStat.attributes().get("node_id"), is(in(nodeIds)));
assertThat((String) nodeStat.attributes().get("node_name"), is(in(nodeNames)));
}
final var currentNodeDiskUsageMetrics = telemetryPlugin.getDoubleGaugeMeasurement(
final var currentNodeDiskUsageMetrics = telemetryPlugin.getLongGaugeMeasurement(
DesiredBalanceMetrics.CURRENT_NODE_DISK_USAGE_METRIC_NAME
);
assertThat(currentNodeDiskUsageMetrics.size(), equalTo(2));
for (var nodeStat : currentNodeDiskUsageMetrics) {
assertThat(nodeStat.value().doubleValue(), greaterThanOrEqualTo(0.0));
assertThat(nodeStat.value().longValue(), greaterThanOrEqualTo(0L));
assertThat((String) nodeStat.attributes().get("node_id"), is(in(nodeIds)));
assertThat((String) nodeStat.attributes().get("node_name"), is(in(nodeNames)));
}
assertTrue(currentNodeDiskUsageMetrics.stream().anyMatch(m -> m.getLong() > 0L));
final var currentNodeUndesiredShardCountMetrics = telemetryPlugin.getLongGaugeMeasurement(
DesiredBalanceMetrics.CURRENT_NODE_UNDESIRED_SHARD_COUNT_METRIC_NAME
);
Expand All @@ -140,15 +152,16 @@ public void testDesiredBalanceMetrics() {
assertThat((String) nodeStat.attributes().get("node_id"), is(in(nodeIds)));
assertThat((String) nodeStat.attributes().get("node_name"), is(in(nodeNames)));
}
final var currentNodeForecastedDiskUsageMetrics = telemetryPlugin.getDoubleGaugeMeasurement(
final var currentNodeForecastedDiskUsageMetrics = telemetryPlugin.getLongGaugeMeasurement(
DesiredBalanceMetrics.CURRENT_NODE_FORECASTED_DISK_USAGE_METRIC_NAME
);
assertThat(currentNodeForecastedDiskUsageMetrics.size(), equalTo(2));
for (var nodeStat : currentNodeForecastedDiskUsageMetrics) {
assertThat(nodeStat.value().doubleValue(), greaterThanOrEqualTo(0.0));
assertThat(nodeStat.value().longValue(), greaterThanOrEqualTo(0L));
assertThat((String) nodeStat.attributes().get("node_id"), is(in(nodeIds)));
assertThat((String) nodeStat.attributes().get("node_name"), is(in(nodeNames)));
}
assertTrue(currentNodeForecastedDiskUsageMetrics.stream().anyMatch(m -> m.getLong() > 0L));
}

private static void assertOnlyMasterIsPublishingMetrics() {
Expand Down Expand Up @@ -182,10 +195,10 @@ private static void assertMetricsAreBeingPublished(String nodeName, boolean shou
matcher
);
assertThat(testTelemetryPlugin.getDoubleGaugeMeasurement(DesiredBalanceMetrics.CURRENT_NODE_WRITE_LOAD_METRIC_NAME), matcher);
assertThat(testTelemetryPlugin.getDoubleGaugeMeasurement(DesiredBalanceMetrics.CURRENT_NODE_DISK_USAGE_METRIC_NAME), matcher);
assertThat(testTelemetryPlugin.getLongGaugeMeasurement(DesiredBalanceMetrics.CURRENT_NODE_DISK_USAGE_METRIC_NAME), matcher);
assertThat(testTelemetryPlugin.getLongGaugeMeasurement(DesiredBalanceMetrics.CURRENT_NODE_SHARD_COUNT_METRIC_NAME), matcher);
assertThat(
testTelemetryPlugin.getDoubleGaugeMeasurement(DesiredBalanceMetrics.CURRENT_NODE_FORECASTED_DISK_USAGE_METRIC_NAME),
testTelemetryPlugin.getLongGaugeMeasurement(DesiredBalanceMetrics.CURRENT_NODE_FORECASTED_DISK_USAGE_METRIC_NAME),
matcher
);
assertThat(
Expand Down
2 changes: 2 additions & 0 deletions server/src/main/java/org/elasticsearch/TransportVersions.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ static TransportVersion def(int id) {
public static final TransportVersion ADD_COMPATIBILITY_VERSIONS_TO_NODE_INFO = def(8_789_00_0);
public static final TransportVersion VERTEX_AI_INPUT_TYPE_ADDED = def(8_790_00_0);
public static final TransportVersion SKIP_INNER_HITS_SEARCH_SOURCE = def(8_791_00_0);
public static final TransportVersion QUERY_RULES_LIST_INCLUDES_TYPES = def(8_792_00_0);

/*
* STOP! READ THIS FIRST! No, really,
* ____ _____ ___ ____ _ ____ _____ _ ____ _____ _ _ ___ ____ _____ ___ ____ ____ _____ _
Expand Down

This file was deleted.

Loading

0 comments on commit 84c6296

Please sign in to comment.