Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable deprecation log indexing by default #78319

Closed
Closed
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
94404f4
draft
pgomulka Sep 9, 2021
aa33bcf
default
pgomulka Sep 27, 2021
9546c5d
Merge remote-tracking branch 'upstream/master' into enable_deprecatio…
pgomulka Sep 27, 2021
5317180
use settings consumer
pgomulka Sep 28, 2021
66c1963
Merge remote-tracking branch 'upstream/master' into enable_deprecatio…
pgomulka Sep 28, 2021
b094f07
register setting
pgomulka Sep 28, 2021
42ca5f2
imports
pgomulka Sep 28, 2021
78ad881
enable settings on startup
pgomulka Sep 28, 2021
0091139
testcase
pgomulka Sep 28, 2021
a822e9d
remove comment
pgomulka Sep 28, 2021
aae2ec7
spotless
pgomulka Sep 28, 2021
736e508
docs
pgomulka Sep 28, 2021
5e747d6
Merge remote-tracking branch 'upstream/master' into enable_deprecatio…
pgomulka Sep 28, 2021
d8307ee
still failing test
pgomulka Sep 28, 2021
c7f12b7
code style
pgomulka Sep 28, 2021
41706ae
Merge remote-tracking branch 'upstream/master' into enable_deprecatio…
pgomulka Oct 1, 2021
d7d3b8d
fix tests
pgomulka Oct 1, 2021
5901d0e
cleanup
pgomulka Oct 1, 2021
86527e9
Merge remote-tracking branch 'upstream/master' into enable_deprecatio…
pgomulka Oct 4, 2021
4fda733
remove assertion on startup
pgomulka Oct 4, 2021
b1624ce
move test to separate class
pgomulka Oct 4, 2021
a1c6829
style
pgomulka Oct 4, 2021
a913634
fix client in a test
pgomulka Oct 4, 2021
0595739
javadocs
pgomulka Oct 4, 2021
0030f00
Merge branch 'master' into enable_deprecation_indexing_by_default
elasticmachine Oct 4, 2021
789a3c4
do not delete logs deprecation ds
pgomulka Oct 5, 2021
ba94da6
Merge branch 'enable_deprecation_indexing_by_default' of github.com:p…
pgomulka Oct 5, 2021
31851e2
Merge remote-tracking branch 'upstream/master' into enable_deprecatio…
pgomulka Oct 5, 2021
ba4334e
deprecated settings test with cleanup
pgomulka Oct 5, 2021
18c4177
fix default value for setting
pgomulka Oct 5, 2021
0436f7b
fix some tests
pgomulka Oct 5, 2021
f76e48c
fix doc test
pgomulka Oct 5, 2021
fd63dac
delete hidden data stream
pgomulka Oct 6, 2021
7011616
Merge remote-tracking branch 'upstream/master' into enable_deprecatio…
pgomulka Oct 6, 2021
faf5a32
compile fix
pgomulka Oct 6, 2021
0c77b99
delete data stream *
pgomulka Oct 6, 2021
a2d3803
auto expand replica
pgomulka Oct 6, 2021
935f802
imports and todo
pgomulka Oct 6, 2021
2515dfd
Merge remote-tracking branch 'upstream/master' into enable_deprecatio…
pgomulka Oct 6, 2021
b34bd64
flush processor when disabeling the indexing
pgomulka Oct 6, 2021
bf33cf0
use exact template in docs on DELETE/_index_template/*
pgomulka Oct 6, 2021
c93abdd
remove index_template cleanup in gradle as it should be handled in tests
pgomulka Oct 6, 2021
3144ec8
disable deprecation indxing in docs and runtime fields
pgomulka Oct 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ PUT /_data_stream/new-data-stream

[source,console]
----
DELETE /_data_stream/*
DELETE /_data_stream/my-data-stream
DELETE /_data_stream/new-data-stream

DELETE /_index_template/*
DELETE /_index_template/new-data-stream-template
DELETE /_index_template/my-data-stream-template

DELETE /_ilm/policy/my-data-stream-policy
----
Expand Down
11 changes: 11 additions & 0 deletions docs/reference/setup/logging-config.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,17 @@ The user ID is included in the `X-Opaque-ID` field in deprecation JSON logs.
---------------------------
// NOTCONSOLE

Deprecation logs are indexed into `.logs-deprecation.elasticsearch-default` data stream by default.
You can disable deprecation log indexing by changing a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You can disable deprecation log indexing by changing a
You can disable deprecation log indexing by changing the

`cluster.deprecation_indexing.enabled` setting to false.

==== Deprecation logs throttling
Deprecation logs are deduplicated based on a deprecated feature key
and x-opaque-id so that if a feature is repeatedly used, it will not overload the deprecation logs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we link x-opaque-id to a description somewhere?

This applies to both indexed deprecation logs and logs emitted to log files.
You can disable the use of `x-opaque-id` in throttling by changing
`cluster.deprecation_indexing.x_opaque_id_used.enabled` to false

[discrete]
[[json-logging]]
=== JSON log format
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
@Plugin(name = "RateLimitingFilter", category = Node.CATEGORY, elementType = Filter.ELEMENT_TYPE)
public class RateLimitingFilter extends AbstractFilter {

private volatile boolean useXOpaqueId = true;

private final Set<String> lruKeyCache = Collections.newSetFromMap(Collections.synchronizedMap(new LinkedHashMap<>() {
@Override
protected boolean removeEldestEntry(final Map.Entry<String, Boolean> eldest) {
Expand All @@ -57,16 +59,23 @@ public Result filter(Message message) {
if (message instanceof ESLogMessage) {
final ESLogMessage esLogMessage = (ESLogMessage) message;

String xOpaqueId = esLogMessage.get(X_OPAQUE_ID_FIELD_NAME);
final String key = esLogMessage.get(KEY_FIELD_NAME);

return lruKeyCache.add(xOpaqueId + key) ? Result.ACCEPT : Result.DENY;
final String key = getKey(esLogMessage);
return lruKeyCache.add(key) ? Result.ACCEPT : Result.DENY;

} else {
return Result.NEUTRAL;
}
}

private String getKey(ESLogMessage esLogMessage) {
final String key = esLogMessage.get(KEY_FIELD_NAME);
if (useXOpaqueId) {
String xOpaqueId = esLogMessage.get(X_OPAQUE_ID_FIELD_NAME);
return xOpaqueId + key;
}
return key;
}

@Override
public Result filter(LogEvent event) {
return filter(event.getMessage());
Expand All @@ -84,4 +93,8 @@ public static RateLimitingFilter createFilter(
) {
return new RateLimitingFilter(match, mismatch);
}

public void setUseXOpaqueId(boolean useXOpaqueId) {
this.useXOpaqueId = useXOpaqueId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,26 @@ public void testFilterCanBeReset() {
// Third time, it is allowed again
assertThat(filter.filter(message), equalTo(Result.ACCEPT));
}

public void testMessagesXOpaqueIsIgnoredWhenDisabled() {
RateLimitingFilter filter = new RateLimitingFilter();
filter.setUseXOpaqueId(false);
filter.start();

// Should NOT be rate-limited because it's not in the cache
Message message = DeprecatedMessage.of(DeprecationCategory.OTHER, "key 0", "opaque-id 0", "msg 0");
assertThat(filter.filter(message), equalTo(Result.ACCEPT));

// Should be rate-limited because it was just added to the cache
message = DeprecatedMessage.of(DeprecationCategory.OTHER, "key 0", "opaque-id 0", "msg 0");
assertThat(filter.filter(message), equalTo(Result.DENY));

// Should be rate-limited because X-Opaque-Id is not used
message = DeprecatedMessage.of(DeprecationCategory.OTHER, "key 0", "opaque-id 1", "msg 0");
assertThat(filter.filter(message), equalTo(Result.DENY));

// Should NOT be rate-limited because "key 1" it not in the cache
message = DeprecatedMessage.of(DeprecationCategory.OTHER, "key 1", "opaque-id 1", "msg 0");
assertThat(filter.filter(message), equalTo(Result.ACCEPT));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.carrotsearch.randomizedtesting.annotations.TestGroup;
import com.carrotsearch.randomizedtesting.generators.RandomNumbers;
import com.carrotsearch.randomizedtesting.generators.RandomPicks;

import org.apache.http.HttpHost;
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.TotalHits;
Expand Down Expand Up @@ -69,11 +70,9 @@
import org.elasticsearch.cluster.routing.allocation.DiskThresholdSettings;
import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.common.Priority;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.core.Tuple;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.network.NetworkAddress;
import org.elasticsearch.common.network.NetworkModule;
Expand All @@ -84,7 +83,6 @@
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
Expand All @@ -94,6 +92,9 @@
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.common.xcontent.smile.SmileXContent;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.core.Tuple;
import org.elasticsearch.core.internal.io.IOUtils;
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.TestEnvironment;
Expand Down Expand Up @@ -171,8 +172,8 @@

import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.core.TimeValue.timeValueMillis;
import static org.elasticsearch.common.util.CollectionUtils.eagerPartition;
import static org.elasticsearch.core.TimeValue.timeValueMillis;
import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING;
import static org.elasticsearch.discovery.SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING;
import static org.elasticsearch.index.IndexSettings.INDEX_SOFT_DELETES_RETENTION_LEASE_PERIOD_SETTING;
Expand Down Expand Up @@ -571,7 +572,7 @@ private void afterInternal(boolean afterClass) throws Exception {
* @return An exclude set of index templates that will not be removed in between tests.
*/
protected Set<String> excludeTemplates() {
return Collections.emptySet();
return Set.of(".deprecation-indexing-template");
}

protected void beforeIndexDeletion() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ protected boolean preserveILMPoliciesUponCompletion() {
*/
protected Set<String> preserveILMPolicyIds() {
return Sets.newHashSet("ilm-history-ilm-policy", "slm-history-ilm-policy",
"watch-history-ilm-policy", "ml-size-based-ilm-policy", "logs", "metrics");
"watch-history-ilm-policy", "ml-size-based-ilm-policy", "logs", "metrics", ".deprecation-indexing-ilm-policy");
}

/**
Expand Down Expand Up @@ -782,7 +782,7 @@ protected static void wipeAllIndices() throws IOException {
boolean includeHidden = minimumNodeVersion().onOrAfter(Version.V_7_7_0);
try {
//remove all indices except ilm history which can pop up after deleting all data streams but shouldn't interfere
final Request deleteRequest = new Request("DELETE", "*,-.ds-ilm-history-*");
final Request deleteRequest = new Request("DELETE", "*,-.ds-ilm-history-*,-.ds-.logs-deprecation.elasticsearch-default-*");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you ask the Data Management team about this?

deleteRequest.addParameter("expand_wildcards", "open,closed" + (includeHidden ? ",hidden" : ""));
RequestOptions allowSystemIndexAccessWarningOptions = RequestOptions.DEFAULT.toBuilder()
.setWarningsHandler(warnings -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"template": {
"settings": {
"index": {
"hidden" : true,
"lifecycle": {
"name": ".deprecation-indexing-ilm-policy"
},
Expand Down
Loading