-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conditionally enable logsdb by default (#121049)
Enable logsdb by default if logsdb.prior_logs_usage has not been set to true. Meaning that if no data streams were created matching with the logs-- pattern in 8.x, then logsdb will be enabled by default for data streams matching with logs-*-* pattern. Also removes LogsPatternUsageService as with version 9.0 and beyond, this component is no longer necessary. Followup from #120708 Closes #106489
- Loading branch information
Showing
14 changed files
with
178 additions
and
554 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -291,6 +291,7 @@ | |
"JVM option", | ||
"Java API", | ||
"Logging", | ||
"Logs", | ||
"Mapping", | ||
"Packaging", | ||
"Painless", | ||
|
This file contains 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,19 @@ | ||
pr: 121049 | ||
summary: Conditionally enable logsdb by default for data streams matching with logs-*-* | ||
pattern. | ||
area: Logs | ||
type: breaking | ||
issues: | ||
- 106489 | ||
breaking: | ||
title: Conditionally enable logsdb by default | ||
area: Logs | ||
details: |- | ||
Logsdb will be enabled by default for data streams matching with logs-*-* pattern. | ||
If upgrading from 8.x to 9.x and data streams matching with log-*-* do exist, | ||
then Logsdb will not be enabled by default. | ||
impact: |- | ||
Logsdb reduce storage footprint in Elasticsearch for logs, but there are side effects | ||
to be taken into account that are described in the Logsdb docs: | ||
https://www.elastic.co/guide/en/elasticsearch/reference/current/logs-data-stream.html#upgrade-to-logsdb-notes | ||
notable: true |
This file contains 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 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 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 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
71 changes: 71 additions & 0 deletions
71
...g-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/LogsUsageRollingUpgradeIT.java
This file contains 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,71 @@ | ||
/* | ||
* 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", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
package org.elasticsearch.upgrades; | ||
|
||
import com.carrotsearch.randomizedtesting.annotations.Name; | ||
|
||
import org.elasticsearch.client.Request; | ||
|
||
import java.io.IOException; | ||
import java.time.Instant; | ||
import java.util.Map; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import static org.elasticsearch.upgrades.LogsdbIndexingRollingUpgradeIT.bulkIndex; | ||
import static org.hamcrest.Matchers.hasEntry; | ||
import static org.hamcrest.Matchers.hasKey; | ||
import static org.hamcrest.Matchers.not; | ||
|
||
public class LogsUsageRollingUpgradeIT extends AbstractRollingUpgradeTestCase { | ||
|
||
public LogsUsageRollingUpgradeIT(@Name("upgradedNodes") int upgradedNodes) { | ||
super(upgradedNodes); | ||
} | ||
|
||
public void testUsage() throws Exception { | ||
assumeTrue("logsdb.prior_logs_usage only gets set in 8.x", getOldClusterTestVersion().before("9.0.0")); | ||
String dataStreamName = "logs-mysql-error"; | ||
if (isOldCluster()) { | ||
bulkIndex(dataStreamName, 4, 256, Instant.now()); | ||
ensureGreen(dataStreamName); | ||
assertBusy(() -> { | ||
var getClusterSettingsResponse = getClusterSettings(); | ||
Map<?, ?> persistentSettings = (Map<?, ?>) getClusterSettingsResponse.get("persistent"); | ||
assertThat(persistentSettings, hasEntry("logsdb.prior_logs_usage", "true")); | ||
}, 2, TimeUnit.MINUTES); | ||
} else { | ||
String newIndex = rolloverDataStream(dataStreamName); | ||
bulkIndex(dataStreamName, 4, 256, Instant.now()); | ||
Map<?, ?> indexResponse = (Map<?, ?>) getIndexSettings(newIndex, true).get(newIndex); | ||
Map<?, ?> settings = (Map<?, ?>) indexResponse.get("settings"); | ||
Map<?, ?> defaults = (Map<?, ?>) indexResponse.get("defaults"); | ||
assertThat(settings, not(hasKey("index.mode"))); | ||
assertThat(defaults, hasEntry("index.mode", "standard")); | ||
} | ||
} | ||
|
||
static Map<String, Object> getClusterSettings() throws IOException { | ||
var request = new Request("GET", "/_cluster/settings"); | ||
request.addParameter("flat_settings", "true"); | ||
request.addParameter("include_defaults", "true"); | ||
var response = client().performRequest(request); | ||
assertOK(response); | ||
return entityAsMap(response); | ||
} | ||
|
||
static String rolloverDataStream(String dataStreamName) throws IOException { | ||
var request = new Request("POST", "/" + dataStreamName + "/_rollover"); | ||
var response = client().performRequest(request); | ||
assertOK(response); | ||
var responseBody = entityAsMap(response); | ||
return (String) responseBody.get("new_index"); | ||
} | ||
|
||
} |
This file contains 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
49 changes: 49 additions & 0 deletions
49
...upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/NoLogsUsageRollingUpgradeIT.java
This file contains 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,49 @@ | ||
/* | ||
* 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", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
package org.elasticsearch.upgrades; | ||
|
||
import com.carrotsearch.randomizedtesting.annotations.Name; | ||
|
||
import java.time.Instant; | ||
import java.util.Map; | ||
|
||
import static org.elasticsearch.upgrades.LogsUsageRollingUpgradeIT.getClusterSettings; | ||
import static org.elasticsearch.upgrades.LogsdbIndexingRollingUpgradeIT.bulkIndex; | ||
import static org.hamcrest.Matchers.hasEntry; | ||
import static org.hamcrest.Matchers.hasKey; | ||
import static org.hamcrest.Matchers.not; | ||
|
||
public class NoLogsUsageRollingUpgradeIT extends AbstractRollingUpgradeTestCase { | ||
|
||
public NoLogsUsageRollingUpgradeIT(@Name("upgradedNodes") int upgradedNodes) { | ||
super(upgradedNodes); | ||
} | ||
|
||
public void testUsage() throws Exception { | ||
String dataStreamName = "logs-mysql-error"; | ||
if (isOldCluster()) { | ||
dataStreamName = dataStreamName.replace("logs-", "log-"); | ||
bulkIndex(dataStreamName, 4, 256, Instant.now()); | ||
ensureGreen(dataStreamName); | ||
} else if (isUpgradedCluster()) { | ||
String newIndex = bulkIndex(dataStreamName, 4, 256, Instant.now()); | ||
ensureGreen(dataStreamName); | ||
Map<?, ?> indexResponse = (Map<?, ?>) getIndexSettings(newIndex, true).get(newIndex); | ||
Map<?, ?> settings = (Map<?, ?>) indexResponse.get("settings"); | ||
assertThat(settings, hasEntry("index.mode", "logsdb")); | ||
var getClusterSettingsResponse = getClusterSettings(); | ||
Map<?, ?> defaults = (Map<?, ?>) getClusterSettingsResponse.get("defaults"); | ||
Map<?, ?> persistentSettings = (Map<?, ?>) getClusterSettingsResponse.get("persistent"); | ||
assertThat(persistentSettings, not(hasKey("logsdb.prior_logs_usage"))); | ||
assertThat(defaults, hasEntry("cluster.logsdb.enabled", "true")); | ||
} | ||
} | ||
|
||
} |
This file contains 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 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.