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

Remove types from Monitoring plugin "backend" code #37745

Merged
merged 16 commits into from
Feb 4, 2019

Conversation

ycombinator
Copy link
Contributor

@ycombinator ycombinator commented Jan 23, 2019

This PR removes the use of document types from the monitoring exporters and template + watches setup code.

It does not remove the notion of types from the monitoring bulk API endpoint "front end" code as that code will eventually just go away in 8.0 and be replaced with Beats as collectors/shippers directly to the monitoring cluster.

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features

@gwbrown
Copy link
Contributor

gwbrown commented Jan 23, 2019

It looks like this may relate to #37442 - does this remove the types from the index templates for the monitoring indices, or just stop using them in the code? It looks like the latter.

@ycombinator
Copy link
Contributor Author

@gwbrown Thanks for linking to that issue. As it stands, this PR just removes types from the code and some watch definitions used by Monitoring. I'm happy to add the template changes to this PR as well.

Copy link
Member

@martijnvg martijnvg left a comment

Choose a reason for hiding this comment

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

Hey @ycombinator can you merge master into this PR? There are some test failures. (for example tests expecting a warning about type being used while that is no longer the case and malformed watches / index templates)

@@ -158,7 +158,6 @@
"add_to_alerts_index": {
"index": {
"index": ".monitoring-alerts-6",
Copy link
Member

Choose a reason for hiding this comment

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

, needs to be removed, otherwise this file can't be parsed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Incidentally, @pickypg, do you recall why this particular watch doesn't set a document ID whereas all the other cluster alerts watches do?

Copy link
Member

Choose a reason for hiding this comment

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

@ycombinator It was briefly before the Task Manager stuff began in Kibana (and partly what led to it), but because you could restart multiple nodes in sequence and you didn't want to lose the history of all of them. The goal was if this index ever became a burden to just delete it and recreate it (anecdotally I've never seen the index with >500 documents) or move to index rollover.

@ycombinator ycombinator force-pushed the monitoring-remove-type branch 3 times, most recently from 5a225be to ce9b502 Compare January 31, 2019 16:42
@ycombinator
Copy link
Contributor Author

ycombinator commented Jan 31, 2019

CI failures are legitimate (related to this PR) and I'm able to reproduce them locally. Fixing...

@ycombinator ycombinator changed the title Remove types from Monitoring plugin code Remove types from Monitoring plugin "backend" code Feb 1, 2019
@ycombinator
Copy link
Contributor Author

@pickypg @martijnvg I’ve managed to make most of the tests pass. However I could use some help/guidance with the 2 monitoring unit tests that are still failing. They both fail with the same error:

java.lang.IllegalArgumentException: Malformed [mappings] section for type [enabled], should include an inner object describing the mapping

As far as I can tell, the test template is structured correctly. If I try to manually create a template with the same structure in Console, it is accepted as valid. So I’m not sure why this error is being thrown.

I’m probably overlooking something simple so I could use a second/third set of eyes here, please. Thank you!

@martijnvg
Copy link
Member

@ycombinator I've pushed a commit that fixes the tests. enabled need to be wrapped in _source object. Also when using PutIndexTemplateRequest#setSource(...) the special _doc type still needs to be used. Only the RestPutIndexTemplateAction has special logic, that if _doc is missing, it adds that. This does not happen when using the request object, so here in this test we need manually add it.

@jtibshirani
Copy link
Contributor

@ycombinator @gwbrown I've started a discussion offline about whether we should update the monitoring templates to be typeless as opposed to using the doc type as they do now. The main concerns around making the change are that is will be a breaking change for some consumers. I don't think that discussion needs to hold up this PR though, as it is already a huge step forward in terms of reducing deprecation messages.

@@ -81,11 +82,14 @@ private static BytesReference generateTemplateSource(final String name, final In
.field("index.number_of_replicas", 0)
.endObject()
.startObject("mappings")
.startObject("doc")
// Still need use type, RestPutIndexTemplateAction#prepareRequestSource has logic that adds type if missing
.startObject(MapperService.SINGLE_MAPPING_NAME)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jtibshirani In your offline discussion you mentioned:

Internal elasticsearch products like monitoring and security have been using 'doc' as a type name, and in particular create index templates using the custom type 'doc'.

Given that, should the argument to startObject here be MapperService.SINGLE_MAPPING_NAME, which would evaluate to _doc or should it be "doc"?

Copy link
Contributor

@jtibshirani jtibshirani Feb 3, 2019

Choose a reason for hiding this comment

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

I think for now we should keep it the same as before (using doc), until we come to a firm conclusion in that discussion to update the monitoring templates.

@ycombinator
Copy link
Contributor Author

@pickypg @jtibshirani @martijnvg @jakelandis @gwbrown I think this PR is ready for another round of review now. Thanks!

@@ -127,7 +126,7 @@ public void testMonitoringBulk() throws Exception {

final MonitoringBulkResponse bulkResponse =
new MonitoringBulkRequestBuilder(client())
.add(system, null, new BytesArray(createBulkEntity().getBytes("UTF-8")), XContentType.JSON,
.add(system, "monitoring_data_type", new BytesArray(createBulkEntity().getBytes("UTF-8")), XContentType.JSON,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why add in a default type here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pickypg can correct me if I'm wrong but I believe this argument is the monitoring data type, e.g. beats_stats or logstash_state, etc. that are sent in to the POST _xpack/monitoring/_bulk API. So I wanted to be more explicit about what the type is, so we don't confuse it in the future with _type.

Copy link
Member

Choose a reason for hiding this comment

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

They are. We use that as a mechanism for routing the document to the right index.

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks, i see now.

Copy link
Member

@pickypg pickypg left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@martijnvg martijnvg left a comment

Choose a reason for hiding this comment

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

LGTM

@ycombinator ycombinator merged commit be1bb0e into elastic:master Feb 4, 2019
@ycombinator ycombinator deleted the monitoring-remove-type branch February 4, 2019 18:58
Copy link
Contributor

@jakelandis jakelandis left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for doing this !

jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Feb 5, 2019
…-lease-expiration

* elastic/master: (24 commits)
  Add support for API keys to access Elasticsearch (elastic#38291)
  Add typless client side GetIndexRequest calls and response class (elastic#37778)
  Limit token expiry to 1 hour maximum (elastic#38244)
  add docs saying mixed-cluster ILM is not supported (elastic#37954)
  Skip unsupported languages for tests (elastic#38328)
  Deprecate `_type` in simulate pipeline requests (elastic#37949)
  Mute testCannotShrinkLeaderIndex (elastic#38374)
  Tighten mapping syncing in ccr remote restore (elastic#38071)
  Add test for `PutFollowAction` on a closed index (elastic#38236)
  Fix SSLContext pinning to TLSV1.2 in reload tests (elastic#38341)
  Mute RareClusterStateIT.testDelayedMappingPropagationOnReplica (elastic#38357)
  Deprecate types in rollover index API (elastic#38039)
  Types removal - fix FullClusterRestartIT warning expectations (elastic#38310)
  Fix ILM explain response to allow unknown fields (elastic#38054)
  Mute testFollowIndexAndCloseNode (elastic#38360)
  Docs: Drop inline callout from scroll example (elastic#38340)
  Deprecate HLRC security methods (elastic#37883)
  Remove types from Monitoring plugin "backend" code (elastic#37745)
  Add Composite to AggregationBuilders (elastic#38207)
  Clarify slow cluster-state log messages (elastic#38302)
  ...
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.

None yet

9 participants