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

[8.18] add filter to entity definitions schema (#208588) #209075

Merged
merged 1 commit into from
Jan 31, 2025

Conversation

kibanamachine
Copy link
Contributor

Backport

This will backport the following commits from main to 8.18:

Questions ?

Please refer to the Backport tool documentation

## Summary

Adds filter to the entity definition schema so it can be used to filter
entity store data further.

### Testing Steps
1. Open Kibana and start the entity store.
2. Initialise an engine (e.g., user) with a filter:
```
POST kbn:/api/entity_store/engines/user/init
{
   "filter": "@timestamp < now-6w"
}
```
3. Once the transform has run, verify in Dev Tools:
`GET _transform/entities-v1-latest-security_user_default`
You should see the applied filter in the results, alongside default
filters for user.name and timestamp from
[generate_latest_transform.ts](https://github.com/elastic/kibana/blob/90d768be9b35ac26a3b938edac5c1af47cab980a/x-pack/platform/plugins/shared/entity_manager/server/lib/entities/transform/generate_latest_transform.ts#L29)
Example output will include the added filter as part of a bool query.

```
"query": {
          **"bool": {
            "filter": [
              {
                "bool": {
                  "should": [
                    {
                      "range": {
                        "@timestamp": {
                          "lt": "now-6w"
                        }
                      }
                    }
                  ],**
                  "minimum_should_match": 1
                }
              },
              {
                "exists": {
                  "field": "user.name"
                }
              },
              {
                "range": {
                  "@timestamp": {
                    "gte": "now-24h"
                  }
                }
              }
            ]
          }
        }
      },
```

(cherry picked from commit b94475c)
@kibanamachine kibanamachine merged commit 79f37e2 into elastic:8.18 Jan 31, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants