-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
293 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
ELK_VERSION=6.7.0 | ||
ELK_VERSION=7.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/expect -f | ||
|
||
# List of expected users with dummy password | ||
set user "(elastic|apm_system|kibana|logstash_system|beats_system|remote_monitoring_user)" | ||
set password "changeme" | ||
|
||
# Find elasticsearch container id | ||
set MODE [lindex $argv 0] | ||
if { [string match "swarm" $MODE] } { | ||
set cid [exec docker ps -q -f label=com.docker.swarm.service.name=elk_elasticsearch] | ||
} else { | ||
set cid [exec docker ps -q -f label=com.docker.compose.service=elasticsearch] | ||
} | ||
|
||
set cmd "docker exec -it $cid bin/elasticsearch-setup-passwords interactive -s -b" | ||
|
||
spawn {*}$cmd | ||
|
||
expect { | ||
-re "(E|Ree)nter password for \\\[$user\\\]: " { | ||
send "$password\r" | ||
exp_continue | ||
} | ||
eof | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu | ||
set -o pipefail | ||
|
||
shopt -s expand_aliases | ||
alias curl="docker run --rm --net=host buildpack-deps:artful-curl curl -s -w '\n'" | ||
|
||
function log { | ||
echo -e "\n[+] $1\n" | ||
} | ||
|
||
log 'Waiting for Elasticsearch readiness' | ||
curl -D- 'http://localhost:9200/' \ | ||
--retry 10 \ | ||
--retry-delay 5 \ | ||
--retry-connrefused \ | ||
-u elastic:changeme | ||
|
||
log 'Waiting for Kibana readiness' | ||
curl -D- 'http://localhost:5601/api/status' \ | ||
--retry 10 \ | ||
--retry-delay 5 \ | ||
--retry-connrefused \ | ||
-u kibana:changeme | ||
|
||
log 'Waiting for Logstash readiness' | ||
curl -D- 'http://localhost:9600/_node/pipelines/main?pretty' \ | ||
--retry 10 \ | ||
--retry-delay 5 \ | ||
--retry-connrefused | ||
|
||
log 'Creating Logstash index pattern in Kibana' | ||
source .env | ||
curl -X POST -D- 'http://localhost:5601/api/saved_objects/index-pattern' \ | ||
-H 'Content-Type: application/json' \ | ||
-H "kbn-version: ${ELK_VERSION}" \ | ||
-u kibana:changeme \ | ||
-d '{"attributes":{"title":"logstash-*","timeFieldName":"@timestamp"}}' | ||
|
||
log 'Searching index pattern via Kibana API' | ||
response="$(curl 'http://localhost:5601/api/saved_objects/_find?type=index-pattern' -u elastic:changeme)" | ||
echo $response | ||
count="$(jq -rn --argjson data "${response}" '$data.total')" | ||
if [[ $count -ne 1 ]]; then | ||
echo "Expected 1 index pattern, got ${count}" | ||
exit 1 | ||
fi | ||
|
||
log 'Sending message to Logstash TCP input' | ||
echo 'dockerelk' | nc localhost 5000 | ||
|
||
sleep 1 | ||
curl -X POST 'http://localhost:9200/_refresh' -u elastic:changeme | ||
|
||
log 'Searching message in Elasticsearch' | ||
response="$(curl 'http://localhost:9200/_count?q=message:dockerelk&pretty' -u elastic:changeme)" | ||
echo $response | ||
count="$(jq -rn --argjson data "${response}" '$data.count')" | ||
if [[ $count -ne 1 ]]; then | ||
echo "Expected 1 document, got ${count}" | ||
exit 1 | ||
fi |
Oops, something went wrong.