Skip to content

Instantly share code, notes, and snippets.

@peasead
Last active June 6, 2023 22:23
Show Gist options
  • Save peasead/0667e516dc5066335c95c3aa71ba0313 to your computer and use it in GitHub Desktop.
Save peasead/0667e516dc5066335c95c3aa71ba0313 to your computer and use it in GitHub Desktop.
Updates Fleet-managed Elastic agents that are stuck in an "Updating" status.
# Shell script to update Elastic Agents that are stuck in an "Updating" state in Fleet.
# Example :
# KIBANA_URL="https://my-kibana-host:5601"
# PASSWORD="secret-password"
# ./update-agents.sh
KIBANA_URL="https://kibana-url:port"
PASSWORD="elastic-user-password"
AGENT_IDS=`
curl --request GET \
--url ${KIBANA_URL}/api/fleet/agents \
--user "elastic:${PASSWORD}" \
--header 'Content-Type: application/json' \
--header 'kbn-xsrf: as' \
| jq '.list | map(select(.status == "updating")) | map(.agent.id)'
`
curl --request POST \
--url ${KIBANA_URL}/api/fleet/agents/bulk_upgrade \
--user "elastic:${PASSWORD}" \
--header 'Content-Type: application/json' \
--header 'kbn-xsrf: as' \
--data '{"version": "8.8.0","force": true,"agents":"$AGENT_IDS"}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment