Last active
June 5, 2021 04:47
-
-
Save Ashishkanojia/54b9e07b14601ec4eb2592bf3e06c329 to your computer and use it in GitHub Desktop.
the script to enable the logging agent in any number of compute instances on GCP
This file contains hidden or 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
for name in $(gcloud compute instances list --format="value(name)") | |
do | |
temp_variable=$(gcloud compute instances list --format="value(name,zone)" | grep ${name}) | |
zone=$(echo $temp_variable | awk '{print $2}') | |
gcloud compute ssh ${name} --zone=${zone} --command="curl -sSO https://dl.google.com/cloudagents/add-logging-agent-repo.sh" | |
gcloud compute ssh ${name} --zone=${zone} --command="sudo bash add-logging-agent-repo.sh --also-install --version=1.*.*" | |
gcloud compute ssh ${name} --zone=${zone} --command="sudo service google-fluentd restart" | |
echo "logging agent installed for ${name}" | |
done | |
echo "logging agent activated successfully" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment