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

[Usage Collection] Report nodes feature usage #70108

Merged

Conversation

TinaHeiligers
Copy link
Contributor

@TinaHeiligers TinaHeiligers commented Jun 26, 2020

Summary

Closes #68603

This PR allows us to track different types of aggregations performed on cluster nodes as well as determine the rest actions that were issued. Note that this PR only handles the case of usage data being collected locally. The case for when monitoring is enabled will be addressed in a different issue.

The original request was to add aggregations to the rest_actions from the nodes feature usage data but we weren't reporting any of that data.
The data is reported pretty much as-is, although the structure is modified slightly from the raw response.

raw response:
{
  cluster_name: 'test cluster',
  nodes: {
    some_node_id: {
      timestamp: 1588617023177,
      since: 1588616945163,
      rest_actions: {
        nodes_usage_action: 1,
        ...
      },
      aggregations: {
        terms: {
          bytes: 2,
        },
        scripted_metric: {
          other: 7,
        },
        ...
      }
    }
  }
}
format of response reported _within `cluster_stats.nodes`_:
usage: [
  {
    node_id: 'some_node_id',
    timestamp: 1588617023177,
    since: 1588616945163,
    rest_actions: {
      nodes_usage_action: 1,
      ...
    },
    aggregations: {
      terms: {
        bytes: 2,
      },
      scripted_metric: {
        other: 7,
      },
      ...
    }
  },
  {
    node_id: 'some_other_node',
    ...
  }
]

screenshots:

Preview of part of the response from POST /api/telemetry/v2/clusters/_stats:
Screen Shot 2020-06-26 at 09 46 38

How it renders in the UI (note that this is a one-node cluster running locally):
Screen Shot 2020-06-26 at 09 47 10

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-telemetry (Team:KibanaTelemetry)

@TinaHeiligers
Copy link
Contributor Author

cc @mindbat this PR adds the response from a GET request to /_nodes/usage for a cluster and reports it un-aggregated. We will need to aggregate the data in the indexing layer, as discussed in #68603 (comment).

@TinaHeiligers
Copy link
Contributor Author

@imotov @polyfractal, here's the PR for adding nodes feature usage aggregations (and rest actions) to the usage collection payload. The work only covers the case for when usage collection is local, i.e. monitoring is not enabled.
The data reported is unaggregated.

Copy link
Member

@afharo afharo left a comment

Choose a reason for hiding this comment

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

It's looking great! I noticed a couple of gotchas. But happy to approve it if they are intended 👍

@kibanamachine
Copy link
Contributor

💛 Build succeeded, but was flaky


Test Failures

Kibana Pipeline / kibana-oss-agent / Plugin Functional Tests.test/plugin_functional/test_suites/core_plugins/logging·ts.core plugins plugin logging writes info_json context to custom JSON appender

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has failed 3 times on tracked branches: https://github.com/elastic/kibana/issues/70151

[00:00:00]       │
[00:01:15]         └-: core plugins
[00:01:15]           └-> "before all" hook
[00:03:46]           └-: plugin logging
[00:03:46]             └-> "before all" hook
[00:03:46]             └-> does not write to custom appenders when not configured
[00:03:46]               └-> "before each" hook: global before each
[00:03:46]               └-> "before each" hook
[00:03:46]               │ proc [kibana]   log   [19:53:30.759] [info][core_logging][debug_json][plugins] i go to the default appender!
[00:03:46]               └- ✓ pass  (71ms) "core plugins plugin logging does not write to custom appenders when not configured"
[00:03:46]             └-> writes debug_json context to custom JSON appender
[00:03:46]               └-> "before each" hook: global before each
[00:03:46]               └-> "before each" hook
[00:03:46]               └- ✓ pass  (50ms) "core plugins plugin logging writes debug_json context to custom JSON appender"
[00:03:46]             └-> writes info_json context to custom JSON appender
[00:03:46]               └-> "before each" hook: global before each
[00:03:46]               └-> "before each" hook
[00:03:46]               │ info Taking screenshot "/dev/shm/workspace/kibana/test/functional/screenshots/failure/core plugins plugin logging writes info_json context to custom JSON appender.png"
[00:03:47]               │ debg browser[WARNING] http://localhost:6121/9007199254740991/bundles/core_legacy_compat.bundle.js 2495:20 "App [dev_tools] is using deprecated mount context. Use core.getStartServices() instead."
[00:03:47]               │ debg browser[INFO] http://localhost:6121/9007199254740991/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js 452:106112 "INFO: 2020-06-29T19:53:31Z
[00:03:47]               │        Adding connection to http://localhost:6121/elasticsearch
[00:03:47]               │
[00:03:47]               │      "
[00:03:47]               │ debg browser[WARNING] http://localhost:6121/9007199254740991/bundles/core_legacy_compat.bundle.js 2495:20 "App [management] is using deprecated mount context. Use core.getStartServices() instead."
[00:03:47]               │ debg browser[WARNING] http://localhost:6121/9007199254740991/bundles/core_legacy_compat.bundle.js 2495:20 "App [rendering] is using deprecated mount context. Use core.getStartServices() instead."
[00:03:47]               │ debg browser[WARNING] http://localhost:6121/9007199254740991/bundles/core_legacy_compat.bundle.js 2495:20 "App [custom-app-route] is using deprecated mount context. Use core.getStartServices() instead."
[00:03:47]               │ debg browser[WARNING] http://localhost:6121/9007199254740991/bundles/core_legacy_compat.bundle.js 2495:20 "App [chromeless] is using deprecated mount context. Use core.getStartServices() instead."
[00:03:47]               │ debg browser[WARNING] http://localhost:6121/9007199254740991/bundles/core_legacy_compat.bundle.js 2495:20 "App [foo] is using deprecated mount context. Use core.getStartServices() instead."
[00:03:47]               │ debg browser[WARNING] http://localhost:6121/9007199254740991/bundles/core_legacy_compat.bundle.js 2495:20 "App [bar] is using deprecated mount context. Use core.getStartServices() instead."
[00:03:47]               │ debg browser[WARNING] http://localhost:6121/9007199254740991/bundles/core_legacy_compat.bundle.js 2495:20 "App [appleave1] is using deprecated mount context. Use core.getStartServices() instead."
[00:03:47]               │ debg browser[WARNING] http://localhost:6121/9007199254740991/bundles/core_legacy_compat.bundle.js 2495:20 "App [appleave2] is using deprecated mount context. Use core.getStartServices() instead."
[00:03:47]               │ debg browser[DEBUG] http://localhost:6121/9007199254740991/bundles/plugin/usageCollection/usageCollection.plugin.js 950:16 "Reporting user-agent."
[00:03:47]               │ debg browser[DEBUG] http://localhost:6121/9007199254740991/bundles/plugin/usageCollection/usageCollection.plugin.js 950:16 "Reporting application changed to core_legacy_compat"
[00:03:47]               │ info Current URL is: http://localhost:6121/app/core_legacy_compat
[00:03:47]               │ info Saving page source to: /dev/shm/workspace/kibana/test/plugin_functional/failure_debug/html/core plugins plugin logging writes info_json context to custom JSON appender.html
[00:03:47]               └- ✖ fail: "core plugins plugin logging writes info_json context to custom JSON appender"
[00:03:47]               │

Stack Trace

{ Error: expected [] to sort of equal [ { level: 'INFO',
    context: 'plugins.core_logging.info_json',
    message: 'log2' } ]
    at Assertion.assert (packages/kbn-expect/expect.js:100:11)
    at Assertion.eql (packages/kbn-expect/expect.js:244:8)
    at Context.it (test/plugin_functional/test_suites/core_plugins/logging.ts:96:40)
  actual: '[]',
  expected:
   '[\n  {\n    "context": "plugins.core_logging.info_json"\n    "level": "INFO"\n    "message": "log2"\n  }\n]',
  showDiff: true }

Build metrics

✅ unchanged

History

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

Copy link
Member

@afharo afharo left a comment

Choose a reason for hiding this comment

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

LGTM!

}
const result = await fetchNodesUsage(callCluster);
const transformedNodes = Object.entries(result?.nodes || {}).map(([key, value]) => ({
...(value as NodeObj),
Copy link
Member

Choose a reason for hiding this comment

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

NIT: I think there is no need for the cast now that fetchNodesUsage is properly typed :)

@TinaHeiligers TinaHeiligers merged commit 93ef5c0 into elastic:master Jun 30, 2020
TinaHeiligers added a commit that referenced this pull request Jun 30, 2020
* Adds nodes feature usage stats merged into cluster_stats.nodes when usage collection is local
@TinaHeiligers TinaHeiligers deleted the nodes-feature-usage-local-collection branch June 30, 2020 16:20
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jul 1, 2020
* master:
  [ML] Modifies page title to Create job (elastic#70191)
  [APM] Add API test for service maps (elastic#70185)
  [DOCS] Adds glossary to documentation (elastic#69721)
  [Usage Collection] Report nodes feature usage (elastic#70108)
  chore: improve support for mjs file extension (elastic#70186)
  [ML] Anomaly Detection: ensure  'Category examples' tab in the expanded table row can be seen (elastic#70241)
  [Maps] Add maps telemetry saved object in with mappings disabled (elastic#69995)
  Fix typo in bootstrap command (elastic#69976)
  [code coverage] ingest correct coveredFilePath for mocha (elastic#70215)
  [Dashboard] Add visualization by value to dashboard (elastic#69898)
  updates wording in Cases connectors (elastic#70298)
  [ML] Fix license subscription race condition. (elastic#70074)
  [Logs UI] [Alerting] "Group by" functionality (elastic#68250)
Bamieh pushed a commit to Bamieh/kibana that referenced this pull request Jul 1, 2020
* Adds nodes feature usage stats merged into cluster_stats.nodes when usage collection is local
@lukeelmers lukeelmers added the Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc label Oct 1, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Telemetry release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.9.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Usage Collection] Collect stats from /_nodes/usage
5 participants