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

Adding x-pack monitoring code for elasticsearch/ccr metricset #8336

Merged

Conversation

ycombinator
Copy link
Contributor

@ycombinator ycombinator commented Sep 17, 2018

This PR teaches the elasticsearch/ccr metricset to index documents into .monitoring-es-6-* indices when xpack.enabled: true is set in modules.d/elasticsearch.yml.

To test this PR

The idea is that metricbeat (specifically the elasticsearch/ccr metricset with xpack.enabled: true) will create exactly the same documents in .monitoring-es-* indices as Elasticsearch's internal collection and reporting does today.

  1. Start up Elasticsearch (using the latest build from master).

  2. Start up Kibana.

  3. Start a trial license from the Kibana Management UI.

  4. Enable Monitoring in Elasticsearch (via the cluster setting xpack.monitoring.collection.enabled: true). You can do this via Elasticsearch's Cluster Update Settings API or by clicking the "Turn on Monitoring" button in the Monitoring UI in Kibana.

  5. Set up CCR with a leader and follower index.

  6. Let Elasticsearch run for ~20 seconds so a few documents are indexed into .monitoring-es-6-*.

  7. From .monitoring-es-6-*, retrieve a document for type = ccr_stats

  8. Turn off Elasticsearch's internal collection via the cluster setting xpack.monitoring.elasticsearch.collection.enabled: false.

  9. Delete .monitoring-es-6-* indices.

  10. Enable the elasticsearch module in metricbeat: ./metricbeat modules enable elasticsearch.

  11. In modules.d/elasticsearch.yml, add the ccr metricset and set xpack.enabled: true. Concretely, your modules.d/elasticsearch.yml should look something like this:

    - module: elasticsearch
       metricsets:
       - ccr
       period: 10s
       hosts: ["http://localhost:9200"]
       #username: "user"
       #password: "secret"
       xpack.enabled: true
  12. Start metricbeat.

  13. Let metricbeat run for ~20 seconds so a few documents are indexed into .monitoring-es-*.

  14. Stop metricbeat

  15. From .monitoring-es-6-*, retrieve a document for type = ccr_stats

  16. Using a tool such as http://www.jsondiff.com, compare the documents indexed by Elasticsearch with those indexed by metricbeat. Verify that their structures are identical (same fields, not necessarily same values), except for these known and expected differences:

    1. Only Metricbeat-indexed documents are expected to contain the fields @timestamp, beat, host, and metricset. These are "standard" fields added by beats and metricbeat and don't have an adverse impact since they are additive.
    2. Only Elasticsearch-indexed documents are expected to contain the field source_node. This field is used for debugging purposes only and not actually consumed by either the Monitoring UI or Telemetry feature in Kibana.

@ycombinator ycombinator force-pushed the metricbeat-elasticsearch-ccr-xpack branch 6 times, most recently from 2eab02a to b75c7d2 Compare September 18, 2018 14:59
@ycombinator ycombinator added in progress Pull request is currently in progress. and removed review labels Sep 18, 2018
@ycombinator
Copy link
Contributor Author

Only CI failure is this unrelated flaky test: #8208.

@ycombinator ycombinator added review and removed in progress Pull request is currently in progress. labels Sep 18, 2018
"timestamp": common.Time(time.Now()),
"interval_ms": m.Module().Config().Period / time.Millisecond,
"type": "ccr_stats",
"ccr_stats": shard,
Copy link
Member

@jsoriano jsoriano Sep 19, 2018

Choose a reason for hiding this comment

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

Shouldn't schema be applied to this shard? or metrics in x-pack are expected to be collected as they are?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Metrics in x-pack are passed through to mirror what internal Elasticsearch collectors are doing today. Eventually (probably in 8.0.0), once we have completely migrated over to Metricbeat for monitoring the Elastic stack and the internal ES collector code has been removed, we can add schemas to these metricset to be stricter in what we collect and ship to Elasticsearch.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, I was just wondering now what would be the experience of a user monitoring an OSS cluster with metricbeat when they start using x-pack 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jsoriano Just to make sure I'm understanding correctly: You mean if they try to monitor an OSS ES cluster with this metricset turned on and set xpack.enabled: true in their modules/elasticsearch.yml?

Copy link
Member

Choose a reason for hiding this comment

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

I mean if they are using OSS, and then at some moment they upgrade to x-pack.

@chrisronline
Copy link
Contributor

@ycombinator

I followed the instructions but I'm not seeing any .monitoring-es-* indices. We zoomed about it but this is just a reminder ❤️

@ycombinator
Copy link
Contributor Author

@chrisronline I'm able to reproduce what you're seeing locally as well. Will investigate and fix.

@ycombinator
Copy link
Contributor Author

@chrisronline The issue you found should be fixed now. Ready for review again. Thanks!

Copy link
Contributor

@chrisronline chrisronline left a comment

Choose a reason for hiding this comment

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

LGTM!

Documents are as identical as expected!

@ycombinator ycombinator force-pushed the metricbeat-elasticsearch-ccr-xpack branch from c2f3a70 to 667ff7b Compare September 24, 2018 16:55
@ycombinator ycombinator merged commit 35068ee into elastic:master Sep 24, 2018
ycombinator added a commit to ycombinator/beats that referenced this pull request Sep 24, 2018
…c#8336)

This PR teaches the `elasticsearch/ccr` metricset to index documents into `.monitoring-es-6-*` indices when `xpack.enabled: true` is set in `modules.d/elasticsearch.yml`.

### To test this PR
The idea is that metricbeat (specifically the elasticsearch/ccr metricset with `xpack.enabled: true`) will create exactly the same documents in `.monitoring-es-*` indices as Elasticsearch's internal collection and reporting does today. 

1. Start up Elasticsearch (using the latest build from `master`).
2. Start up Kibana.
3. Start a trial license from the Kibana Management UI.
3. Enable Monitoring in Elasticsearch (via the cluster setting `xpack.monitoring.collection.enabled: true`). You can do this via [Elasticsearch's Cluster Update Settings API](https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html) or by clicking the "Turn on Monitoring" button in the Monitoring UI in Kibana.
4. Set up CCR with a leader and follower index.
4. Let Elasticsearch run for ~20 seconds so a few documents are indexed into `.monitoring-es-6-*`.
6. From `.monitoring-es-6-*`, retrieve a document for `type = ccr_stats`
8. Turn off Elasticsearch's internal collection via the cluster setting `xpack.monitoring.elasticsearch.collection.enabled: false`.
7. Delete `.monitoring-es-6-*` indices.
10. Enable the `elasticsearch` module in metricbeat: `./metricbeat modules enable elasticsearch`.
11. In `modules.d/elasticsearch.yml`, add the `ccr` metricset and set `xpack.enabled: true`.  Concretely, your `modules.d/elasticsearch.yml` should look something like this:

      ```yaml
      - module: elasticsearch
         metricsets:
         - ccr
         period: 10s
         hosts: ["http://localhost:9200"]
         #username: "user"
         #password: "secret"
         xpack.enabled: true
       ```


12. Start metricbeat.
13. Let metricbeat run for ~20 seconds so a few documents are indexed into `.monitoring-es-*`.
14. Stop metricbeat
6. From `.monitoring-es-6-*`, retrieve a document for `type = ccr_stats`
16. Using a tool such as http://www.jsondiff.com, compare the documents indexed by Elasticsearch with those indexed by metricbeat. Verify that their structures are identical (same fields, not necessarily same values), except for these known and expected differences:
    1. Only Metricbeat-indexed documents are expected to contain the fields `@timestamp`, `beat`, `host`, and `metricset`. These are "standard" fields added by beats and metricbeat and don't have an adverse impact since they are additive.
    3. Only Elasticsearch-indexed documents are expected to contain the field `source_node`. This field is used for debugging purposes only and not actually consumed by either the Monitoring UI or Telemetry feature in Kibana.


(cherry picked from commit 35068ee)
@ycombinator ycombinator added v6.5.0 and removed needs_backport PR is waiting to be backported to other branches. labels Sep 24, 2018
ycombinator added a commit that referenced this pull request Sep 26, 2018
…#8422)

This PR teaches the `elasticsearch/ccr` metricset to index documents into `.monitoring-es-6-*` indices when `xpack.enabled: true` is set in `modules.d/elasticsearch.yml`.

### To test this PR
The idea is that metricbeat (specifically the elasticsearch/ccr metricset with `xpack.enabled: true`) will create exactly the same documents in `.monitoring-es-*` indices as Elasticsearch's internal collection and reporting does today. 

1. Start up Elasticsearch (using the latest build from `master`).
2. Start up Kibana.
3. Start a trial license from the Kibana Management UI.
3. Enable Monitoring in Elasticsearch (via the cluster setting `xpack.monitoring.collection.enabled: true`). You can do this via [Elasticsearch's Cluster Update Settings API](https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html) or by clicking the "Turn on Monitoring" button in the Monitoring UI in Kibana.
4. Set up CCR with a leader and follower index.
4. Let Elasticsearch run for ~20 seconds so a few documents are indexed into `.monitoring-es-6-*`.
6. From `.monitoring-es-6-*`, retrieve a document for `type = ccr_stats`
8. Turn off Elasticsearch's internal collection via the cluster setting `xpack.monitoring.elasticsearch.collection.enabled: false`.
7. Delete `.monitoring-es-6-*` indices.
10. Enable the `elasticsearch` module in metricbeat: `./metricbeat modules enable elasticsearch`.
11. In `modules.d/elasticsearch.yml`, add the `ccr` metricset and set `xpack.enabled: true`.  Concretely, your `modules.d/elasticsearch.yml` should look something like this:

      ```yaml
      - module: elasticsearch
         metricsets:
         - ccr
         period: 10s
         hosts: ["http://localhost:9200"]
         #username: "user"
         #password: "secret"
         xpack.enabled: true
       ```


12. Start metricbeat.
13. Let metricbeat run for ~20 seconds so a few documents are indexed into `.monitoring-es-*`.
14. Stop metricbeat
6. From `.monitoring-es-6-*`, retrieve a document for `type = ccr_stats`
16. Using a tool such as http://www.jsondiff.com, compare the documents indexed by Elasticsearch with those indexed by metricbeat. Verify that their structures are identical (same fields, not necessarily same values), except for these known and expected differences:
    1. Only Metricbeat-indexed documents are expected to contain the fields `@timestamp`, `beat`, `host`, and `metricset`. These are "standard" fields added by beats and metricbeat and don't have an adverse impact since they are additive.
    3. Only Elasticsearch-indexed documents are expected to contain the field `source_node`. This field is used for debugging purposes only and not actually consumed by either the Monitoring UI or Telemetry feature in Kibana.


(cherry picked from commit 35068ee)
@ycombinator ycombinator deleted the metricbeat-elasticsearch-ccr-xpack branch September 26, 2018 14:12
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

3 participants