Repository navigation
feat(entity-store): add seed-nat-tiles to seed the Needs attention tiles - #495
Draft
CAWilson94 wants to merge 2 commits into
Draft
CAWilson94 wants to merge 2 commits into
CAWilson94 wants to merge 2 commits into
Conversation
Adds `seed-nat-tiles` to the entity-store commands. It seeds 24 entities with 65 days of history (entities, risk scores, alerts, anomaly records, a watchlist and the security ML placeholder jobs), so every Needs attention tile on the new Entity Analytics page shows a number, a change against the previous period and a sparkline. It prints the numbers each tile should show on 24h, 7d and 30d. - `--entities` seeds whole sets of 24, `--space` picks the space, `--clean` removes what it seeded, and running it again refreshes the data without duplicates. - It checks the Entity Store, the license and the ML jobs before writing. - Adds `createPlaceholderSecurityMlJob` to `kibana_api.ts`. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Adds five resolved groups (a main entity and an alias) to the seeded set, so the tiles are exercised the way the page judges them: an alert or anomaly on an alias counts for its group once, a group is on the watchlist when any member is, a group is new by its earliest member, and a group's risk score (from resolution score documents) wins over the main entity's own score. The set is now 34 entities. The expected numbers are still computed from the same definitions, now per resolved group. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
orouz
pushed a commit
to orouz/kibana
that referenced
this pull request
Nov 2, 2026
… query in the local project (elastic#302397) ## Summary **The Needs attention tiles now only search the project you're in, not every project linked to it through cross-project search (CPS).** - Before: only the New & alerting tile did this. The other five searched all linked projects, so they could count alerts, anomalies and risk scores from other projects against your own entities. - Now: every tile query (count, change, sparkline) is pinned to the current project with `projectRouting: '_alias:_origin'`, the same fix elastic#272473 made for the entities table. - Without CPS nothing changes. Addresses B6 in elastic/security-team#19969. ## Desk testing **Data (small: 34 entities).** `seed-nat-tiles` gives every Needs attention tile a count, a change and a sparkline, and prints the number each tile should show for 24h, 7d and 30d. It is in elastic/security-documents-generator#495 (not merged yet): 1. Kibana with a trial license, the Entity Store installed in the space, and in `kibana.yml`: `feature_flags.overrides: { securitySolution.useNewEntityAnalyticsPage: true }` 2. In security-documents-generator: `gh pr checkout 495 && yarn install && yarn start seed-nat-tiles`. Keep the table it prints. 3. The numbers hold for about an hour; run it again to refresh, and reload the page (the tiles cache for an hour). **Without CPS (nothing should change):** 1. On this branch, open Security → Entity analytics. 2. For Last 24h, 7d and 30d, every tile's number and change match the table `seed-nat-tiles` printed, and every tile has a sparkline. **With CPS (the actual change; same setup as elastic#272473):** 1. Start the local CPS servers (Docker needs about 15 GB of memory): `node scripts/scout start-server --arch serverless --domain security_complete --serverConfigSet cps_local` This starts the origin cluster (`:9220`), a linked cluster (`:9230`) and Kibana (`:5620`). 2. Seed the origin as above, pointing the generator at `:9220` / `:5620`. 3. Index a few high or critical alerts into the **linked** cluster's `.alerts-security.alerts-default` (`:9230`), with `kibana.alert.entity.id` set to entities the seed created. (How to authenticate to the linked cluster is not verified here.) 4. On `main`: Severely alerting can count more than the printed table (the linked alerts are counted). 5. On this branch: it matches the printed table, and every tile search request carries `project_routing: '_alias:_origin'` (DevTools → Network, or Inspect). ## Tests - Each of the 5 count hooks, the previous-period query and its history check, and all 4 sparkline hooks assert the routing. - `node scripts/jest .../needs_attention_tiles`: 30 suites, 475 tests pass. `.../entity_analytics/pages`: 5 suites, 94 tests pass. - eslint clean; `type_check` on `security_solution` clean. - Not tested on a CPS project (not available locally). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
seed-nat-tiles, a subcommand of the entity-store commands that seeds a small, exact set of data so every Needs attention tile on the new Entity Analytics page shows a number, a change against the previous period and a sparkline. It prints the numbers each tile should show, so a tester can check the page against them.--entities <n>seeds whole sets of 34 (every number scales),--space <id>picks the space,--cleanremoves what it seeded.createPlaceholderSecurityMlJobtosrc/utils/kibana_api.ts, and a README recipe and aseed-earow.What the tiles show
number (change vs previous period). The numbers differ by range because the history is spread over time; every tile has a sparkline. The command prints these plus every sparkline (oldest dot first, ending on the number).The data is defined once in
seed_nat_tiles.ts(event ages per entity, and which entities are aliases), and the expected numbers are computed from those same definitions, one resolved group at a time, so the data and the printed numbers cannot drift apart.Resolved groups
Five of the 34 entities are aliases (
entity.relationships.resolution.resolved_topoints at the main entity), so the page lists 29 resolved entities from the seed, not 34. The groups cover what the tiles judge by group:Why it is shaped this way
entityStoreCommands(src/commands/entity_store/index.ts), next torisk-score-v2andseed-risk-score-history.risk-score-v2ornat-perf: this needs fixed data with known numbers, not generated data at scale. I did not check in detail whether either could be configured to do that.bulkUpsert(pre-built body with custom_ids across indices). The risk score index is a data stream, so it usescreateand the command deletes its own risk documents first, which also puts fresh timestamps back on a repeat run.deleteByQueryon this command's own ids, becausedeleteAllByIndexanddeleteDataStreamSafewould remove other data.How to test
feature_flags.overrides: { securitySolution.useNewEntityAnalyticsPage: true }inkibana.yml.yarn start seed-nat-tiles, then open Security > Entity analytics and reload.yarn start seed-nat-tiles --cleanto remove it.What I ran
yarn checks(typecheck, eslint, prettier) passes; the pre-commit hooks ran too.--entities 68(two sets, every number doubles), which checks that each alias links to the main entity of its own set.--clean: counts back to 0, including the watchlist, for one set and for two.git cloneof this branch,yarn install, then the README command only, seeded correctly.Caveats
--cleanleaves the ML placeholder jobs in place (they are harmless). Use the same--entitiesyou seeded with.useNewEntityAnalyticsPageflag and a Kibana restart; the command prints this.Related
Independent of #481 (open, seeds previous-period alert and anomaly deltas for
nat-perf) and of any fork-only seeding code: it uses only what is on main.🤖 Generated with Claude Code