-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Fleet] Support for remote ES output #169252
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
c98403e
remote es output
juliaElastic e49de06
[CI] Auto-commit changed files from 'node scripts/check_mappings_upda…
kibanamachine 22db8e2
generate service token from UI
juliaElastic 97cf572
moved service token generation to settings
juliaElastic f153d18
removed unused translations
juliaElastic 7cb9c22
hide remote es output from agent policy data output dropdown
juliaElastic 1fa0426
include output_permissions and service_token for remote output
juliaElastic f0e8070
removed generate token from settings and added callout to flyout
juliaElastic 9ef33e4
fix unit test
juliaElastic fd02cfd
fix test
juliaElastic f42f1c6
Merge remote-tracking branch 'upstream/main' into remote-es-output
juliaElastic 11b8cc1
[CI] Auto-commit changed files from 'node scripts/jest_integration -u…
kibanamachine b818b90
fix type after merge conflict
juliaElastic 9e0621b
turn feature flag off for now
juliaElastic 2700ab6
Merge branch 'main' into remote-es-output
juliaElastic 200a227
added tests
juliaElastic dc46e2f
Merge branch 'main' into remote-es-output
juliaElastic bc2e10b
updated callout
juliaElastic 0315d01
added mappings_addition to SO config
juliaElastic 43c864c
[CI] Auto-commit changed files from 'node scripts/jest_integration -u…
kibanamachine d9257fb
Merge branch 'main' into remote-es-output
juliaElastic d9eb33f
review comments
juliaElastic 54c3900
Merge branch 'main' into remote-es-output
juliaElastic 813846d
fix tests
juliaElastic fcaa3e8
fixing schema validation
juliaElastic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
37 changes: 0 additions & 37 deletions
37
...public/applications/fleet/components/fleet_server_instructions/hooks/use_service_token.ts
This file was deleted.
Oops, something went wrong.
This file contains 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
138 changes: 138 additions & 0 deletions
138
x-pack/plugins/fleet/public/applications/fleet/components/generate_service_token.tsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
import { EuiLink, EuiToolTip } from '@elastic/eui'; | ||
import { | ||
EuiButton, | ||
EuiCallOut, | ||
EuiCodeBlock, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiSpacer, | ||
EuiText, | ||
} from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
|
||
import { useStartServices } from '../../../hooks'; | ||
import { useCheckPermissions } from '../hooks'; | ||
|
||
const FlexItemWithMinWidth = styled(EuiFlexItem)` | ||
min-width: 0px; | ||
max-width: 100%; | ||
`; | ||
|
||
// Otherwise the copy button is over the text | ||
const CommandCode = styled.div.attrs(() => { | ||
return { | ||
className: 'eui-textBreakAll', | ||
}; | ||
})` | ||
margin-right: ${(props) => props.theme.eui.euiSizeM}; | ||
`; | ||
|
||
export const GenerateServiceTokenComponent: React.FunctionComponent<{ | ||
serviceToken?: string; | ||
generateServiceToken: (remote?: boolean) => void; | ||
isLoadingServiceToken: boolean; | ||
isRemote?: boolean; | ||
}> = ({ serviceToken, generateServiceToken, isLoadingServiceToken, isRemote = false }) => { | ||
const { docLinks } = useStartServices(); | ||
const { permissionsError, isPermissionsLoading } = useCheckPermissions(); | ||
|
||
return ( | ||
<> | ||
<EuiText> | ||
{isRemote ? ( | ||
<FormattedMessage | ||
id="xpack.fleet.settings.remoteServiceToken.generateServiceTokenDescription" | ||
defaultMessage="A service token grants Fleet Server permissions to write to Elasticsearch, and can be used to configure this Elasticsearch cluster for remote output. For more information, see the {fleetUserGuide}." | ||
values={{ | ||
fleetUserGuide: ( | ||
<EuiLink href={docLinks.links.fleet.guide} target="_blank"> | ||
{i18n.translate('xpack.fleet.settings.editOutputFlyout.fleetUserGuideLabel', { | ||
defaultMessage: 'Fleet User Guide', | ||
})} | ||
</EuiLink> | ||
), | ||
}} | ||
/> | ||
) : ( | ||
<FormattedMessage | ||
id="xpack.fleet.fleetServerSetup.generateServiceTokenDescription" | ||
defaultMessage="A service token grants Fleet Server permissions to write to Elasticsearch." | ||
/> | ||
)} | ||
</EuiText> | ||
<EuiSpacer size="m" /> | ||
{!serviceToken ? ( | ||
<EuiFlexGroup> | ||
<EuiFlexItem grow={false}> | ||
<EuiToolTip | ||
content={ | ||
isRemote && !!permissionsError ? ( | ||
<FormattedMessage | ||
id="xpack.fleet.settings.remoteServiceToken.noPermissionTooltip" | ||
defaultMessage="To generate service token, you must have the minimum required privileges. Contact your administrator." | ||
/> | ||
) : null | ||
} | ||
> | ||
<EuiButton | ||
fill | ||
isLoading={isLoadingServiceToken} | ||
isDisabled={isLoadingServiceToken || isPermissionsLoading || !!permissionsError} | ||
onClick={() => { | ||
generateServiceToken(isRemote); | ||
}} | ||
data-test-subj="fleetServerGenerateServiceTokenBtn" | ||
> | ||
<FormattedMessage | ||
id="xpack.fleet.fleetServerSetup.generateServiceTokenButton" | ||
defaultMessage="Generate service token" | ||
/> | ||
</EuiButton> | ||
</EuiToolTip> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
) : ( | ||
<> | ||
<EuiCallOut | ||
iconType="check" | ||
size="s" | ||
color="success" | ||
title={ | ||
<FormattedMessage | ||
id="xpack.fleet.fleetServerSetup.saveServiceTokenDescription" | ||
defaultMessage="Save your service token information. This will be shown only once." | ||
/> | ||
} | ||
/> | ||
<EuiSpacer size="m" /> | ||
<EuiFlexGroup direction="column" gutterSize="s"> | ||
<EuiFlexItem grow={false}> | ||
<strong data-test-subject="serviceTokenSaveReminderHeader"> | ||
<FormattedMessage | ||
id="xpack.fleet.fleetServerSetup.serviceTokenLabel" | ||
defaultMessage="Service token" | ||
/> | ||
</strong> | ||
</EuiFlexItem> | ||
<FlexItemWithMinWidth> | ||
<EuiCodeBlock paddingSize="m" isCopyable> | ||
<CommandCode>{serviceToken}</CommandCode> | ||
</EuiCodeBlock> | ||
</FlexItemWithMinWidth> | ||
</EuiFlexGroup> | ||
</> | ||
)} | ||
</> | ||
); | ||
}; |
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved out and renamed this component to
GenerateServiceTokenComponent
to reuse in generating remote tokenThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the end I haven't used this component somewhere else, but I think the refactor can be left in.