-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Write deprecation logs to a data stream #58924
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
Closed
pugnascotia
wants to merge
66
commits into
elastic:master
from
pugnascotia:index-deprecation-logs-v2
Closed
Changes from all commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
36ac092
Introduce DeprecationIndexingService
pugnascotia cf5a677
First go at ensuring the data stream template is loaded
pugnascotia 86c3d7d
Tweaks index name
pugnascotia d74dc9a
WIP - Adding tests for DeprecationIndexingService
pugnascotia 6457f97
More tests
pugnascotia f0e0192
Fix template index pattern
pugnascotia 581be1f
Merge remote-tracking branch 'upstream/master' into index-deprecation…
pugnascotia 14c929a
Rework deprecation code so that log handlers are more generic
pugnascotia e902fb9
Move DeprecationIndexingService to x-pack depreacation plugin
pugnascotia 40bea2c
Don't need a custom template any more :tada:
pugnascotia 013bf55
Remove unused import
pugnascotia 4c189da
Merge remote-tracking branch 'upstream/master' into index-deprecation…
pugnascotia d61b145
License header fix
pugnascotia ae62d06
Remove unused imports
pugnascotia 32d8316
Add Javadoc
pugnascotia 25ea88f
Silence log checker error
pugnascotia dce2a5d
Merge remote-tracking branch 'upstream/master' into index-deprecation…
pugnascotia 3482d31
Subtitute log message params, simplify things
pugnascotia 34e5529
Merge remote-tracking branch 'upstream/master' into index-deprecation…
pugnascotia f7f9ea7
Fixes
pugnascotia 46c5aca
Use BulkProcessor in DeprecationIndexingService
pugnascotia c8d8086
Use the opaque ID from the EsLogMessage
pugnascotia 4bf9b34
Record cluster and node IDs
pugnascotia 75eac35
Tweaks
pugnascotia abd8381
Merge remote-tracking branch 'upstream/master' into index-deprecation…
pugnascotia 8e4339f
WIP - trying a log4j implementation
pugnascotia d33b72b
Reimplement deprecation logging using log4j
pugnascotia 379ca5d
Merge remote-tracking branch 'upstream/master' into index-deprecation…
pugnascotia 4aead94
Reimplement using log4j abstractions
pugnascotia e8d246b
Polishing
pugnascotia 31ff5fe
Merge remote-tracking branch 'upstream/master' into index-deprecation…
pugnascotia 95e3fc3
More polishing
pugnascotia c0b8f65
Include key in DeprecatedMessage.of(...)
pugnascotia 07c34cc
Merge remote-tracking branch 'upstream/master' into index-deprecation…
pugnascotia d6a75bd
Strip out UnionFilter
pugnascotia 074ef8d
Build deprecation msg docs using EcsJsonLayout
pugnascotia 516ce6d
Checkstyle
pugnascotia a750f49
Update docker log4j configs
pugnascotia 2352a20
Fix libs tests
pugnascotia 3b80fdd
Configure HeaderWarningAppender in ESTestCase
pugnascotia 1a3f2da
Fix docker log4j deprecation levels
pugnascotia 3db6c7a
Test fixes
pugnascotia edd0466
Merge remote-tracking branch 'upstream/master' into index-deprecation…
pugnascotia 0d70f53
Merge remote-tracking branch 'upstream/master' into index-deprecation…
pugnascotia 5529912
WIP - trying to write an integration test
pugnascotia 3452367
Implement indexing test
pugnascotia d17a5e8
WIP - trying to rewrite DeprecationHttpIT as a rest test
pugnascotia 8f70584
Tests execute against custom plugin, but need fixed
pugnascotia 4f6f501
Rework deprecation HTTP tests
pugnascotia 98def13
Merge remote-tracking branch 'upstream/master' into index-deprecation…
pugnascotia 97f4934
Merge remote-tracking branch 'upstream/master' into index-deprecation…
pugnascotia 26a3495
Tweaks
pugnascotia c070571
Merge branch 'index-deprecation-logs-v2-tests' into index-deprecation…
pugnascotia 022793e
Fix tests finally, by resetting the rate limiting filter
pugnascotia d8eee69
Merge remote-tracking branch 'upstream/master' into index-deprecation…
pugnascotia afc4dcf
Add test
pugnascotia 2d1d3fb
Merge remote-tracking branch 'upstream/master' into index-deprecation…
pugnascotia 3c8069b
Fix license checks
pugnascotia 2dac9a3
Formatting
pugnascotia f0f3edb
Remove redundant line
pugnascotia 9877d57
Merge branch 'master' into index-deprecation-logs-v2
elasticmachine 1309355
Remove unused import
pugnascotia bd8e3c9
Merge remote-tracking branch 'upstream/master' into index-deprecation…
pugnascotia 76993c9
Add warning headers solely through the log4j appender
pugnascotia e695753
Merge branch 'master' into index-deprecation-logs-v2
elasticmachine 3ff1015
Fixes to JsonLoggerTest
pugnascotia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,12 @@ | ||
appender.header_warning.type = HeaderWarningAppender | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explain why this file is needed? |
||
appender.header_warning.name = header_warning | ||
|
||
logger.header_logger.name = header_logger | ||
logger.header_logger.level = warn | ||
logger.header_logger.appenderRef.header_warning.ref = header_warning | ||
logger.header_logger.additivity = false | ||
|
||
logger.deprecation.name = deprecation | ||
logger.deprecation.level = deprecation | ||
logger.deprecation.appenderRef.deprecation_file.ref = deprecation_file | ||
logger.deprecation.additivity = false |
This file contains hidden or 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 |
---|---|---|
|
@@ -57,6 +57,7 @@ | |
import java.util.stream.Collectors; | ||
import java.util.stream.IntStream; | ||
|
||
import static org.elasticsearch.common.logging.DeprecationLogger.DEPRECATION; | ||
import static org.hamcrest.Matchers.endsWith; | ||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.hasItem; | ||
|
@@ -119,7 +120,7 @@ public void testConcurrentDeprecationLogger() throws IOException, UserException, | |
final List<Integer> ids = IntStream.range(0, 128).boxed().collect(Collectors.toList()); | ||
Randomness.shuffle(ids); | ||
final ThreadContext threadContext = new ThreadContext(Settings.EMPTY); | ||
DeprecationLogger.setThreadContext(threadContext); | ||
HeaderWarning.setThreadContext(threadContext); | ||
try { | ||
barrier.await(); | ||
} catch (final BrokenBarrierException | InterruptedException e) { | ||
|
@@ -180,8 +181,8 @@ public void testConcurrentDeprecationLogger() throws IOException, UserException, | |
for (int i = 0; i < 128; i++) { | ||
assertLogLine( | ||
deprecationEvents.get(i), | ||
Level.WARN, | ||
"org.elasticsearch.common.logging.ThrottlingLogger\\$2\\.run", | ||
DEPRECATION, | ||
"org.elasticsearch.common.logging.DeprecationLogger\\$DeprecationLoggerBuilder.withDeprecation", | ||
"This is a maybe logged deprecation message" + i); | ||
} | ||
|
||
|
@@ -191,49 +192,6 @@ public void testConcurrentDeprecationLogger() throws IOException, UserException, | |
|
||
} | ||
|
||
public void testDeprecationLoggerMaybeLog() throws IOException, UserException { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed this test because the rate-limiting functionality now lives in a dedicated Filter. |
||
setupLogging("deprecation"); | ||
|
||
final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger("deprecation"); | ||
|
||
final int iterations = randomIntBetween(1, 16); | ||
|
||
for (int i = 0; i < iterations; i++) { | ||
deprecationLogger.deprecate("key", "This is a maybe logged deprecation message"); | ||
assertWarnings("This is a maybe logged deprecation message"); | ||
} | ||
for (int k = 0; k < 128; k++) { | ||
for (int i = 0; i < iterations; i++) { | ||
deprecationLogger.deprecate("key" + k, "This is a maybe logged deprecation message" + k); | ||
assertWarnings("This is a maybe logged deprecation message" + k); | ||
} | ||
} | ||
for (int i = 0; i < iterations; i++) { | ||
deprecationLogger.deprecate("key", "This is a maybe logged deprecation message"); | ||
assertWarnings("This is a maybe logged deprecation message"); | ||
} | ||
|
||
final String deprecationPath = | ||
System.getProperty("es.logs.base_path") + | ||
System.getProperty("file.separator") + | ||
System.getProperty("es.logs.cluster_name") + | ||
"_deprecation.log"; | ||
final List<String> deprecationEvents = Files.readAllLines(PathUtils.get(deprecationPath)); | ||
assertThat(deprecationEvents.size(), equalTo(1 + 128 + 1)); | ||
assertLogLine( | ||
deprecationEvents.get(0), | ||
Level.WARN, | ||
"org.elasticsearch.common.logging.ThrottlingLogger\\$2\\.run", | ||
"This is a maybe logged deprecation message"); | ||
for (int k = 0; k < 128; k++) { | ||
assertLogLine( | ||
deprecationEvents.get(1 + k), | ||
Level.WARN, | ||
"org.elasticsearch.common.logging.ThrottlingLogger\\$2\\.run", | ||
"This is a maybe logged deprecation message" + k); | ||
} | ||
} | ||
|
||
public void testDeprecatedSettings() throws IOException, UserException { | ||
setupLogging("settings"); | ||
|
||
|
@@ -256,8 +214,8 @@ public void testDeprecatedSettings() throws IOException, UserException { | |
assertThat(deprecationEvents.size(), equalTo(1)); | ||
assertLogLine( | ||
deprecationEvents.get(0), | ||
Level.WARN, | ||
"org.elasticsearch.common.logging.ThrottlingLogger\\$2\\.run", | ||
DEPRECATION, | ||
"org.elasticsearch.common.logging.DeprecationLogger\\$DeprecationLoggerBuilder.withDeprecation", | ||
"\\[deprecated.foo\\] setting was deprecated in Elasticsearch and will be removed in a future release! " + | ||
"See the breaking changes documentation for the next major version."); | ||
} | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.