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

[Ingest Manager] support multiple kibana urls #75712

Merged
merged 18 commits into from
Sep 2, 2020

Conversation

neptunian
Copy link
Contributor

@neptunian neptunian commented Aug 21, 2020

#72731

Support letting the user have multiple kibana urls in their global Settings and notify the agent when they change.

Changes

  • validation in the settings flyout and the /settings endpoint that paths and protocol or a list of kibana urls cannot differ
  • the enroll command in the Add Agent flyout will return the first item in the list of kibana URLS.
  • the ingest_manager_settings saved object's kibana_url attribute is now an array of strings type
  • the PUT /api/ingest_manager/settings was changed from allowing only a string url to allowing only an array of string urls. GET always returns kibana_url as an array of strings.
  • the kibana configuration xpack.ingestManager.fleet.kibana.host now accepts both a string url or an array of string urls.
  • PUT /ingest_manager/settings, regardless of what was updated, will bump all agent configuration saved objects revision, triggering a CONFIG_CHANGE action
  • the Kibana URL in the settings flyout is now a EUI combo box that allows for multiple URLS
  • changes all instances of kibana_url of type string to kibana_urls of type string[] and adds migration
  • updates the view agent policy flyout to handle errors from /{agentPolicyId}/full endpoint
    Before:

Screen Shot 2020-08-31 at 2 44 29 PM

After:

Screen Shot 2020-08-31 at 2 28 59 PM

Test

  • integration and unit tests should run
  • in your Kibana configuration yaml file try a list of kibana urls where the path and protocols don't match. It should fail. eg: xpack.ingestManager.fleet.kibana.host: ["http://localhost:5601/", "https://localhost:5603/"]
  • In the Settings flyout, try adding a list of kibana urls where the path and protocols don't match. It should fail. On a successful save, all agent policy saved objects revision should be updated. Look at the Full Agent Policy yaml file through the UI, notice there is now a list of kibana host urls under "fleet".
  • hit the PUT /ingest_manager/settings endpoint, all agent policy saved objects revision should be updated. If an agent is running, notice CONFIG_CHANGE action after a settings update. Also try to to update kibana_url with mismatched paths or protocol through this endpoint. It should fail.

Note

  • I do not check what in the settings was updated or whether kibana_url array has changed or not. The agent configs are always bumped when settings are updated.
  • have left the agent policy SO attribute kibana_url but we should probably change it to kibana_urls. Would like to do this change and SO migration in a separate PR.

@neptunian neptunian self-assigned this Aug 21, 2020
@neptunian neptunian force-pushed the 72731-allow-multiple-kibana-urls branch from 21e41f1 to 543f456 Compare August 25, 2020 17:58
@neptunian neptunian force-pushed the 72731-allow-multiple-kibana-urls branch from ebe2dfb to c71e883 Compare August 27, 2020 18:31
@neptunian neptunian added release_note:enhancement v7.10.0 v8.0.0 Team:Fleet Team label for Observability Data Collection Fleet team labels Aug 27, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/ingest-management (Team:Ingest Management)

@neptunian neptunian requested review from a team as code owners August 28, 2020 13:29
Copy link
Member

@nchaulet nchaulet left a comment

Choose a reason for hiding this comment

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

Tested and it work as expected

There is maybe just one think that we can improve (can be done in a follow up PR)
I think the config yaml flyout in the policy details should show the standalone config and not the full one, (it's here https://github.com/neptunian/kibana/blob/72731-allow-multiple-kibana-urls/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_policy/components/agent_policy_yaml_flyout.tsx/#L36)

Screen Shot 2020-08-31 at 4 02 14 PM

@@ -186,6 +196,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
type: 'elasticsearch',
},
},
fleet: {
Copy link
Contributor

Choose a reason for hiding this comment

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

These look fine to me. @paul-tavares do we need to make changes in the UI code that creates the policy?

Copy link
Contributor

Choose a reason for hiding this comment

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

@jonathan-buttner no, I don't think this impacts the Endpoint Integration Policy because its outside of the Integration input - that's the only one we manipulate in the Endpoint Policy Details page.

Copy link
Contributor

@jonathan-buttner jonathan-buttner left a comment

Choose a reason for hiding this comment

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

Security changes look good.

},
Settings
> = (settingsDoc) => {
settingsDoc.attributes.kibana_urls = [settingsDoc.attributes.kibana_url];
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible for the old settingsDoc to have undefined for settingsDoc.attributes.kibana_url? if so, we may need to wrap this line in a conditional so that we don't set [undefined] as a value for the new doc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's only possible for there to be no settings if they haven't started kibana. Settings along with the kibana_url gets created during setup and they cannot remove it through the settings api

GLOBAL_SETTINGS_SAVED_OBJECT_TYPE,
newData
);
const defaultSettings = createDefaultSettings();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nchaulet since during setup we create the Settings saved object with default attributes, I moved those into a function and they will be added when the saved object (if missing for some reason) is created here as well.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

@kbn/optimizer bundle module count

id value diff baseline
ingestManager 519 +1 518

async chunks size

id value diff baseline
ingestManager 1.1MB +750.0B 1.1MB

page load bundle size

id value diff baseline
ingestManager 468.0KB +567.0B 467.5KB

distributable file count

id value diff baseline
total 45448 +1 45447

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@neptunian neptunian merged commit a656b96 into elastic:master Sep 2, 2020
neptunian added a commit to neptunian/kibana that referenced this pull request Sep 2, 2020
* let the user specify multiple kibana urls

* add validation to kibana urls so paths and protocols cannot differ

* update i18n message

* only send the first url to the instructions

* udpate all agent configs' revision when settings is updated

* fix jest test

* update endpoint full agent policy test

* fix type

* dont add settings if standalone mode

* fix ui not handling errors from /{agentPolicyId}/full endpoint

* fix formatted message id

* only return needed fields

* fill in updated_by and updated_at attributes of the ingest-agent-policies when revision is bumped

* throw error if kibana_urls not set and update tests

* change ingest_manager_settings SO attribute kibana_url: string to kibana_urls: string[] and add migration

* leave instructions single kibana url

* make kibana_url and other attributes created during setup required, fix types
neptunian added a commit that referenced this pull request Sep 2, 2020
* let the user specify multiple kibana urls

* add validation to kibana urls so paths and protocols cannot differ

* update i18n message

* only send the first url to the instructions

* udpate all agent configs' revision when settings is updated

* fix jest test

* update endpoint full agent policy test

* fix type

* dont add settings if standalone mode

* fix ui not handling errors from /{agentPolicyId}/full endpoint

* fix formatted message id

* only return needed fields

* fill in updated_by and updated_at attributes of the ingest-agent-policies when revision is bumped

* throw error if kibana_urls not set and update tests

* change ingest_manager_settings SO attribute kibana_url: string to kibana_urls: string[] and add migration

* leave instructions single kibana url

* make kibana_url and other attributes created during setup required, fix types
@ghost
Copy link

ghost commented Sep 14, 2020

Hi @EricDavisX

We have validated the ticket by setting up 03 different 7.10.0-SNAPSHOT Kibana cloud environments.

Steps Followed:

  1. Login to Kibana Cloud environment with 'elastic' user.
  2. Click on the 'Settings' flyout.
  3. Add 03 kibana cloud urls in the 'Kibana URL' field and click on 'Save Settings' button.
  4. Click on Policies->Default policy->Actions->View policy.
  5. Click on Fleet->Online Host->Activity log

Observations:

  1. Kibana URL in the settings flyout is a EUI combo box that allows for multiple URLs.
  2. 03 Kibana urls are updated in policy under fleet->kibana->hosts section.
  3. 'CONFIG_CHANGE' action is displayed in agent activity logs after kibana urls are added in Settings.
  4. Enroll command in the 'Add Agent' flyout returns the first item in the list of kibana URLs on Settings flyout.

Moreover, we have created and executed 05 testcases under Support multiple kibana urls TestRun.

Queries:

  1. On saving kibana url with incorrect http protocol in 'Settings' flyout, no error message occurs and 'CONFIG_CHANGE' action is displayed in agent activity logs.
    Screenshot:
    image

As per #75712 description under Test section and our understanding, error message should be displayed for the same. Please share your feedback.

  1. (i) On executing the PUT /ingest_manager/settings ES query under Management->Dev Tools->Console, following error message is displayed.
    Screenshot:
    image

(ii) On executing the POST /ingest_manager/settings ES query under Management->Dev Tools->Console, following error message is displayed.
Screenshot:
image

However as per #75712 description under Test section, all agent policy saved objects revision should be updated on executing PUT ES query . Please share your feedback.

  1. Error is displayed on enrolling the agent with different kibana enroll command than kibana logged-in into.
    Steps Followed:
    (a) Login into Kibana cloud environment (say https://1c238ddda25743e297c3b47d3c5de1fc.us-central1.gcp.foundit.no:9243)
    (b) Click on Settings flyout and update the 'Kibana URL' field by adding https://e4eb0f3ad19f4043aecd7ab95d9294a8.us-central1.gcp.foundit.no:9243 and then https://1c238ddda25743e297c3b47d3c5de1fc.us-central1.gcp.foundit.no:9243 kibana url.
    (c) Click on Fleet->Add Agent flyout
    (d) Copy the following enroll command and enroll the agent.
    .\elastic-agent enroll https://e4eb0f3ad19f4043aecd7ab95d9294a8.us-central1.gcp.foundit.no:9243 RGE0Z2kzUUJ2U2xwNlVodEt5S1o6RzVpTUY5X1hRUHE0NUdoQlByeUpjQQ==
    .\install-service-elastic-agent.ps1

Screenshot:
image

Please share your feedback.

  1. Could you please let us know the business use-case, functionality impact from end-user point of view.
  2. On following the below steps, elastic-agent is enrolled only on the logged-in Kibana environment.
    Steps Followed:
    (i) RDP to the windows10 endpoint and download the 7.10.0-SNAPSHOT elastic-agent.
    (ii) Edit the elastic-agent.yml file to include 03 kibana cloud environments under fleet: section (as per #72731_comment)

.\elastic-agent enroll https://0f19b73ebc5c47ab846337ff293239bc.us-central1.gcp.foundit.no:443 UlowSWZIUUJrVTF5TDFqOEtsUVA6TGpQRHpaYlJSWnVITkh6Q01YRDZNdw==

.\install-service-elastic-agent.ps1

(vi) Enroll the agent on Windows10 using above command.

Observation:
(a) Agent is enrolled only on the Kibana cloud environment from which enroll command was copied(here first Kibana cloud environment).
(b) elastic-agent.yml file is modified and does not contain the above 03 kibana cloud environments.

Screenshot:
image

Please let us know if it is the expected behavior.

  1. 'xpack.ingestManager.fleet.kibana.host' field is not accepted in kibana.yml of cloud environment(#75712 description->Test section->point2). Please let us know if it is the expected behavior.

(a)Error is displayed on adding following string url setting in kibana.yml file on cloud environment:
xpack.ingestManager.fleet.kibana.host: "http://0f19b73ebc5c47ab846337ff293239bc.us-central1.gcp.foundit.no:9243/"

Screenshot:
adding_only_01_string

(b) Error is displayed on adding following string array of urls setting in kibana yml file on cloud environment:-
xpack.ingestManager.fleet.kibana.host: ["http://0f19b73ebc5c47ab846337ff293239bc.us-central1.gcp.foundit.no:9243", "http://5a3e547c36a3471fb9b0273088b89428.us-central1.gcp.foundit.no:1234/", "http://a687c886912145408f636ff9b92f28bc.us-central1.gcp.foundit.no:6789/"]

Screenshot:
array_string

(c) Error is displayed on adding suggested host.0 setting in kibana yml file on cloud environment::-
xpack.ingestManager.fleet.kibana.host.0: "http://0f19b73ebc5c47ab846337ff293239bc.us-central1.gcp.foundit.no:9243/"

Screenshot:
on adding host_zero

Please let us know if anything is missing from our end.

@EricDavisX
Copy link
Contributor

@rahulgupta-qasource I'm sending you a DM, lets talk testing in a new test ticket instead of this closed pr. Thanks for kicking this off!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:enhancement Team:Fleet Team label for Observability Data Collection Fleet team v7.10.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants