[Observability Onboarding] Various fixes for Quickstart Onboarding flows (#189134)

Resolves #188643
Resolves #188644
Resolves #188630

## Summary

Various fixes for Quickstart Onboarding flows

Co-authored-by: Joe Reuter <johannes.reuter@elastic.co>
This commit is contained in:
Thom Heymann 2024-07-26 15:14:38 +01:00 committed by GitHub
parent 19010a0747
commit 27bddf284f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 30 additions and 7 deletions

View file

@ -6,7 +6,19 @@ fail() {
}
if [ -z "${BASH_VERSION:-}" ]; then
fail "Bash is requred to run this script"
fail "Bash is required to run this script"
fi
if ! command -v curl >/dev/null 2>&1; then
fail "curl is required to run this script"
fi
# Check if the `lsof` command exists in PATH, if not use `/usr/sbin/lsof` if possible
LSOF_PATH=""
if command -v lsof >/dev/null 2>&1; then
LSOF_PATH=$(command -v lsof)
elif command -v /usr/sbin/lsof >/dev/null 2>&1; then
LSOF_PATH="/usr/sbin/lsof"
fi
install_api_key_encoded=""
@ -106,7 +118,7 @@ elif [ "${OS}" == "Darwin" ]; then
fi
elastic_agent_config_path=/Library/Elastic/Agent/elastic-agent.yml
else
fail "This script is only supported on linux and macOS"
fail "This script is only supported on Linux and macOS"
fi
elastic_agent_artifact_name="elastic-agent-${elastic_agent_version}-${os}-${arch}"
@ -293,9 +305,12 @@ read_open_log_file_list() {
"^\/var\/log\/system.log"
"^\/var\/log\/messages"
"^\/var\/log\/secure"
# Exclude previous installation logs
"\/opt\/Elastic\/Agent\/"
"\/Library\/Elastic\/Agent\/"
)
local list=$(lsof -Fn / | grep "^n.*\.log$" | cut -c2- | sort -u)
local list=$("$LSOF_PATH" -Fn / | grep "^n.*\.log$" | cut -c2- | sort -u)
# Filtering by the exclude patterns
while IFS= read -r line; do
@ -506,8 +521,15 @@ generate_custom_integration_name() {
printf "\e[1m%s\e[0m\n" "Looking for log files..."
update_step_progress "logs-detect" "loading"
detect_known_integrations
read_open_log_file_list
build_unknown_log_file_patterns
# Check if LSOF_PATH is executable
if [ -x "$LSOF_PATH" ]; then
read_open_log_file_list
build_unknown_log_file_patterns
else
echo -e "\nlsof is required to detect custom log files. Looking for known integrations only."
fi
update_step_progress "logs-detect" "complete"
echo -e "\nWe found these logs on your system:"
select_list

View file

@ -52,12 +52,13 @@ const createKubernetesOnboardingFlowRoute = createObservabilityOnboardingServerR
const fleetPluginStart = await plugins.fleet.start();
const packageClient = fleetPluginStart.packageService.asScoped(request);
await packageClient.ensureInstalledPackage({ pkgName: 'kubernetes' });
const [{ encoded: apiKeyEncoded }, elasticAgentVersion] = await Promise.all([
createShipperApiKey(client.asCurrentUser, 'kubernetes_onboarding'),
getAgentVersion(fleetPluginStart, kibanaVersion),
packageClient.ensureInstalledPackage({ pkgName: 'kubernetes' }),
packageClient.ensureInstalledPackage({ pkgName: 'system' }),
]);
const elasticsearchUrlList = plugins.cloud?.setup?.elasticsearchUrl
? [plugins.cloud?.setup?.elasticsearchUrl]
: await getFallbackESUrl(services.esLegacyConfigService);