[Security solution] Implement dashboard to track Gen AI Token Usage#159075
Merged
stephmilovic merged 79 commits intoelastic:mainfrom Jun 15, 2023
Merged
[Security solution] Implement dashboard to track Gen AI Token Usage#159075stephmilovic merged 79 commits intoelastic:mainfrom
stephmilovic merged 79 commits intoelastic:mainfrom
Conversation
Contributor
Author
|
@elasticmachine merge upstream |
stephmilovic
commented
Jun 14, 2023
| ) | ||
| .set('kbn-xsrf', 'foo') | ||
| .expect(204); | ||
| .expect(plugin === 'saved_objects' ? 200 : 204); |
Contributor
Author
There was a problem hiding this comment.
I'm deleting a saved object, and the successful response for this api is 200
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
kobelb
approved these changes
Jun 15, 2023
angorayc
approved these changes
Jun 15, 2023
Contributor
angorayc
left a comment
There was a problem hiding this comment.
Nicely done! Thank you Steph! LGTM!
11 tasks
pgayvallet
added a commit
that referenced
this pull request
Jan 28, 2025
## Summary In #159075 was introduced a reference from the `stack_connectors` plugin to the `dashboard` plugin. This dependency was made so that the logic creating the GenAI dashboard has proper typing for the dashboard SO attributes type. However, that is a bad isolation of concerns, introducing a high risk of cyclic dependencies: the `dashboard` plugin, or any of its dependencies, can't depend on `stack_connectors`, or any plugin depending on stack_connectors. This is especially problematic because of another bad design decision of having `dashboard` depending on `observability_ai_assistant`, as it increases the risk of circular dependencies. This PR addresses it by removing the few usages we have of the dashboard plugin's type in stack_connectors. Of course the ideal fix would be to extract the type from the dashboard plugin instead, but those types we're using here are inferred from config schema concrete objects, making it complicated, so I went the pragmatic road even if it means loosing a bit of type safety.
kibanamachine
pushed a commit
to kibanamachine/kibana
that referenced
this pull request
Jan 28, 2025
…08165) ## Summary In elastic#159075 was introduced a reference from the `stack_connectors` plugin to the `dashboard` plugin. This dependency was made so that the logic creating the GenAI dashboard has proper typing for the dashboard SO attributes type. However, that is a bad isolation of concerns, introducing a high risk of cyclic dependencies: the `dashboard` plugin, or any of its dependencies, can't depend on `stack_connectors`, or any plugin depending on stack_connectors. This is especially problematic because of another bad design decision of having `dashboard` depending on `observability_ai_assistant`, as it increases the risk of circular dependencies. This PR addresses it by removing the few usages we have of the dashboard plugin's type in stack_connectors. Of course the ideal fix would be to extract the type from the dashboard plugin instead, but those types we're using here are inferred from config schema concrete objects, making it complicated, so I went the pragmatic road even if it means loosing a bit of type safety. (cherry picked from commit 5b62617)
kibanamachine
added a commit
that referenced
this pull request
Jan 28, 2025
…dashboard` (#208165) (#208604) # Backport This will backport the following commits from `main` to `8.x`: - [Remove TS reference from `stack_connectors` to `dashboard` (#208165)](#208165) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Pierre Gayvallet","email":"pierre.gayvallet@elastic.co"},"sourceCommit":{"committedDate":"2025-01-28T18:58:57Z","message":"Remove TS reference from `stack_connectors` to `dashboard` (#208165)\n\n## Summary\r\n\r\nIn #159075 was introduced a reference from the `stack_connectors` plugin\r\nto the `dashboard` plugin. This dependency was made so that the logic\r\ncreating the GenAI dashboard has proper typing for the dashboard SO\r\nattributes type.\r\n\r\nHowever, that is a bad isolation of concerns, introducing a high risk of\r\ncyclic dependencies: the `dashboard` plugin, or any of its dependencies,\r\ncan't depend on `stack_connectors`, or any plugin depending on\r\nstack_connectors.\r\n\r\nThis is especially problematic because of another bad design decision of\r\nhaving `dashboard` depending on `observability_ai_assistant`, as it\r\nincreases the risk of circular dependencies.\r\n\r\nThis PR addresses it by removing the few usages we have of the dashboard\r\nplugin's type in stack_connectors. Of course the ideal fix would be to\r\nextract the type from the dashboard plugin instead, but those types\r\nwe're using here are inferred from config schema concrete objects,\r\nmaking it complicated, so I went the pragmatic road even if it means\r\nloosing a bit of type safety.","sha":"5b6261782e6c93ccd11c3b145cc01bf671780229","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:version","v8.18.0"],"title":"Remove TS reference from `stack_connectors` to `dashboard`","number":208165,"url":"https://github.com/elastic/kibana/pull/208165","mergeCommit":{"message":"Remove TS reference from `stack_connectors` to `dashboard` (#208165)\n\n## Summary\r\n\r\nIn #159075 was introduced a reference from the `stack_connectors` plugin\r\nto the `dashboard` plugin. This dependency was made so that the logic\r\ncreating the GenAI dashboard has proper typing for the dashboard SO\r\nattributes type.\r\n\r\nHowever, that is a bad isolation of concerns, introducing a high risk of\r\ncyclic dependencies: the `dashboard` plugin, or any of its dependencies,\r\ncan't depend on `stack_connectors`, or any plugin depending on\r\nstack_connectors.\r\n\r\nThis is especially problematic because of another bad design decision of\r\nhaving `dashboard` depending on `observability_ai_assistant`, as it\r\nincreases the risk of circular dependencies.\r\n\r\nThis PR addresses it by removing the few usages we have of the dashboard\r\nplugin's type in stack_connectors. Of course the ideal fix would be to\r\nextract the type from the dashboard plugin instead, but those types\r\nwe're using here are inferred from config schema concrete objects,\r\nmaking it complicated, so I went the pragmatic road even if it means\r\nloosing a bit of type safety.","sha":"5b6261782e6c93ccd11c3b145cc01bf671780229"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/208165","number":208165,"mergeCommit":{"message":"Remove TS reference from `stack_connectors` to `dashboard` (#208165)\n\n## Summary\r\n\r\nIn #159075 was introduced a reference from the `stack_connectors` plugin\r\nto the `dashboard` plugin. This dependency was made so that the logic\r\ncreating the GenAI dashboard has proper typing for the dashboard SO\r\nattributes type.\r\n\r\nHowever, that is a bad isolation of concerns, introducing a high risk of\r\ncyclic dependencies: the `dashboard` plugin, or any of its dependencies,\r\ncan't depend on `stack_connectors`, or any plugin depending on\r\nstack_connectors.\r\n\r\nThis is especially problematic because of another bad design decision of\r\nhaving `dashboard` depending on `observability_ai_assistant`, as it\r\nincreases the risk of circular dependencies.\r\n\r\nThis PR addresses it by removing the few usages we have of the dashboard\r\nplugin's type in stack_connectors. Of course the ideal fix would be to\r\nextract the type from the dashboard plugin instead, but those types\r\nwe're using here are inferred from config schema concrete objects,\r\nmaking it complicated, so I went the pragmatic road even if it means\r\nloosing a bit of type safety.","sha":"5b6261782e6c93ccd11c3b145cc01bf671780229"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Pierre Gayvallet <pierre.gayvallet@elastic.co>
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
Resolves https://github.com/elastic/security-team/issues/6712
getDashboard. The subaction checks if a dashbord with a given id exists, and if not creates the dashboard. Returns{ exists: true }upon successful retreival/creation{ exists: false }if the user does not have permissions.getDashboardsubaction returns{ exists: true }andisEditis true, the connector form displays a link to the dashboard filtered by the connector idType confusion
It seems the
stack_connectorsuses thetriggers_actions_uiCONNECTORS_PLUGIN_IDwhich has its ownTriggersAndActionsUiServicestype. However, when I importuseKibanait is tied to the type forPLUGIN_ID. That is why I extended both versions of the app to includedashboard. Please let me know if you think I should instead maybe export auseKibanathat is specifically typed to the connector?To test
Credentials for OpenAI and Azure OpenAI: https://p.elstc.co/paste/+6nHnsHt#WJOOGIkVoJjTq7zPLP77BzSG1AUxNFUDvcnSfLPtO7m
Testing permissions
Update 6/12/23: Updated to selectively show the link to the dashboard based on user permissions

Update 6/13/23: Added a markdown text block to explain dashboard permissions, content to be updated with a doc link