logstash/ci/serverless/metricbeat_monitoring_tests.sh
kaisecheng 0f8695593e
buildkite serverless test (#15150)
This commit adds a Buildkite pipeline to test against serverless endpoint daily

Tests cover 
- es-output
- es-input
- es-filter
- central pipeline management
- legacy monitoring
- dlq
- integration-filter
- kibana API
- metricbeat stack monitoring

Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
Co-authored-by: João Duarte <jsvduarte@gmail.com>
2023-07-19 17:21:53 +01:00

73 lines
1.6 KiB
Bash
Executable file

#!/usr/bin/env bash
set -ex
source ./$(dirname "$0")/common.sh
get_cpu_arch() {
local arch=$(uname -m)
if [ "$arch" == "aarch64" ]; then
echo "arm64"
else
echo "$arch"
fi
}
export INDEX_NAME=".monitoring-logstash-8-mb"
export OS=$(uname -s | tr '[:upper:]' '[:lower:]')
export ARCH=$(get_cpu_arch)
export BEATS_VERSION=$(curl -s "https://api.github.com/repos/elastic/beats/tags" | jq -r '.[0].name' | cut -c 2-)
start_metricbeat() {
cd "$CURRENT_DIR"
MB_FILENAME="metricbeat-$BEATS_VERSION-$OS-$ARCH"
MB_DL_URL="https://artifacts.elastic.co/downloads/beats/metricbeat/$MB_FILENAME.tar.gz"
if [[ ! -d "$MB_FILENAME" ]]; then
curl -o "$MB_FILENAME.tar.gz" "$MB_DL_URL"
tar -zxf "$MB_FILENAME.tar.gz"
fi
chmod go-w "metricbeat/metricbeat.yml"
"$MB_FILENAME/metricbeat" -c "metricbeat/metricbeat.yml" &
export MB_PID=$!
cd -
}
stop_metricbeat() {
[[ -n "$MB_PID" ]] && kill "$MB_PID" || true
}
get_monitor_count() {
curl -s -u "$ES_USER:$ES_PW" "$ES_ENDPOINT/$INDEX_NAME/_count" | jq '.count'
}
compare_monitor_count() {
[[ $(get_monitor_count) -gt "$INITIAL_MONITOR_CNT" ]] && echo "0"
}
check_monitor_output() {
count_down_check 60 compare_monitor_count
}
check_plugin() {
add_check check_monitor_output "Failed metricbeat monitor check."
}
metricbeat_clean_up() {
exit_code=$?
ERR_MSGS+=("Unknown error!")
CHECKS+=("$exit_code")
stop_metricbeat
clean_up_and_get_result
}
setup
trap metricbeat_clean_up INT TERM EXIT
export INITIAL_MONITOR_CNT=$(get_monitor_count)
start_metricbeat
run_logstash "$CURRENT_DIR/pipeline/005_uptime.conf" check_plugin