Skip to content

Watchlists maintainer, sync all watchlists on setup #260144

Merged
jaredburgettelastic merged 6 commits intomainfrom
watchlist-maintainer
Mar 30, 2026
Merged

Watchlists maintainer, sync all watchlists on setup #260144
jaredburgettelastic merged 6 commits intomainfrom
watchlist-maintainer

Conversation

@CAWilson94
Copy link
Copy Markdown
Contributor

@CAWilson94 CAWilson94 commented Mar 28, 2026

Summary

This PR adds the watchlist maintainer and registers it on plugin setup. Additionally, all watchlists are synced on a 10 minute schedule.

Feature flags:

xpack.securitySolution.enableExperimental:
  - entityAnalyticsEntityStoreV2
  - entityAnalyticsWatchlistEnabled

Debugging log config:

logging:
  loggers:
    - name: plugins.securitySolution
      level: debug
    - name: plugins.entityStore
      level: debug

Document generator commands:

yarn start organization-quick
yarn start generate-entity-maintainers-data --quick

Example watchlist with entity source

// watchlist 
POST kbn:/api/entity_analytics/watchlists 
{
    "name": "test-name-1",
    "description": "Test watchlist for index sync-1",
    "riskModifier": 1.5,
    "managed": false
}
// get the id for the next call
GET kbn:/api/entity_analytics/watchlists/list

// entity source for this watchlist 
POST kbn:/api/entity_analytics/watchlists/{watchlist-id}/entity_source
{
    "type": "index",
    "name": "some-watchlist-source-name",
    "queryRule": "entity.risk.calculated_level : \"High\" or entity.risk.calculated_level : \"Moderate\"",
    "identifierField": "user.name"
}


GET .entity-analytics.watchlists.test-name-1-default/_search

Testing Steps:
0. Update WATCHLIST_MAINTAINER_INTERVAL in register watchlist maintainer to something smol like 1m

  1. Start up kibana with the admin/platinum license.
  2. Ensure entity analytics is enabled (v2)
  3. With the data generated from document generator ...
  4. Look in kibana logs for Entity Analytics Watchlist Maintainer
  5. Head over to dev tools and create a watchlist with an entity source
  6. Head back to the kibana logs, look out for:
    'Watchlist maintainer run for namespace "default'
    Then something like
    'Found n watchlist(s) to sync in namespace "default"
    Syncing watchlist "name" ()'
  7. Go back to dev tools and have a look at the watchlist index to see synced entities!

@CAWilson94 CAWilson94 changed the title maintainer WiP Watchlists Maintainer and Prebuilt Watchlist Install Mar 30, 2026
logger.debug(`Initializing watchlist maintainer for namespace "${namespace}"`);

// TODO: add watchlist-specific setup logic here (e.g. saved objects, data client init)
// Add in call to pre-built watchlists install
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Doing this in the entity analytics migration flow instead

@CAWilson94 CAWilson94 changed the title Watchlists Maintainer and Prebuilt Watchlist Install Watchlists maintainer, sync all watchlists on setup Mar 30, 2026
@CAWilson94 CAWilson94 marked this pull request as ready for review March 30, 2026 19:08
@CAWilson94 CAWilson94 requested review from a team as code owners March 30, 2026 19:08
@CAWilson94 CAWilson94 requested a review from hop-dev March 30, 2026 19:08
@CAWilson94 CAWilson94 added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting Theme: entity_analytics Feature:Entity Analytics Security Solution Entity Analytics features Team:Entity Analytics Security Entity Analytics Team v9.4.0 labels Mar 30, 2026
@CAWilson94 CAWilson94 self-assigned this Mar 30, 2026
Copy link
Copy Markdown
Contributor

@jaredburgettelastic jaredburgettelastic left a comment

Choose a reason for hiding this comment

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

👍 Code looks good, but I think we will have to register this as a task in check_registered_task_types.ts. Will wait for CI to pass/fail to check first, as I'm unsure if that's necessary or not until the feature flag is enabled by default

@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Mar 30, 2026

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #63 / Cloud Security Posture GET /internal/cloud_security_posture/stats KSPM Compliance Dashboard Stats API should return KSPM benchmarks V2
  • [job] [logs] FTR Configs #98 / serverless security UI Security ML Trained models list page navigation renders trained models list
  • [job] [logs] Jest Integration Tests #1 / Serverless upgrade and rollback checks detect param changes to review for: siem.eqlRule
  • [job] [logs] Jest Integration Tests #1 / Serverless upgrade and rollback checks detect param changes to review for: siem.eqlRule
  • [job] [logs] Jest Integration Tests #1 / Serverless upgrade and rollback checks detect param changes to review for: siem.eqlRule
  • [job] [logs] Jest Integration Tests #1 / Serverless upgrade and rollback checks detect param changes to review for: siem.indicatorRule
  • [job] [logs] Jest Integration Tests #1 / Serverless upgrade and rollback checks detect param changes to review for: siem.indicatorRule
  • [job] [logs] Jest Integration Tests #1 / Serverless upgrade and rollback checks detect param changes to review for: siem.indicatorRule
  • [job] [logs] Jest Integration Tests #1 / Serverless upgrade and rollback checks detect param changes to review for: siem.mlRule
  • [job] [logs] Jest Integration Tests #1 / Serverless upgrade and rollback checks detect param changes to review for: siem.mlRule
  • [job] [logs] Jest Integration Tests #1 / Serverless upgrade and rollback checks detect param changes to review for: siem.mlRule
  • [job] [logs] Jest Integration Tests #1 / Serverless upgrade and rollback checks detect param changes to review for: siem.newTermsRule
  • [job] [logs] Jest Integration Tests #1 / Serverless upgrade and rollback checks detect param changes to review for: siem.newTermsRule
  • [job] [logs] Jest Integration Tests #1 / Serverless upgrade and rollback checks detect param changes to review for: siem.newTermsRule
  • [job] [logs] Jest Integration Tests #1 / Serverless upgrade and rollback checks detect param changes to review for: siem.queryRule
  • [job] [logs] Jest Integration Tests #1 / Serverless upgrade and rollback checks detect param changes to review for: siem.queryRule
  • [job] [logs] Jest Integration Tests #1 / Serverless upgrade and rollback checks detect param changes to review for: siem.queryRule
  • [job] [logs] Jest Integration Tests #1 / Serverless upgrade and rollback checks detect param changes to review for: siem.savedQueryRule
  • [job] [logs] Jest Integration Tests #1 / Serverless upgrade and rollback checks detect param changes to review for: siem.savedQueryRule
  • [job] [logs] Jest Integration Tests #1 / Serverless upgrade and rollback checks detect param changes to review for: siem.savedQueryRule
  • [job] [logs] Jest Integration Tests #1 / Serverless upgrade and rollback checks detect param changes to review for: siem.thresholdRule
  • [job] [logs] Jest Integration Tests #1 / Serverless upgrade and rollback checks detect param changes to review for: siem.thresholdRule
  • [job] [logs] Jest Integration Tests #1 / Serverless upgrade and rollback checks detect param changes to review for: siem.thresholdRule

Metrics [docs]

✅ unchanged

History

cc @CAWilson94

// credentials of the user who installed the Entity Store) rather than
// buildScopedInternalSavedObjectsClientUnsafe, which builds its own fake
// request with empty headers and no auth credentials.
const soClient = coreStart.savedObjects.getScopedClient(fakeRequest, {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we now have a better way of doing this. Maybe even privmon or risk engine already use the new version, so we can check later

Just flagging it, wont block for this!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I think you are correct . Will add it to the list!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agreed, you can use this as an example of the new way to do so for entity maintainers. It comes with its own esClient, scoped to the user who originally enabled the entity store.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(we now get this for free from task manager)

@CAWilson94
Copy link
Copy Markdown
Contributor Author

👍 Code looks good, but I think we will have to register this as a task in check_registered_task_types.ts. Will wait for CI to pass/fail to check first, as I'm unsure if that's necessary or not until the feature flag is enabled by default

Thanks @jaredburgettelastic nice catch!

The check_registered_task_types.ts test only sees task types that are registered with default config.

Since both entityAnalyticsEntityStoreV2 and entityAnalyticsWatchlistEnabled default to false, the watchlist maintainer task type (entity_store:v2:entity_maintainer_task:watchlist) won't be registered when that test runs — so we don't need to add it there yet.

Same for the risk scoring maintainer, so we will need to update both once the flags are gone.

@jaredburgettelastic jaredburgettelastic merged commit ad8803c into main Mar 30, 2026
18 checks passed
@jaredburgettelastic jaredburgettelastic deleted the watchlist-maintainer branch March 30, 2026 22:47
jeramysoucy pushed a commit to jeramysoucy/kibana that referenced this pull request Apr 1, 2026
### Summary 
This PR adds the watchlist maintainer and registers it on plugin setup.
Additionally, all watchlists are synced on a 10 minute schedule.

**Feature flags:**  

```
xpack.securitySolution.enableExperimental:
  - entityAnalyticsEntityStoreV2
  - entityAnalyticsWatchlistEnabled
```

Debugging log config: 

```
logging:
  loggers:
    - name: plugins.securitySolution
      level: debug
    - name: plugins.entityStore
      level: debug
```

Document generator commands: 
```
yarn start organization-quick
yarn start generate-entity-maintainers-data --quick
```

Example watchlist with entity source 
```
// watchlist 
POST kbn:/api/entity_analytics/watchlists 
{
    "name": "test-name-1",
    "description": "Test watchlist for index sync-1",
    "riskModifier": 1.5,
    "managed": false
}
// get the id for the next call
GET kbn:/api/entity_analytics/watchlists/list

// entity source for this watchlist 
POST kbn:/api/entity_analytics/watchlists/{watchlist-id}/entity_source
{
    "type": "index",
    "name": "some-watchlist-source-name",
    "queryRule": "entity.risk.calculated_level : \"High\" or entity.risk.calculated_level : \"Moderate\"",
    "identifierField": "user.name"
}


GET .entity-analytics.watchlists.test-name-1-default/_search

```
Testing Steps: 
0. Update WATCHLIST_MAINTAINER_INTERVAL in register watchlist maintainer
to something smol like 1m
1. Start up kibana with the admin/platinum license. 
2. Ensure entity analytics is enabled (v2) 
3. With the data generated from document generator ... 
4. Look in kibana logs for Entity Analytics Watchlist Maintainer
5. Head over to dev tools and create a watchlist with an entity source 
6. Head back to the kibana logs, look out for: 
'Watchlist maintainer run for namespace "default'
Then something like 
'Found n watchlist(s) to sync in namespace "default"
Syncing watchlist "name" (<watchlist-id>)'
7. Go back to dev tools and have a look at the watchlist index to see
synced entities!

---------

Co-authored-by: Jared Burgett <147995946+jaredburgettelastic@users.noreply.github.com>
paulinashakirova pushed a commit to paulinashakirova/kibana that referenced this pull request Apr 2, 2026
### Summary 
This PR adds the watchlist maintainer and registers it on plugin setup.
Additionally, all watchlists are synced on a 10 minute schedule.

**Feature flags:**  

```
xpack.securitySolution.enableExperimental:
  - entityAnalyticsEntityStoreV2
  - entityAnalyticsWatchlistEnabled
```

Debugging log config: 

```
logging:
  loggers:
    - name: plugins.securitySolution
      level: debug
    - name: plugins.entityStore
      level: debug
```

Document generator commands: 
```
yarn start organization-quick
yarn start generate-entity-maintainers-data --quick
```

Example watchlist with entity source 
```
// watchlist 
POST kbn:/api/entity_analytics/watchlists 
{
    "name": "test-name-1",
    "description": "Test watchlist for index sync-1",
    "riskModifier": 1.5,
    "managed": false
}
// get the id for the next call
GET kbn:/api/entity_analytics/watchlists/list

// entity source for this watchlist 
POST kbn:/api/entity_analytics/watchlists/{watchlist-id}/entity_source
{
    "type": "index",
    "name": "some-watchlist-source-name",
    "queryRule": "entity.risk.calculated_level : \"High\" or entity.risk.calculated_level : \"Moderate\"",
    "identifierField": "user.name"
}


GET .entity-analytics.watchlists.test-name-1-default/_search

```
Testing Steps: 
0. Update WATCHLIST_MAINTAINER_INTERVAL in register watchlist maintainer
to something smol like 1m
1. Start up kibana with the admin/platinum license. 
2. Ensure entity analytics is enabled (v2) 
3. With the data generated from document generator ... 
4. Look in kibana logs for Entity Analytics Watchlist Maintainer
5. Head over to dev tools and create a watchlist with an entity source 
6. Head back to the kibana logs, look out for: 
'Watchlist maintainer run for namespace "default'
Then something like 
'Found n watchlist(s) to sync in namespace "default"
Syncing watchlist "name" (<watchlist-id>)'
7. Go back to dev tools and have a look at the watchlist index to see
synced entities!

---------

Co-authored-by: Jared Burgett <147995946+jaredburgettelastic@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Feature:Entity Analytics Security Solution Entity Analytics features release_note:skip Skip the PR/issue when compiling release notes Team:Entity Analytics Security Entity Analytics Team Theme: entity_analytics v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants