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

Only request wildcard expansion for hidden indices if supported #20938

Merged
merged 9 commits into from
Sep 3, 2020

Conversation

ycombinator
Copy link
Contributor

@ycombinator ycombinator commented Sep 2, 2020

What does this PR do?

This PR teaches the elasticsearch/index metricset to check the version of the Elasticsearch cluster it's monitoring and, depending on that, ask the cluster to expand wildcards for hidden indices or not.

Why is it important?

In #18703 we enhanced the elasticsearch/index metricset to ask the monitored Elasticsearch cluster to expand wildcards for hidden indices. This enhancement was released in Metricbeat 7.9.0.

Unfortunately this enhancement a backwards-incompatible change, as wildcard expansion for hidden indices is only supported starting Elasticsearch 7.9.0. So if a Metricbeat >= 7.90 tries to monitor an Elasticsearch cluster < 7.9.0, the elasticsearch/index metricset is not able to collect metrics and throws the following error:

Error fetching data for metricset elasticsearch.index: HTTP error 400 in : 400 Bad Request.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

@ycombinator ycombinator added bug module Metricbeat Metricbeat Feature:Stack Monitoring v8.0.0 Team:Services (Deprecated) Label for the former Integrations-Services team labels Sep 2, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations-services (Team:Services)

@elasticmachine
Copy link
Collaborator

Pinging @elastic/stack-monitoring (Stack monitoring)

@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Sep 2, 2020
@ycombinator ycombinator force-pushed the indices-stats-hidden-bc branch from 51d0743 to b69c255 Compare September 2, 2020 16:45
@ycombinator ycombinator added v7.9.2 [zube]: In Review needs_backport PR is waiting to be backported to other branches. labels Sep 2, 2020
@elasticmachine
Copy link
Collaborator

elasticmachine commented Sep 2, 2020

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #20938 updated]

  • Start Time: 2020-09-03T11:37:45.108+0000

  • Duration: 74 min 51 sec

Test stats 🧪

Test Results
Failed 0
Passed 3204
Skipped 698
Total 3902

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

LGTM, comments are not blockers.

var BulkStatsAvailableVersion = common.MustNewVersion("8.0.0")
//ExpandWildcardsHiddenAvailableVersion is the version since when the "expand_wildcards" query parameter to
// the Indices Stats API can accept "hidden" as a value.
ExpandWildcardsHiddenAvailableVersion = common.MustNewVersion("7.9.0")
Copy link
Member

Choose a reason for hiding this comment

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

In #18703 an integration test was added and it was being executed against Elasticsearch 7.7.0, why did this test didn't fail?
Should we add some other test for the expand wildcards case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I just checked and this ES feature actually went into 7.7.0, not 7.9.0. So that's why the test in #18703 passed. I will fix the constant here.

I will also add a unit test for the getServicePath function for the expand wildcards case with different versions of ES.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed constant in 1d6ceae.

Copy link
Contributor Author

@ycombinator ycombinator Sep 2, 2020

Choose a reason for hiding this comment

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

Added unit test cases in 08d22a5.

Comment on lines 133 to 134
ew := u.Query().Get(expandWildcardsParam)
if !strings.HasSuffix(ew, hiddenSuffix) {
Copy link
Member

Choose a reason for hiding this comment

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

The path comes from a constant, do we need to do these checks to see if some suffix is already present?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I guess you're right. I was thinking of a different problem (#16044) but that's not applicable here. I will remove the checks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed in 854671e.

@ycombinator ycombinator requested a review from jsoriano September 2, 2020 20:17
@ycombinator
Copy link
Contributor Author

@jsoriano Thanks for the excellent review. I have addressed all your feedback. Please re-review when you get a chance. Thanks!

@jsoriano
Copy link
Member

jsoriano commented Sep 3, 2020

Failing test seems related.

@ycombinator ycombinator merged commit c0afa49 into elastic:master Sep 3, 2020
@ycombinator ycombinator deleted the indices-stats-hidden-bc branch September 3, 2020 12:53
@ycombinator ycombinator removed the needs_backport PR is waiting to be backported to other branches. label Sep 3, 2020
v1v added a commit to v1v/beats that referenced this pull request Sep 3, 2020
…ne-2.0

* upstream/master:
  [Metricbeat][test] Disable ec2 flaky test (elastic#20959)
  Check if tracer is active before starting a transaction (elastic#20852)
  [Elastic Agent] Add support for variable replacement from providers (elastic#20839)
  Only request wildcard expansion for hidden indices if supported (elastic#20938)
  [Ingest Manager] New agent structure (symlinks) (elastic#20400)
  [Ingest Manager] Print a message confirming shutdown (elastic#20948)
  Skip flaky test on unix input (elastic#20942)
  [Ingest Manager] Align introspect-inspect naming in code (elastic#20952)
  [Filebeat][zeek] Map new x509 fields for ssl module (elastic#20927)
  [CI] fix regression with variable name (elastic#20930)
  [Autodiscover] Handle input-not-finished errors in config reload (elastic#20915)
  [Ingest Manager] Remove Success from fleet contract (elastic#20449)
v1v added a commit to v1v/beats that referenced this pull request Sep 3, 2020
…-faster

* upstream/master:
  [Metricbeat][test] Disable ec2 flaky test (elastic#20959)
  Check if tracer is active before starting a transaction (elastic#20852)
  [Elastic Agent] Add support for variable replacement from providers (elastic#20839)
  Only request wildcard expansion for hidden indices if supported (elastic#20938)
  [Ingest Manager] New agent structure (symlinks) (elastic#20400)
  [Ingest Manager] Print a message confirming shutdown (elastic#20948)
  Skip flaky test on unix input (elastic#20942)
  [Ingest Manager] Align introspect-inspect naming in code (elastic#20952)
  [Filebeat][zeek] Map new x509 fields for ssl module (elastic#20927)
ycombinator added a commit that referenced this pull request Sep 8, 2020
…s if supported (#20938) (#20962)

* Only request wildcard expansion for hidden indices if supported (#20938)

* Refactoring: inverting logic to make room for another case

* Expand hidden indices wildcards if monitored ES supports that option

* Adding CHANGELOG entry

* Fixing formatting

* Avoid unnecessary setting

* Removing unnecessary suffix existence checks

* Fixing feature version

* Add test cases to unit test

* Updating test
# Conflicts:
#	metricbeat/module/elasticsearch/index/index_test.go

* Fixing CHANGELOG
ycombinator added a commit that referenced this pull request Sep 8, 2020
…) (#20963)

* Refactoring: inverting logic to make room for another case

* Expand hidden indices wildcards if monitored ES supports that option

* Adding CHANGELOG entry

* Fixing formatting

* Avoid unnecessary setting

* Removing unnecessary suffix existence checks

* Fixing feature version

* Add test cases to unit test

* Updating test
# Conflicts:
#	metricbeat/module/elasticsearch/index/index_test.go
melchiormoulin pushed a commit to melchiormoulin/beats that referenced this pull request Oct 14, 2020
…tic#20938)

* Refactoring: inverting logic to make room for another case

* Expand hidden indices wildcards if monitored ES supports that option

* Adding CHANGELOG entry

* Fixing formatting

* Avoid unnecessary setting

* Removing unnecessary suffix existence checks

* Fixing feature version

* Add test cases to unit test

* Updating test
leweafan pushed a commit to leweafan/beats that referenced this pull request Apr 28, 2023
…s if supported (elastic#20938) (elastic#20962)

* Only request wildcard expansion for hidden indices if supported (elastic#20938)

* Refactoring: inverting logic to make room for another case

* Expand hidden indices wildcards if monitored ES supports that option

* Adding CHANGELOG entry

* Fixing formatting

* Avoid unnecessary setting

* Removing unnecessary suffix existence checks

* Fixing feature version

* Add test cases to unit test

* Updating test
# Conflicts:
#	metricbeat/module/elasticsearch/index/index_test.go

* Fixing CHANGELOG
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.

3 participants