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

[AI Assistant] Add to dashboard #179329

Merged
merged 25 commits into from
Jul 9, 2024

Conversation

dgieselaar
Copy link
Member

@dgieselaar dgieselaar commented Mar 25, 2024

Adds a new functionality in the AI assistant when in dashboards. If the users ask for a question which will generate a query then then can use prompts like:

  • Create a visualization from this query and add this to a dashboard
  • Create a metric from this query and add this to a dashboard
  • ....

meow

How it works

  • It uses the existing functionality of the assistant to create an ES|QL query (if the generated query is wrong is not part of this PR)
  • The LLM returns the query to the new add_to_dashboard function and with the chart type (if the user has added the preference) and the configuration needed for the ConfigBuilder it creates a Lens embeddable and adds it to the dashboard.

How to test

  • Go to advanced settings, find the Observability AI Assistant scope setting and change to Everywhere
  • Go to a dahsboard (existing or new)
  • Ask a question to the AI such as I want the 95th percentile of ... from ... index or I want the median of butes from the kibana_sample_data_logs grouped by the top 5 destinations
  • After the ES|QL query has been generated correctly ask AI to create a chart from this query and add this to the dashboard

important note

As this is the first real consumer of the build api for ES|QL I have fixed and various bugs I discovered in the api.

@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • /oblt-deploy-serverless : Deploy a serverless Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@dgieselaar dgieselaar force-pushed the obs-ai-assistant-add-to-dashboard branch from 8b0a71f to 79fcedb Compare March 26, 2024 15:04
@dgieselaar dgieselaar changed the title [AI Assistant] Add setting for preferred type [AI Assistant] Add to dashboard Mar 26, 2024
@dgieselaar dgieselaar force-pushed the obs-ai-assistant-add-to-dashboard branch from 8eadd3f to 0b8ef48 Compare April 15, 2024 10:01
stratoula and others added 6 commits April 15, 2024 12:18
@elastic elastic deleted a comment from kibana-ci May 6, 2024
@stratoula
Copy link
Contributor

The circular dependency happens because the lens-embeddable-utils needs a type from the maps which on their side have a dependency on the dashboard. The dependency on the dashboard on the maps level can be removed. I will take care of it on another PR

@stratoula stratoula added release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting Team:Obs AI Assistant Observability AI Assistant Feature:ES|QL ES|QL related features in Kibana v8.15.0 labels Jun 23, 2024
@stratoula stratoula marked this pull request as ready for review June 24, 2024 07:32
Copy link
Contributor

@MiriamAparicio MiriamAparicio left a comment

Choose a reason for hiding this comment

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

LGTM

@dgieselaar
Copy link
Member Author

@sorenlouv both good points I think, can you create issues for those?

@stratoula
Copy link
Contributor

/ci

@Heenawter Heenawter self-requested a review July 4, 2024 13:54
@teresaalvarezsoler
Copy link

@stratoula @dgieselaar this works great. Almost all of the feedback I shared here has been addressed.

A small UI thing unrelated with the PR but relevant when using the Assistant in dashboards. If I have the Assistant open as a push flyout and I click on "Edit visualization", the Assistant should be closed and the viz flyout for the inline editor should be open. Instead, the Assistant hides the editor behind now.
image

Copy link

@teresaalvarezsoler teresaalvarezsoler left a comment

Choose a reason for hiding this comment

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

Works great! Next step is to show the assistant by default in dashboards instead of hiding this behind an Adevanced Config so everyone can enjoy these amazing features :)

@stratoula
Copy link
Contributor

Thanx Teresa for looking again into this! I know about this and I want to find a way to tackle this but yes is not relevant with this PR!

maxFontSize: 72,
minFontSize: 12,
orientation: 'single',
showLabel: true,
...(layer.breakdown
? {
tagAccessor: !isFormula ? (layer.breakdown as string) : getAccessorName('breakdown'),
tagAccessor: getAccessorName('breakdown'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why removing the formula support here and above?

Copy link
Contributor

@stratoula stratoula Jul 5, 2024

Choose a reason for hiding this comment

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

It doesnt remove the formula support. (!isFormula) It is fixing a bug in the ES|QL implementation, if you check the rest implementations they use the same logic. This got missed and the tagclouds were not working properly for all cases (I had checked with Peter back then too, is a very old PR)

Copy link
Contributor

@Heenawter Heenawter left a comment

Choose a reason for hiding this comment

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

Tested locally + code review. One thing I noticed is that I am often seeing the following error after adding a visualization?

image

Which then blocks me from adding new visualizations to my dashboard via the AI assistant 🤔 Approving to unblock but curious if the above error is related to this PR?

@stratoula
Copy link
Contributor

@Heenawter thanx Soren mentioned it above #179329 (comment)
Is not related to this PR but we will check it as a follow up

@dgieselaar
Copy link
Member Author

@stratoula I think that's a different error, fwiw

@stratoula
Copy link
Contributor

stratoula commented Jul 5, 2024

Different message, I missed that. Can you help me replicate @Heenawter ? I have never seen it personally

@stratoula stratoula added v8.16.0 backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) and removed backport:skip This commit does not require backporting labels Jul 5, 2024
@stratoula
Copy link
Contributor

/ci

@stratoula
Copy link
Contributor

/ci

@elasticmachine
Copy link
Contributor

elasticmachine commented Jul 8, 2024

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
dashboard 563 609 +46

Async chunks

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

id before after diff
dashboard 503.6KB 529.3KB +25.7KB
infra 1.5MB 1.5MB -82.0B
total +25.6KB

Page load bundle

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

id before after diff
dashboard 43.1KB 43.1KB +54.0B

History

@stratoula
Copy link
Contributor

Different message, I missed that. Can you help me replicate @Heenawter ? I have never seen it personally

I synced with Hannah offline and she cant reproduce it now (neither can I)

@stratoula stratoula merged commit 4013f60 into elastic:main Jul 9, 2024
22 checks passed
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 9, 2024
Adds a new functionality in the AI assistant when in dashboards. If the
users ask for a question which will generate a query then then can use
prompts like:

- `Create a visualization from this query and add this to a dashboard`
- `Create a metric from this query and add this to a dashboard`
- ....

![meow](https://github.com/elastic/kibana/assets/17003240/3092f006-13ce-4565-b9d3-c6ad407afb31)

### How it works
- It uses the existing functionality of the assistant to create an ES|QL
query (if the generated query is wrong is not part of this PR)
- The LLM returns the query to the new `add_to_dashboard` function and
with the chart type (if the user has added the preference) and the
configuration needed for the ConfigBuilder it creates a Lens embeddable
and adds it to the dashboard.

### How to test
- Go to advanced settings, find the `Observability AI Assistant scope`
setting and change to Everywhere
- Go to a dahsboard (existing or new)
- Ask a question to the AI such as `I want the 95th percentile of ...
from ... index` or `I want the median of butes from the
kibana_sample_data_logs grouped by the top 5 destinations`
- After the ES|QL query has been generated correctly ask AI to create a
chart from this query and add this to the dashboard

### important note
As this is the first real consumer of the build api for ES|QL I have
fixed and various bugs I discovered in the api.

---------

Co-authored-by: Stratoula Kalafateli <[email protected]>
Co-authored-by: Stratoula Kalafateli <[email protected]>
Co-authored-by: kibanamachine <[email protected]>
(cherry picked from commit 4013f60)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.15

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

Questions ?

Please refer to the Backport tool documentation

stratoula pushed a commit that referenced this pull request Jul 9, 2024
# Backport

This will backport the following commits from `main` to `8.15`:
- [[AI Assistant] Add to dashboard
(#179329)](#179329)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT [{"author":{"name":"Dario
Gieselaar","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-07-09T07:31:54Z","message":"[AI
Assistant] Add to dashboard (#179329)\n\nAdds a new functionality in the
AI assistant when in dashboards. If the\r\nusers ask for a question
which will generate a query then then can use\r\nprompts like:\r\n\r\n-
`Create a visualization from this query and add this to a
dashboard`\r\n- `Create a metric from this query and add this to a
dashboard`\r\n-
....\r\n\r\n\r\n![meow](https://github.com/elastic/kibana/assets/17003240/3092f006-13ce-4565-b9d3-c6ad407afb31)\r\n\r\n\r\n###
How it works\r\n- It uses the existing functionality of the assistant to
create an ES|QL\r\nquery (if the generated query is wrong is not part of
this PR)\r\n- The LLM returns the query to the new `add_to_dashboard`
function and\r\nwith the chart type (if the user has added the
preference) and the\r\nconfiguration needed for the ConfigBuilder it
creates a Lens embeddable\r\nand adds it to the dashboard.\r\n\r\n###
How to test\r\n- Go to advanced settings, find the `Observability AI
Assistant scope`\r\nsetting and change to Everywhere\r\n- Go to a
dahsboard (existing or new)\r\n- Ask a question to the AI such as `I
want the 95th percentile of ...\r\nfrom ... index` or `I want the median
of butes from the\r\nkibana_sample_data_logs grouped by the top 5
destinations`\r\n- After the ES|QL query has been generated correctly
ask AI to create a\r\nchart from this query and add this to the
dashboard\r\n\r\n\r\n### important note\r\nAs this is the first real
consumer of the build api for ES|QL I have\r\nfixed and various bugs I
discovered in the api.\r\n\r\n---------\r\n\r\nCo-authored-by: Stratoula
Kalafateli <[email protected]>\r\nCo-authored-by: Stratoula
Kalafateli <[email protected]>\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"4013f608c1872b75f4f5601889a478b985479859","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:prev-minor","Team:Obs
AI
Assistant","Feature:ES|QL","ci:project-deploy-observability","apm:review","v8.15.0","v8.16.0"],"title":"[AI
Assistant] Add to
dashboard","number":179329,"url":"https://github.com/elastic/kibana/pull/179329","mergeCommit":{"message":"[AI
Assistant] Add to dashboard (#179329)\n\nAdds a new functionality in the
AI assistant when in dashboards. If the\r\nusers ask for a question
which will generate a query then then can use\r\nprompts like:\r\n\r\n-
`Create a visualization from this query and add this to a
dashboard`\r\n- `Create a metric from this query and add this to a
dashboard`\r\n-
....\r\n\r\n\r\n![meow](https://github.com/elastic/kibana/assets/17003240/3092f006-13ce-4565-b9d3-c6ad407afb31)\r\n\r\n\r\n###
How it works\r\n- It uses the existing functionality of the assistant to
create an ES|QL\r\nquery (if the generated query is wrong is not part of
this PR)\r\n- The LLM returns the query to the new `add_to_dashboard`
function and\r\nwith the chart type (if the user has added the
preference) and the\r\nconfiguration needed for the ConfigBuilder it
creates a Lens embeddable\r\nand adds it to the dashboard.\r\n\r\n###
How to test\r\n- Go to advanced settings, find the `Observability AI
Assistant scope`\r\nsetting and change to Everywhere\r\n- Go to a
dahsboard (existing or new)\r\n- Ask a question to the AI such as `I
want the 95th percentile of ...\r\nfrom ... index` or `I want the median
of butes from the\r\nkibana_sample_data_logs grouped by the top 5
destinations`\r\n- After the ES|QL query has been generated correctly
ask AI to create a\r\nchart from this query and add this to the
dashboard\r\n\r\n\r\n### important note\r\nAs this is the first real
consumer of the build api for ES|QL I have\r\nfixed and various bugs I
discovered in the api.\r\n\r\n---------\r\n\r\nCo-authored-by: Stratoula
Kalafateli <[email protected]>\r\nCo-authored-by: Stratoula
Kalafateli <[email protected]>\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"4013f608c1872b75f4f5601889a478b985479859"}},"sourceBranch":"main","suggestedTargetBranches":["8.15"],"targetPullRequestStates":[{"branch":"8.15","label":"v8.15.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/179329","number":179329,"mergeCommit":{"message":"[AI
Assistant] Add to dashboard (#179329)\n\nAdds a new functionality in the
AI assistant when in dashboards. If the\r\nusers ask for a question
which will generate a query then then can use\r\nprompts like:\r\n\r\n-
`Create a visualization from this query and add this to a
dashboard`\r\n- `Create a metric from this query and add this to a
dashboard`\r\n-
....\r\n\r\n\r\n![meow](https://github.com/elastic/kibana/assets/17003240/3092f006-13ce-4565-b9d3-c6ad407afb31)\r\n\r\n\r\n###
How it works\r\n- It uses the existing functionality of the assistant to
create an ES|QL\r\nquery (if the generated query is wrong is not part of
this PR)\r\n- The LLM returns the query to the new `add_to_dashboard`
function and\r\nwith the chart type (if the user has added the
preference) and the\r\nconfiguration needed for the ConfigBuilder it
creates a Lens embeddable\r\nand adds it to the dashboard.\r\n\r\n###
How to test\r\n- Go to advanced settings, find the `Observability AI
Assistant scope`\r\nsetting and change to Everywhere\r\n- Go to a
dahsboard (existing or new)\r\n- Ask a question to the AI such as `I
want the 95th percentile of ...\r\nfrom ... index` or `I want the median
of butes from the\r\nkibana_sample_data_logs grouped by the top 5
destinations`\r\n- After the ES|QL query has been generated correctly
ask AI to create a\r\nchart from this query and add this to the
dashboard\r\n\r\n\r\n### important note\r\nAs this is the first real
consumer of the build api for ES|QL I have\r\nfixed and various bugs I
discovered in the api.\r\n\r\n---------\r\n\r\nCo-authored-by: Stratoula
Kalafateli <[email protected]>\r\nCo-authored-by: Stratoula
Kalafateli <[email protected]>\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"4013f608c1872b75f4f5601889a478b985479859"}}]}]
BACKPORT-->

Co-authored-by: Dario Gieselaar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:review backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) ci:project-deploy-observability Create an Observability project Feature:ES|QL ES|QL related features in Kibana release_note:skip Skip the PR/issue when compiling release notes Team:Obs AI Assistant Observability AI Assistant v8.15.0 v8.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.