Skip to content

[Obs AI Assistant] Anonymization support#223351

Merged
dgieselaar merged 89 commits intoelastic:mainfrom
dgieselaar:assistant-anonymization-rules
Jun 11, 2025
Merged

[Obs AI Assistant] Anonymization support#223351
dgieselaar merged 89 commits intoelastic:mainfrom
dgieselaar:assistant-anonymization-rules

Conversation

@dgieselaar
Copy link
Copy Markdown
Contributor

@dgieselaar dgieselaar commented Jun 11, 2025

Re-submit of #216352 as it has merge conflicts and we don't have write permissions for Sandra's remote.

To test, add the following to your kibana.yml:

uiSettings:
  overrides:
    "observability:aiAssistantAnonymizationRules":
      - id: "ner"
        type: "ner"
        enabled: true
      - id: "beach"
        type: "regex"
        enabled: true
        pattern: "sandy"

@sorenlouv sorenlouv requested a review from Copilot June 11, 2025 07:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds end-to-end anonymization support—including redaction, deanonymization, new types, UI settings, and chat‐level highlighting—to the Observability AI Assistant plugin.

  • Introduces hash‐based redaction/unredaction utilities and service methods
  • Defines new types (DetectedEntity, Unredaction, AnonymizationRule) and runtime schema updates
  • Adds UI settings for anonymization rules and integrates entity highlighting in chat components

Reviewed Changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated no comments.

Show a summary per file
File Description
server/service/anonymization/deanonymize_text.ts New service to replace hashes with original values
server/service/anonymization/chunk_text.ts Utility to split text into inference‐sized chunks
server/routes/runtime_types.ts Added unredactions runtime type to message schema
public/plugin.tsx Refactored config retrieval for scopeFromConfig
public/index.ts Export anonymization utilities and new settings key
public/components/message_panel/message_text.tsx Render highlighted/anonymized content when provided
common/utils/anonymization/redaction.ts Core redaction and unhashing functions
common/types.ts New interfaces for DetectedEntity, Unredaction, etc.
common/ui_settings/settings_keys.ts Added key for anonymization rules
common/index.ts Exported AnonymizationRule and settings key
private/.../server/plugin.ts Excluded anonymization rules from core settings reg.
private/.../config.ts Formatted exposeToBrowser object
private/.../settings_page.test.tsx Reformatted test config object
private/.../common/ui_settings.ts Defined UI setting for anonymization rules
packages/shared/kbn-ai-assistant/src/utils/builders.ts Added unredactions to builder types
packages/shared/kbn-ai-assistant/src/chat/chat_timeline.tsx Integrated UI logic for anonymization highlighting
packages/shared/kbn-ai-assistant/src/chat/chat_item_content_inline_prompt_editor.tsx Passed anonymized content into MessageText
packages/shared/kbn-ai-assistant/src/chat/chat_item.tsx Added text extraction from ReactNode for clipboard
packages/shared/ai-infra/inference-common/src/chat_complete/events.ts Defined ChatCompletionUnredactedMessageEvent
Comments suppressed due to low confidence (3)

server/service/anonymization/deanonymize_text.ts:14

  • The doc comment mentions placeholders with braces (e.g., "{hash123}"), but HASH_REGEX only matches raw 40-char hex strings. Update the doc or regex to stay consistent.
* Takes text containing hash placeholders like "{hash123}" and replaces

server/routes/runtime_types.ts:56

  • unredactions is marked as required, but it should be optional to match the Message interface. Consider wrapping it in t.partial or using t.union([t.array(unredactionRt), t.undefined]).
unredactions: t.array(unredactionRt),

packages/shared/ai-infra/inference-common/src/chat_complete/events.ts:38

  • The unredactions payload here includes only entity, class_name, and hash, but client highlighting relies on positional data (start_pos, end_pos). Consider adding those fields for consistency.
export interface ChatCompletionUnredactedMessageEvent<

@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Jun 11, 2025

💚 Build Succeeded

  • Buildkite Build
  • Commit: d07e8c8
  • Kibana Serverless Image: docker.elastic.co/kibana-ci/kibana-serverless:pr-223351-d07e8c8dcdb1

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
observabilityAIAssistant 106 107 +1

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
observabilityAIAssistant 427 443 +16

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
observabilityAIAssistantApp 173.8KB 174.8KB +1013.0B
searchAssistant 100.1KB 101.1KB +1007.0B
total +2.0KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
observabilityAIAssistant 27 30 +3

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
observabilityAIAssistant 40.5KB 41.0KB +485.0B
Unknown metric groups

API count

id before after diff
observabilityAIAssistant 429 447 +18

History

@dgieselaar dgieselaar merged commit 71ec37a into elastic:main Jun 11, 2025
11 checks passed
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.19

https://github.com/elastic/kibana/actions/runs/15580615122

@dgieselaar dgieselaar deleted the assistant-anonymization-rules branch June 11, 2025 09:03
@kibanamachine
Copy link
Copy Markdown
Contributor

💔 All backports failed

Status Branch Result
8.19 Backport failed because of merge conflicts

You might need to backport the following PRs to 8.19:
- [Obs AI Assistant] Add Elastic Managed LLM tour callout (#220782)

Manual backport

To create the backport manually run:

node scripts/backport --pr 223351

Questions ?

Please refer to the Backport tool documentation

nickpeihl pushed a commit to nickpeihl/kibana that referenced this pull request Jun 12, 2025
Re-submit of elastic#216352 as it has
merge conflicts and we don't have write permissions for Sandra's remote.

To test, add the following to your kibana.yml:

```
uiSettings:
  overrides:
    "observability:aiAssistantAnonymizationRules":
      - id: "ner"
        type: "ner"
        enabled: true
      - id: "beach"
        type: "regex"
        enabled: true
        pattern: "sandy"
```

---------

Co-authored-by: Sandra Gonzales <sandra.gonzales@elastic.co>
Co-authored-by: Sandra G <neptunian@users.noreply.github.com>
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Jun 13, 2025
@kibanamachine
Copy link
Copy Markdown
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 223351 locally
cc: @dgieselaar

iblancof pushed a commit to iblancof/kibana that referenced this pull request Jun 16, 2025
Re-submit of elastic#216352 as it has
merge conflicts and we don't have write permissions for Sandra's remote.

To test, add the following to your kibana.yml:

```
uiSettings:
  overrides:
    "observability:aiAssistantAnonymizationRules":
      - id: "ner"
        type: "ner"
        enabled: true
      - id: "beach"
        type: "regex"
        enabled: true
        pattern: "sandy"
```

---------

Co-authored-by: Sandra Gonzales <sandra.gonzales@elastic.co>
Co-authored-by: Sandra G <neptunian@users.noreply.github.com>
@kibanamachine
Copy link
Copy Markdown
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 223351 locally
cc: @dgieselaar

@neptunian
Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
8.19

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

neptunian pushed a commit to neptunian/kibana that referenced this pull request Jun 16, 2025
Re-submit of elastic#216352 as it has
merge conflicts and we don't have write permissions for Sandra's remote.

To test, add the following to your kibana.yml:

```
uiSettings:
  overrides:
    "observability:aiAssistantAnonymizationRules":
      - id: "ner"
        type: "ner"
        enabled: true
      - id: "beach"
        type: "regex"
        enabled: true
        pattern: "sandy"
```

---------

Co-authored-by: Sandra Gonzales <sandra.gonzales@elastic.co>
Co-authored-by: Sandra G <neptunian@users.noreply.github.com>
(cherry picked from commit 71ec37a)

# Conflicts:
#	x-pack/platform/packages/shared/kbn-ai-assistant/src/chat/chat_timeline.tsx
#	x-pack/platform/plugins/shared/observability_ai_assistant/server/service/client/index.ts
neptunian added a commit that referenced this pull request Jun 16, 2025
# Backport

This will backport the following commits from `main` to `8.19`:
- [[Obs AI Assistant] Anonymization support
(#223351)](#223351)

<!--- Backport version: 10.0.1 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Dario
Gieselaar","email":"dario.gieselaar@elastic.co"},"sourceCommit":{"committedDate":"2025-06-11T09:00:40Z","message":"[Obs
AI Assistant] Anonymization support (#223351)\n\nRe-submit of
#216352 as it has\nmerge conflicts
and we don't have write permissions for Sandra's remote.\n\nTo test, add
the following to your kibana.yml:\n\n```\nuiSettings:\n overrides:\n
\"observability:aiAssistantAnonymizationRules\":\n - id: \"ner\"\n type:
\"ner\"\n enabled: true\n - id: \"beach\"\n type: \"regex\"\n enabled:
true\n pattern: \"sandy\"\n```\n\n---------\n\nCo-authored-by: Sandra
Gonzales <sandra.gonzales@elastic.co>\nCo-authored-by: Sandra G
<neptunian@users.noreply.github.com>","sha":"71ec37a2a688ca5b0791658e7cc7d0634e7139a9","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","backport
missing","Team:Obs AI
Assistant","ci:project-deploy-observability","backport:version","v9.1.0","v8.19.0"],"title":"[Obs
AI Assistant] Anonymization
support","number":223351,"url":"https://github.com/elastic/kibana/pull/223351","mergeCommit":{"message":"[Obs
AI Assistant] Anonymization support (#223351)\n\nRe-submit of
#216352 as it has\nmerge conflicts
and we don't have write permissions for Sandra's remote.\n\nTo test, add
the following to your kibana.yml:\n\n```\nuiSettings:\n overrides:\n
\"observability:aiAssistantAnonymizationRules\":\n - id: \"ner\"\n type:
\"ner\"\n enabled: true\n - id: \"beach\"\n type: \"regex\"\n enabled:
true\n pattern: \"sandy\"\n```\n\n---------\n\nCo-authored-by: Sandra
Gonzales <sandra.gonzales@elastic.co>\nCo-authored-by: Sandra G
<neptunian@users.noreply.github.com>","sha":"71ec37a2a688ca5b0791658e7cc7d0634e7139a9"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/223351","number":223351,"mergeCommit":{"message":"[Obs
AI Assistant] Anonymization support (#223351)\n\nRe-submit of
#216352 as it has\nmerge conflicts
and we don't have write permissions for Sandra's remote.\n\nTo test, add
the following to your kibana.yml:\n\n```\nuiSettings:\n overrides:\n
\"observability:aiAssistantAnonymizationRules\":\n - id: \"ner\"\n type:
\"ner\"\n enabled: true\n - id: \"beach\"\n type: \"regex\"\n enabled:
true\n pattern: \"sandy\"\n```\n\n---------\n\nCo-authored-by: Sandra
Gonzales <sandra.gonzales@elastic.co>\nCo-authored-by: Sandra G
<neptunian@users.noreply.github.com>","sha":"71ec37a2a688ca5b0791658e7cc7d0634e7139a9"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

---------

Co-authored-by: Dario Gieselaar <dario.gieselaar@elastic.co>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels ci:project-deploy-observability Create an Observability project release_note:enhancement Team:Obs AI Assistant Observability AI Assistant v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants