Skip to content

Instantly share code, notes, and snippets.

@FrankHassanabad
Created February 3, 2020 20:08
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save FrankHassanabad/e875ffe325ae0d33e760fc71e3c55c12 to your computer and use it in GitHub Desktop.
Test saved objects and duplicate issues part 1
#!/bin/sh
#
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
#
set -e
./check_env_variables.sh
# Uses a default of alert if no argument is specified
TYPE=${1:-alert}
# Example: ./find_saved_object.sh alert
# Example: ./find_saved_object.sh action
# Example: ./find_saved_object.sh action_task_params
# https://www.elastic.co/guide/en/kibana/master/saved-objects-api-find.html#saved-objects-api-find-request
rm -f /tmp/output_per_ten.txt
rm -f /tmp/output_per_one.txt
for i in {1..12}
do
curl -s -k \
-u ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD} \
-X GET "${KIBANA_URL}${SPACE_URL}/api/saved_objects/_find?per_page=10&type=alert&sort_field=createdAt&page=${i}" | jq . | jq ".saved_objects" | jq ".[].id" >> /tmp/output_per_ten.txt
done
for i in {1..112}
do
curl -s -k \
-u ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD} \
-X GET "${KIBANA_URL}${SPACE_URL}/api/saved_objects/_find?per_page=1&type=alert&sort_field=createdAt&page=${i}" | jq . | jq ".saved_objects" | jq ".[].id" >> /tmp/output_per_one.txt
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment