mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
# Backport This will backport the following commits from `main` to `8.10`: - [[Logs onboarding] Getting elastic-agent state in a more reliably way (#165205)](https://github.com/elastic/kibana/pull/165205) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Yngrid Coello","email":"yngrid.coello@elastic.co"},"sourceCommit":{"committedDate":"2023-08-31T08:46:41Z","message":"[Logs onboarding] Getting elastic-agent state in a more reliably way (#165205)\n\nCloses https://github.com/elastic/kibana/issues/163163.\r\n\r\nWe were getting `elastic-agent` status using `human`\r\n[output](https://www.elastic.co/guide/en/fleet/current/elastic-agent-cmd-options.html#_options_7),\r\nthis way of obtaining the state is very unreliable since human format\r\nit's more likeable to vary from one version to other. e.g\r\n\r\n- v8.0.0\r\n<img width=\"1021\" alt=\"image\"\r\nsrc=\"7c8102a4
-0785-4ab1-b690-ab62ec67644d\">\r\n\r\n- v8.9.0\r\n<img width=\"1026\" alt=\"image\"\r\nsrc=\"b6acdfbd
-6efa-4518-8855-0aba3662f07b\">\r\n\r\n### Changes\r\n- Get `elastic-agent` status from json output.\r\n\r\n#### Demo\r\n\r\n##### v8.0.0\r\n\r\n\r\n6c507269
-65d5-4c8a-9e9f-420698ca995d\r\n\r\n\r\n##### v8.9.0\r\n\r\n\r\nacdab744
-0bd7-43c8-9eb8-024e5a2eeae5","sha":"94bccbc6cd689acf79be97176a19ecfbb085c1ac","branchLabelMapping":{"^v8.11.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v8.10.0","v8.11.0"],"number":165205,"url":"https://github.com/elastic/kibana/pull/165205","mergeCommit":{"message":"[Logs onboarding] Getting elastic-agent state in a more reliably way (#165205)\n\nCloses https://github.com/elastic/kibana/issues/163163.\r\n\r\nWe were getting `elastic-agent` status using `human`\r\n[output](https://www.elastic.co/guide/en/fleet/current/elastic-agent-cmd-options.html#_options_7),\r\nthis way of obtaining the state is very unreliable since human format\r\nit's more likeable to vary from one version to other. e.g\r\n\r\n- v8.0.0\r\n<img width=\"1021\" alt=\"image\"\r\nsrc=\"7c8102a4
-0785-4ab1-b690-ab62ec67644d\">\r\n\r\n- v8.9.0\r\n<img width=\"1026\" alt=\"image\"\r\nsrc=\"b6acdfbd
-6efa-4518-8855-0aba3662f07b\">\r\n\r\n### Changes\r\n- Get `elastic-agent` status from json output.\r\n\r\n#### Demo\r\n\r\n##### v8.0.0\r\n\r\n\r\n6c507269
-65d5-4c8a-9e9f-420698ca995d\r\n\r\n\r\n##### v8.9.0\r\n\r\n\r\nacdab744
-0bd7-43c8-9eb8-024e5a2eeae5","sha":"94bccbc6cd689acf79be97176a19ecfbb085c1ac"}},"sourceBranch":"main","suggestedTargetBranches":["8.10"],"targetPullRequestStates":[{"branch":"8.10","label":"v8.10.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.11.0","labelRegex":"^v8.11.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/165205","number":165205,"mergeCommit":{"message":"[Logs onboarding] Getting elastic-agent state in a more reliably way (#165205)\n\nCloses https://github.com/elastic/kibana/issues/163163.\r\n\r\nWe were getting `elastic-agent` status using `human`\r\n[output](https://www.elastic.co/guide/en/fleet/current/elastic-agent-cmd-options.html#_options_7),\r\nthis way of obtaining the state is very unreliable since human format\r\nit's more likeable to vary from one version to other. e.g\r\n\r\n- v8.0.0\r\n<img width=\"1021\" alt=\"image\"\r\nsrc=\"7c8102a4
-0785-4ab1-b690-ab62ec67644d\">\r\n\r\n- v8.9.0\r\n<img width=\"1026\" alt=\"image\"\r\nsrc=\"b6acdfbd
-6efa-4518-8855-0aba3662f07b\">\r\n\r\n### Changes\r\n- Get `elastic-agent` status from json output.\r\n\r\n#### Demo\r\n\r\n##### v8.0.0\r\n\r\n\r\n6c507269
-65d5-4c8a-9e9f-420698ca995d\r\n\r\n\r\n##### v8.9.0\r\n\r\n\r\nacdab744
-0bd7-43c8-9eb8-024e5a2eeae5","sha":"94bccbc6cd689acf79be97176a19ecfbb085c1ac"}}]}] BACKPORT--> Co-authored-by: Yngrid Coello <yngrid.coello@elastic.co>
This commit is contained in:
parent
5c58049b41
commit
128d240ba8
1 changed files with 10 additions and 4 deletions
|
@ -124,14 +124,20 @@ waitForElasticAgentStatus
|
|||
if [ "$?" -ne 0 ]; then
|
||||
updateStepProgress "ea-status" "warning" "Unable to determine agent status"
|
||||
fi
|
||||
ELASTIC_AGENT_STATE="$(elastic-agent status | grep -m1 State | sed 's/State: //')"
|
||||
ELASTIC_AGENT_MESSAGE="$(elastic-agent status | grep -m1 Message | sed 's/Message: //')"
|
||||
if [ "${ELASTIC_AGENT_STATE}" = "HEALTHY" ] && [ "${ELASTIC_AGENT_MESSAGE}" = "Running" ]; then
|
||||
|
||||
# https://www.elastic.co/guide/en/fleet/current/elastic-agent-cmd-options.html#elastic-agent-status-command
|
||||
ELASTIC_AGENT_STATES=(STARTING CONFIGURING HEALTHY DEGRADED FAILED STOPPING UPGRADING ROLLBACK)
|
||||
|
||||
# Get elastic-agent status in json format | removing extra states in the json | finding "state":value | removing , | removing "state": | trimming the result
|
||||
ELASTIC_AGENT_STATE="$(elastic-agent status --output json | sed -n '/components/q;p' | grep state | sed 's/\(.*\),/\1 /' | sed 's/"state": //' | sed 's/\s//g')"
|
||||
# Get elastic-agent status in json format | removing extra states in the json | finding "message":value | removing , | removing "message": | trimming the result | removing ""
|
||||
ELASTIC_AGENT_MESSAGE="$(elastic-agent status --output json | sed -n '/components/q;p' | grep message | sed 's/\(.*\),/\1 /' | sed 's/"message": //' | sed 's/\s//g' | sed 's/\"//g')"
|
||||
if [ "${ELASTIC_AGENT_STATE}" = "2" ] && [ "${ELASTIC_AGENT_MESSAGE}" = "Running" ]; then
|
||||
echo "Elastic Agent running"
|
||||
echo "Download and save configuration to ${cfg}"
|
||||
updateStepProgress "ea-status" "complete"
|
||||
else
|
||||
updateStepProgress "ea-status" "warning" "Expected agent status HEALTHY / Running but got ${ELASTIC_AGENT_STATE} / ${ELASTIC_AGENT_MESSAGE}"
|
||||
updateStepProgress "ea-status" "warning" "Expected agent status HEALTHY / Running but got ${ELASTIC_AGENT_STATES[ELASTIC_AGENT_STATE]} / ${ELASTIC_AGENT_MESSAGE}"
|
||||
fi
|
||||
|
||||
downloadElasticAgentConfig() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue