Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to install and start logstash on ec2 instances #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions install-logstash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
#

echo "Starting logstash install ..."
sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
if [ -f ~/logstash.repo ];
then
echo "File logstash.repo exist."
sudo mv ~/logstash.repo /etc/yum.repos.d/
sudo chown root:root /etc/yum.repos.d/logstash.repo
sudo chmod 644 /etc/yum.repos.d/logstash.repo
else
echo "File logstash.repo does not exist"
echo "[logstash-6.x]" >> ~/logstash.repo
echo "name=Elastic repository for 6.x packages" >> ~/logstash.repo
echo "baseurl=https://artifacts.elastic.co/packages/6.x/yum" >> ~/logstash.repo
echo "gpgcheck=1" >> ~/logstash.repo
echo "gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch" >> ~/logstash.repo
echo "enabled=1" >> ~/logstash.repo
echo "autorefresh=1" >> ~/logstash.repo
echo "type=rpm-md" >> ~/logstash.repo

sudo mv ~/logstash.repo /etc/yum.repos.d/
sudo chown root:root /etc/yum.repos.d/logstash.repo
sudo chmod 644 /etc/yum.repos.d/logstash.repo
fi


sudo yum -y install logstash


if [ -f ~/logstash.conf ];
then
echo "File logstash.conf exist."a
sudo mv ~/logstash.conf /etc/logstash/conf.d/
sudo chown root:root /etc/logstash/conf.d/logstash.conf
sudo chmod 644 /etc/logstash/conf.d/logstash.conf
else
echo "File logstash.conf does not exist"

fi

sudo nohup /usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/logstash.conf &

ps -ef | grep logstash >> /tmp/logstash.ps

echo "Ended intall"
cat "Ended install" >> /tmp/logstash.logfile
56 changes: 56 additions & 0 deletions jmeter-ec2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -718,10 +718,66 @@ function runsetup() {
echo -n "done...."
fi

# scp install-logstash.sh
if [ -r $LOCAL_HOME/install-logstash.sh ] ; then
echo -n "logstash-install.sh.."
for host in ${hosts[@]} ; do
(scp -q -C -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
-i "$PEM_PATH/$PEM_FILE" -P $REMOTE_PORT \
$LOCAL_HOME/install-logstash.sh \
$USER@$host:$REMOTE_HOME) &
done
wait
echo -n "done...."
fi

# scp logstash.conf
if [ -r $LOCAL_HOME/logstash.conf ] ; then
echo -n "logstash.conf.."
for host in ${hosts[@]} ; do
(scp -q -C -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
-i "$PEM_PATH/$PEM_FILE" -P $REMOTE_PORT \
$LOCAL_HOME/logstash.conf \
$USER@$host:$REMOTE_HOME) &
done
wait
echo -n "done...."
fi



echo "all files uploaded"
echo
fi


# Install logstash
echo "starting install logstash:"
for host in ${hosts[@]} ; do
echo $host
done
for counter in ${!hosts[@]} ; do
( ssh -nq -o StrictHostKeyChecking=no \
-p $REMOTE_PORT \
-i "$PEM_PATH/$PEM_FILE" $USER@${hosts[$counter]} \
$REMOTE_HOME/install-logstash.sh &>/dev/null
)
done


# Run logstash
echo "starting running logstash:"
for host in ${hosts[@]} ; do
echo $host
done
for counter in ${!hosts[@]} ; do
( nohup ssh -nq -o StrictHostKeyChecking=no \
-p $REMOTE_PORT \
-i "$PEM_PATH/$PEM_FILE" $USER@${hosts[$counter]} \
$REMOTE_HOME/run-logstash.sh &>/dev/null &
)
done

# Start JMeter
echo "starting jmeter on:"
for host in ${hosts[@]} ; do
Expand Down
48 changes: 48 additions & 0 deletions logstash.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
input {
file { # point to jmeter result file created using simple csv writer
path => ["/home/ec2-user/data/resultfile.csv"]
start_position => "beginning"
}
}

filter {

if ([message] =~ "responseCode") {
drop { }
} else {
csv {
columns => ["timestamp", "elapsed", "label", "responseCode", "responseMessage", "threadName",
"dataType", "success", "failureMessage", "bytes", "grpThreads", "allThreads", "URL", "Latency",
"SampleCount", "ErrorCount", "Hostname"]
}
date {
match => [ "timestamp", "UNIX_MS" ]
}


mutate {
convert => [ "elapsed", "integer" ]
convert => [ "label", "string" ]
convert => [ "responseCode", "integer" ]
convert => [ "responseMessage", "string" ]
convert => [ "success", "boolean" ]
convert => [ "failureMessage", "string" ]
convert => [ "bytes", "integer" ]
convert => [ "URL", "string" ]
convert => [ "Latency", "integer" ]
convert => [ "SampleCount", "integer" ]
convert => [ "ErrorCount", "integer" ]
convert => [ "Hostname", "string" ]

remove_field => [ "threadName", "dataType", "grpThreads", "allThreads" ]
}
}
}
output {
#stdout { codec => rubydebug }
elasticsearch {
# point to Elastic search server configured to accept incoming traffic
hosts => ["111.22.33.44:9200"]
index => "jmeter-result-dash-%{+YYYY.MM.dd}"
}
}
2 changes: 2 additions & 0 deletions run-logstash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
nohup sudo /usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/logstash.conf > /dev/null 2>&1 &