Skip to content

Feat: data-stream support + logging improvements #988

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

Merged
merged 79 commits into from
Apr 12, 2021

Conversation

kares
Copy link
Contributor

@kares kares commented Jan 18, 2021

Data stream support, specification elastic/logstash#12178

  • confirm (spec-ified) OSS behavior now defunct
  • needs documentation
  • name validation could do more checks but should be sufficient for now
  • NOTE: due missing support on ES end we currently do not validate whether a data-stream endpoint is actually a DS
    pending issue: can not check ES version when hooking up plugin #1001
  • use at least require_alias=true with _bulk when using DS?!?

DS configuration diverged from the proposed implementation plan:

Implementation wise, the proposal is to build a proxy class that takes in all settings and decides if they are DS compatible.

Simply because it seemed fine to just detect the configuration directly, given:

  • we can check for configuration params from LogStash::PluginMixins::ElasticSearch::APIConfigs mixin
    there's a APIConfigs::CONFIG_PARAMS convention to make sure introducing a new param will not break DS detection
  • we can filter out all super-class (generic) configuration parameters
  • there's a data_stream_ prefix convention for DS specific configuration params

Initially I extracted a base-line for the later include DataStreamSupport but I've run into (existing) spec problems due mocking. I decided to fix these along the way and also bring back logging which was disabled previously due tests.
Splitting this work into separate PR would require extra work as spec improvements rely on some of the DS related refactorinfs for the updated mocking, thus its all here with minor changes besides DS support, namely:

  • re-invent error logging (disabled previously) happening after successful_connection (from install template etc.)
  • unified logging syntax - use Capitalized messages without . or ! logical ends
    (might be just me but I never appreciate logs 'screaming' at me with !)
  • split some methods and hide what is meant to be private (with respect to LS re-use in monitoring)

@kares kares changed the title Feat: support for appending to a data-stream Refactor: cleaner code + unified logging (a data-streams baseline) Feb 15, 2021
@kares kares mentioned this pull request Feb 16, 2021
@kares kares marked this pull request as ready for review February 16, 2021 14:19
@kares kares changed the title Refactor: cleaner code + unified logging (a data-streams baseline) Refactor: review/improve logging + expose ES version to plugin Feb 17, 2021
@kares kares marked this pull request as draft March 1, 2021 08:33
@kares kares changed the title Refactor: review/improve logging + expose ES version to plugin WiP Mar 1, 2021
kares added 18 commits March 1, 2021 11:56
resolves running bare bone against LS 8.0 SNAPSHOT:
```
NoMethodError: undefined method `stoppable_sleep' for Stud:Module
```
before output would only wait for template to be installed
these will be checked as data-stream compatible
also re-arranged pool code for better readability
to reduce ERROR logging noise in specs
and also extract after successful connection parts
we've seen some weird behavior on ES 7.10.2 where a _bulk request to
index 69 documents returned 135 entries

this leads to an ugly `NoMethodError: undefined method ``[]' for
nil:NilClass`

resolves logstash-plugins#989
due failures when spec was run individually
kares added 4 commits March 1, 2021 15:06
this will play fine with LS' existing overrides e.g.
```
 es = LogStash::Outputs::ElasticSearch.new(@es_options)
 es.instance_eval { @logger = logger }
 es.build_client
```
@kares kares marked this pull request as ready for review March 31, 2021 11:22
@@ -198,12 +198,16 @@
let (:settings) { super().merge!({ 'ilm_enabled' => true }) }

it 'should raise a configuration error' do
# TODO should be refactored not to rely on plugin internals
Copy link
Contributor Author

Choose a reason for hiding this comment

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

integration test was relying on a raise from the other thread to propagate, which is problematic.
the new logic to rescue everything from the async thread and propagate exceptions back as thread.value - making it a bit hard to test -> spec example should be rewritten or migrated to a unit test.

Copy link
Contributor

@yaauie yaauie left a comment

Choose a reason for hiding this comment

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

👍🏼 good cleanup on the async auto-DS.

I've got some suggestions for making the validation a little easier to read, perhaps detangling some of the logic that ended up getting a bit twisty.

Copy link
Contributor

@karenzone karenzone left a comment

Choose a reason for hiding this comment

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

Covers the basics and builds cleanly. I recommend that we merge this huge body of work when it's ready, and immediately follow up with a docs-only PR. Suggestions for enhancements are here: #1006. These kinds of suggestions/enhancements are hard to notate and implement in the github workflow. LMKWYT about this approach.

UPDATED: Please add a data streams section (similar to the ILM section), and include the two configs from the issue. We can handle and track the other doc improvements as part of the follow up issue: #1006

kares and others added 6 commits April 8, 2021 08:45
@kares kares requested a review from yaauie April 8, 2021 09:18
Copy link
Contributor

@yaauie yaauie left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants