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 beat module with state metricset #12615

Merged
merged 49 commits into from
Jun 25, 2019

Conversation

ycombinator
Copy link
Contributor

@ycombinator ycombinator commented Jun 19, 2019

This PR adds the state metricset to the beat Metricbeat module.

More specifically, this PR:

  • Implements the non-xpack code path for this metricset.
  • Implements the xpack code path for this metricset.
  • Updates the modules.d/beat.yml and modules.d/beat-xpack.yml module configuration files.

Testing this PR

X-Pack code path (for Stack Monitoring UI)

  1. Build metricbeat with this PR.

    cd $GOPATH/src/github.com/elastic/beats/metricbeat
    mage build
    
  2. Using Kibana > Console, clear out existing Beats monitoring data.

    DELETE .monitoring-beats-*
    
  3. Start Metricbeat with internal collection.

    ./metricbeat -e -E monitoring.enabled=true
    
  4. Wait 10 seconds or so for monitoring data to be collected.

  5. Using Kibana > Console, retrieve the latest document from the .monitoring-beats-* index and save it.

    POST .monitoring-beats-*/_search?filter_path=hits.hits._source
    {
      "query": {
        "bool": {
          "filter": {
            "term": {
              "type": "beats_state"
            }
          }
        }
      },
      "sort": [
        {
          "timestamp": {
            "order": "desc"
          }
        }
      ]
    }
    
  6. Stop Metricbeat.

  7. Using Kibana > Console, clear out existing Beats monitoring data.

    DELETE .monitoring-beats-*
    
  8. Start Metricbeat with HTTP API enabled for external collection.

    ./metricbeat -e -E http.enabled=true
    
  9. In a new window enable the beats-xpack Metricbeat module for external collection and start this Metricbeat instance.

    ./metricbeat modules enable beat-xpack
    ./metricbeat -e
    
  10. Wait 10 seconds or so for monitoring data to be collected.

  11. Using Kibana > Console, retrieve the latest document from the .monitoring-beats-* index and save it.

    POST .monitoring-beats-*/_search?filter_path=hits.hits._source
    {
      "query": {
        "bool": {
          "filter": {
            "term": {
              "type": "beats_state"
            }
          }
        }
      },
      "sort": [
        {
          "timestamp": {
            "order": "desc"
          }
        }
      ]
    }
    
  12. Compare the JSON document saved from internal collection (step 5) with the JSON document saved from external collection (step 11). You might want to use a tool like jsondiff.com for this purpose.

    The only structural difference between the two documents should be that the externally-collected JSON document should have 7 extra top-level fields: @timestamp, event, ecs, agent, metricset, service, host. These are expected extra fields that are always inserted by Metricbeat. Other than these expected structural differences, the rest of the structure should be identical; however, values of corresponding fields may be different.

@ycombinator
Copy link
Contributor Author

jenkins, test this

@ycombinator ycombinator force-pushed the mb-beat-state branch 3 times, most recently from ed22834 to d84fedd Compare June 21, 2019 15:47
@elasticmachine
Copy link
Collaborator

Pinging @elastic/stack-monitoring

@ycombinator ycombinator marked this pull request as ready for review June 22, 2019 04:04
@ycombinator ycombinator requested review from a team as code owners June 22, 2019 04:04
Copy link
Member

@ruflin ruflin left a comment

Choose a reason for hiding this comment

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

I wonder if we should follow ECS here?

"service": {
"address": "127.0.0.1:5066",
"name": "beat",
"type": "beat"
Copy link
Member

Choose a reason for hiding this comment

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

This does not seem to be correct. This should be metricbeat. And name should probably be what we have in beat.name or skip it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 64eff0c.

{
"@timestamp": "2017-10-12T08:05:34.853Z",
"beat": {
"id": "1f0c187b-f2ef-4950-b9cc-dd6864b9191a",
Copy link
Member

Choose a reason for hiding this comment

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

service.id?

Copy link
Contributor Author

@ycombinator ycombinator Jun 24, 2019

Choose a reason for hiding this comment

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

Done in 64eff0c.

"name": "mem"
}
},
"type": "metricbeat"
Copy link
Member

Choose a reason for hiding this comment

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

Should be under service.type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 64eff0c.

@ycombinator
Copy link
Contributor Author

@ruflin I believe I've addressed all your review feedback now. Ready for your 👀 again, when you get a chance. Thanks!

@ruflin
Copy link
Member

ruflin commented Jun 25, 2019

@ycombinator Skimmed through it and LGTM. But would be good if for example @mikecote could have a look to as I mainly checked fields and didn't test it locally.

@ycombinator
Copy link
Contributor Author

But would be good if for example @mikecote could have a look to as I mainly checked fields and didn't test it locally.

I think you meant @cachedout? :)

@ruflin
Copy link
Member

ruflin commented Jun 25, 2019

Yep, 🤦‍♂

Copy link
Contributor

@cachedout cachedout left a comment

Choose a reason for hiding this comment

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

I have tested this according to the instructions and found that, as described, the noted fields are present in the second document but not the first, along with differences in field values for things such as timestamps.

@ycombinator ycombinator merged commit e14a8b9 into elastic:master Jun 25, 2019
@ycombinator ycombinator deleted the mb-beat-state branch June 25, 2019 13:40
@ycombinator ycombinator removed the needs_backport PR is waiting to be backported to other branches. label Jan 15, 2020
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