Skip to content

Comments

[Monitoring] Update /api/stats to use core.metrics#60974

Merged
chrisronline merged 8 commits intoelastic:masterfrom
chrisronline:monitoring/api_stats
Mar 24, 2020
Merged

[Monitoring] Update /api/stats to use core.metrics#60974
chrisronline merged 8 commits intoelastic:masterfrom
chrisronline:monitoring/api_stats

Conversation

@chrisronline
Copy link
Contributor

@chrisronline chrisronline commented Mar 23, 2020

Relates to #56675

After migration the Stack Monitoring server to new platform, we had a set of parity tests fails: https://internal-ci.elastic.co/job/elastic+estf-monitoring-snapshots+master+multijob-kibana/157/console

This is because internal collection (of monitoring data) goes through the monitoring code base, which was updated to use the new core.metrics API. Metricbeat collection goes through the /api/stats endpoint, which still exists in legacy.

This PR updates the /api/stats endpoint to use the new core.metrics API.

It also fixes some other issues with parity between Metricbeat collection of kibana_stats and kibana_settings documents.

kibana_stats

Internal
{
  "kibana" : {
    "uuid" : "5b2de169-2785-441b-ae8c-186a1936b17d",
    "name" : "cbr-mbp.lan",
    "index" : ".kibana",
    "host" : "localhost",
    "transport_address" : "localhost:5601",
    "version" : "8.0.0",
    "snapshot" : false,
    "status" : "green"
  },
  "concurrent_connections" : 22,
  "os" : {
    "load" : {
      "1m" : 4.5205078125,
      "5m" : 4.1416015625,
      "15m" : 3.77978515625
    },
    "memory" : {
      "total_in_bytes" : 34359738368,
      "free_in_bytes" : 126353408,
      "used_in_bytes" : 34233384960
    },
    "uptime_in_millis" : 2553488000,
    "platform" : "darwin",
    "platformRelease" : "darwin-19.3.0"
  },
  "process" : {
    "event_loop_delay" : 0.9769420623779297,
    "memory" : {
      "heap" : {
        "total_in_bytes" : 525910016,
        "used_in_bytes" : 326812800,
        "size_limit" : 8564343922
      },
      "resident_set_size_in_bytes" : 1026121728
    },
    "uptime_in_millis" : 31415
  },
  "requests" : {
    "disconnects" : 0,
    "total" : 16
  },
  "response_times" : {
    "average" : 148.5,
    "max" : 517
  },
  "timestamp" : "2020-03-24T01:27:29.100Z"
}
Metricbeat
{
  "process" : {
    "event_loop_delay" : 0.07048416137695312,
    "memory" : {
      "resident_set_size_in_bytes" : 1026928640,
      "heap" : {
        "total_in_bytes" : 526434304,
        "used_in_bytes" : 332255512,
        "size_limit" : 8564343922
      }
    },
    "uptime_in_millis" : 33375
  },
  "requests" : {
    "disconnects" : 0,
    "total" : 13
  },
  "response_times" : {
    "average" : 67,
    "max" : 132
  },
  "kibana" : {
    "snapshot" : false,
    "status" : "green",
    "uuid" : "5b2de169-2785-441b-ae8c-186a1936b17d",
    "name" : "cbr-mbp.lan",
    "index" : ".kibana",
    "host" : "localhost",
    "transport_address" : "localhost:5601",
    "version" : "8.0.0"
  },
  "timestamp" : "2020-03-24T01:27:32.235Z",
  "concurrent_connections" : 5,
  "os" : {
    "platformRelease" : "darwin-19.3.0",
    "load" : {
      "15m" : 3.77978515625,
      "1m" : 4.5205078125,
      "5m" : 4.1416015625
    },
    "memory" : {
      "free_in_bytes" : 114679808,
      "used_in_bytes" : 34245058560,
      "total_in_bytes" : 34359738368
    },
    "uptime_in_millis" : 2553490000,
    "platform" : "darwin"
  }
}

kibana_settings

Internal
{
  "kibana_settings": {
    "kibana": {
      "uuid": "5b2de169-2785-441b-ae8c-186a1936b17d",
      "name": "cbr-mbp.lan",
      "index": ".kibana",
      "port" : 5601,
      "host": "localhost",
      "transport_address": "localhost:5601",
      "version": "8.0.0",
      "snapshot": false,
      "status": "green",
      "locale": "en"
    },
    "xpack": {
      "default_admin_email": null
    }
  }
}

Metricbeat
{
  "kibana_settings": {
    "kibana" : {
      "snapshot" : false,
      "name" : "cbr-mbp.lan",
      "host" : "localhost",
      "index" : ".kibana",
      "port" : 5601,
      "locale" : "en",
      "transport_address" : "localhost:5601",
      "version" : "8.0.0",
      "uuid" : "5b2de169-2785-441b-ae8c-186a1936b17d",
      "status" : "green"
    },
    "xpack" : { }
  }
}
(env) cbr-mbp:kibana chris$ python docs_compare.py ../../../ait_workspace/monitoring/kibana/internal ../../../ait_workspace/monitoring/kibana/metricbeat
OK: Metricbeat-indexed doc for type='kibana_stats' has expected parity with internally-indexed doc.
OK: Metricbeat-indexed doc for type='kibana_settings' has expected parity with internally-indexed doc.

I ran the parity tests with a locally built version of Kibana from this PR and they are passing!

OK: Metricbeat-indexed doc for type='kibana_stats' has expected parity with internally-indexed doc.
OK: Metricbeat-indexed doc for type='kibana_settings' has expected parity with internally-indexed doc.

@chrisronline chrisronline marked this pull request as ready for review March 24, 2020 01:52
@chrisronline chrisronline requested a review from a team as a code owner March 24, 2020 01:52
@chrisronline chrisronline requested a review from a team March 24, 2020 01:52
@chrisronline chrisronline self-assigned this Mar 24, 2020
@chrisronline chrisronline added release_note:skip Skip the PR/issue when compiling release notes review Team:Monitoring Stack Monitoring team v7.7.0 v8.0.0 labels Mar 24, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/stack-monitoring (Team:Monitoring)

let lastMetrics: MonitoringOpsMetrics | null = null;
metrics$.subscribe(metrics => {
metrics$.subscribe(_metrics => {
const metrics: any = cloneDeep(_metrics);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I don't think we need to use cloneDeep here (unless metrics is somehow a reference), and looks like _metrics is not used anywhere else. Don't know if Observables hold references though, in which case maybe shallow might be good enough?:
metrics$.subscribe(({ ...metrics }) => {

Only mentioning because I know cloneDeep can be pretty expensive

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea I tried it without it and any delete or re-setting the object caused issues with the other subscriber.

Copy link
Contributor

@igoristic igoristic left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@chrisronline chrisronline merged commit 223f774 into elastic:master Mar 24, 2020
@chrisronline chrisronline deleted the monitoring/api_stats branch March 24, 2020 19:53
chrisronline added a commit that referenced this pull request Mar 24, 2020
* Align api/stats with the monitoring logic for kibana ops metrics

* Align collectors

* Add in locale to kibana_settings

* More tweaks

* PR feedback

* PR feedback
@chrisronline
Copy link
Contributor Author

Backport:

7.x: e439836

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

Labels

release_note:skip Skip the PR/issue when compiling release notes review Team:Monitoring Stack Monitoring team v7.7.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants