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

[Ingest] Data streams list page #64134

Merged
merged 8 commits into from
Apr 23, 2020
Merged

Conversation

jen-huang
Copy link
Contributor

@jen-huang jen-huang commented Apr 21, 2020

Resolves #60814

Summary

This PR adds the initial shell page for data streams. A new DataStream type and list API was added to support this, along with corresponding response types.

GET /api/ingest_manager/data_streams returns an array of DataStreams sorted by last activity (desc) similar to:

{
  "data_streams": [
    {
      "index": "metrics-system.cpu-tester",
      "dataset": "system.cpu",
      "namespace": "tester",
      "type": "metrics",
      "package": "system",
      "last_activity": "2020-04-21T23:23:02.770Z",
      "size_in_bytes": 298682
    },
    {
      "index": "metrics-system.load-tester",
      "dataset": "system.load",
      "namespace": "tester",
      "type": "metrics",
      "package": "system",
      "last_activity": "2020-04-21T23:23:02.770Z",
      "size_in_bytes": 235274
    },
    ...
  ]
}

Deferred

The following tasks still needs to be done in subsequent PRs for this page:

  • Add row actions like view in Dashboard etc
  • Add overall stats to header (total data sets & total size)
  • Update Integration column values to display package icon
  • Add support for paging to API, currently returns first 100,000 indices/streams
    • Table will also need to be updated, currently paging/sorting/filtering is done in memory

Screenshots

image

@jen-huang jen-huang requested a review from a team April 21, 2020 23:46
@jen-huang jen-huang self-assigned this Apr 21, 2020
@jen-huang jen-huang added release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v7.8.0 v8.0.0 labels Apr 21, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/ingest-management (Team:Ingest Management)

must: [
{
exists: {
field: 'fields.stream.namespace',
Copy link
Member

Choose a reason for hiding this comment

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

That it has a fields prefix is actually a bug. As soon as elastic/beats#17858 is merged, this must be adjusted. Same for the other fields below.

@michalpristas Seeing your PR is approved, could you get it in so perhaps we can adjust this here before merging?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will adjust.

},
package: {
terms: {
field: 'event.module',
Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed? Sorting? Perhaps prefix query could help here? event.module is likely to disappear in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to detect the package to display in the Integrations column of the table. I see the same value in service.type too? What should I use?

Copy link
Member

Choose a reason for hiding this comment

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

None of both :-( This brings up the question: Is it the data that links to the package or does the ingest manager know which package belongs to the data? I would say it is the second one. Lets assume someone configure the agent to ship system metrics. He will not have added any information around packages as the agent does not know about packages. But the data will still be processed correctly, stored and works with the dashboards. Basically for each stream the ingest manager must check if it belongs to an installed package to show the link and then also show the dashboards ...

If your current solution works, lets keep it and then iterate on 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.

Ok, it sounds like the get the package info the "right" way will involve more work that overlaps with the work needed for linking to dashboard, so will defer this for now.

Does that mean this PR gets a 👍? 🙂

Copy link
Member

Choose a reason for hiding this comment

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

The query gets a 👍 Did not really check the rest of the code or did it run locally.

@jen-huang jen-huang requested a review from a team April 22, 2020 19:04
Copy link
Member

@nchaulet nchaulet left a comment

Choose a reason for hiding this comment

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

Tested it locally and it seems a few fields are missing, I am missing something for tests?
Screen Shot 2020-04-22 at 9 50 05 PM


const dataStreams: DataStream[] = [];

(indexResults as any[]).forEach(result => {
Copy link
Member

Choose a reason for hiding this comment

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

any reason of mapping directly results here to dataStream? const dataStreams: DataStream[] = (indexResults as any[]).map(result => { ...;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will update; was leftover logic from previous attempt :)


const DATA_STREAM_INDEX_PATTERN = 'logs-*-*,metrics-*-*';

export const getListHandler: RequestHandler = async (context, request, response) => {
Copy link
Member

Choose a reason for hiding this comment

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

Do you think we can cover this API by an API integration tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will add

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I took a look into our api integration tests and we have setup for fleet and epm routes, but not the general ingest manager routes. This particular route will need ES data fixtures to get tested. As we have a ton of other things to get done by FF, I'm going to defer test coverage on this for now :(

@jen-huang
Copy link
Contributor Author

@nchaulet The missing fields are due to changes on agent side that were recently merged, needs a build/snapshot with those changes: #64134 (comment)

export const getListHandler: RequestHandler = async (context, request, response) => {
const callCluster = context.core.elasticsearch.dataClient.callAsCurrentUser;

try {
Copy link
Contributor

Choose a reason for hiding this comment

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

This handler is more knowledgeable than most. Can we move this out to a service or function(s) which accept callCluster, etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Blocking for this PR? This page needs to be iterated on with more functionality and we can move it to a service then.

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface GetFleetSetupRequest {}

export interface CreateFleetSetupRequest {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you talk about these changes? It's not clear to me why we're also making changes to the Fleet setup behavior

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No behavioral changes, just cleaning up typings: e0e62b1

GetFleetSetupRequest, CreateFleetSetupRequest, and CreateFleetSetupResponse were duplicated in server/types/rest_spec/fleet_setup.ts, so I removed that file and kept this one in /common (to match with our existing structure).

GetFleetSetupRequest is empty so I removed it. CreateFleetSetupRequest is invalid as we no longer require username/password as part of the setup endpoint request, so it's also empty.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Thanks for the additional info. I wasn't aware of the duplication or that we don't require user/pass any longer for setup.

I feel like setting validate: false is a step backwards (platform/security encourage them for a reason). I'd prefer to keep that but it's nothing to hold up this change.

@jen-huang jen-huang merged commit 9ad8b8f into elastic:master Apr 23, 2020
@jen-huang jen-huang deleted the ingest/data-streams branch April 23, 2020 21:14
jen-huang added a commit to jen-huang/kibana that referenced this pull request Apr 23, 2020
* Clean up fleet setup request/response typings

* Add data stream model and list route, handler, and request/response types

* Initial pass at data streams list

* Table styling fixes

* Fix types, fix field names

* Change forEach to map
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

jen-huang added a commit that referenced this pull request Apr 23, 2020
* Clean up fleet setup request/response typings

* Add data stream model and list route, handler, and request/response types

* Initial pass at data streams list

* Table styling fixes

* Fix types, fix field names

* Change forEach to map
gmmorris added a commit to gmmorris/kibana that referenced this pull request Apr 24, 2020
* master: (70 commits)
  KQL removes leading zero and breaks query (elastic#62748)
  [FieldFormats] Cleanup: rename IFieldFormatType -> FieldFormatInstanceType (elastic#64193)
  [ML] Changes transforms wizard UI text (elastic#64150)
  [Alerting] change server log action type .log to .server-log in README (elastic#64124)
  [Metrics UI] Design Refresh: Inventory View, Episode 1 (elastic#64026)
  chore(NA): reduce siem bundle size using babel-plugin-transfor… (elastic#63269)
  chore(NA): use core-js instead of babel-polyfill on canvas sha… (elastic#63486)
  skip flaky suite (elastic#61173)
  skip flaky suite (elastic#62497)
  Renamed ilm policy for event log so it is not prefixed with dot (elastic#64262)
  [eslint] no_restricted_paths config cleanup (elastic#63741)
  Add Oil Rig Icon from @elastic/maki (elastic#64364)
  [Maps] Migrate Maps embeddables to NP (elastic#63976)
  [Ingest] Data streams list page (elastic#64134)
  chore(NA): add file-loader into jest moduleNameMapper (elastic#64330)
  [DOCS] Added images to automating report generation (elastic#64333)
  [SIEM][CASE] Api Integration Tests: Configuration (elastic#63948)
  Expose ability to check if API Keys are enabled (elastic#63454)
  [DOCS] Fixes formatting in alerting doc (elastic#64338)
  [data.search.aggs]: Create agg types function for terms agg. (elastic#63541)
  ...
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 Team:Fleet Team label for Observability Data Collection Fleet team v7.8.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Ingest] Data streams page UI
6 participants