Skip to content

Commit

Permalink
fix : filebeat 설치 시 스크립트가 아닌 바로 설치
Browse files Browse the repository at this point in the history
  • Loading branch information
java-saeng committed Jul 24, 2023
1 parent ed4920c commit 155308f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions backend/.ebextensions/02-set-filebeat.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,24 @@
"mode": "000755",
"content": "#!/bin/bash\nPASSWORD=$(sudo /opt/elasticbeanstalk/bin/get-config environment -k ELASTICSEARCH_PASSWORD)\nHOST=$(sudo /opt/elasticbeanstalk/bin/get-config environment -k ELASTICSEARCH_HOST)\nPORT=$(sudo /opt/elasticbeanstalk/bin/get-config environment -k ELASTICSEARCH_PORT)\nUSER=$(sudo /opt/elasticbeanstalk/bin/get-config environment -k ELASTICSEARCH_USER)\ncat > /home/ec2-user/filebeat-7.14.1-linux-x86_64/filebeat.yml <<EOF\nfilebeat.inputs:\n- type: log\n enabled: true\n paths:\n - /var/app/current/logs/info/info.log\n - /var/app/current/logs/error/error.log\n - /var/app/current/logs/warn/*.log\n fields:\n log_type: legacy-log\n- type: log\n enabled: true\n paths:\n - /var/log/nginx/access.log\n fields:\n log_type: access-log\noutput.elasticsearch:\n hosts: [\"$HOST:$PORT\"]\n username: \"$USER\"\n password: \"$PASSWORD\"\n indices:\n - index: \"filebeat-%{[agent.version]}-access-log\"\n when.equals:\n fields.log_type: \"access-log\"\n - index: \"filebeat-%{[agent.version]}-legacy-log\"\n when.equals:\n fields.log_type: \"legacy-log\"\nEOF"
},
"/tmp/install_filebeat.sh": {
"mode": "000755",
"content": "#!/bin/bash\nFILEBEAT_DIRECTORY=\"/home/ec2-user/filebeat-7.14.1-linux-x86_64\"\nif [ ! -d \"$FILEBEAT_DIRECTORY\" ]; then\n wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.14.1-linux-x86_64.tar.gz\n tar xzvf filebeat-7.14.1-linux-x86_64.tar.gz\nelse\n echo \"Filebeat already installed.\"\nfi\n"
},
"/tmp/restart_filebeat.sh": {
"mode": "000755",
"content": "#!/bin/bash\n\nPID=$(ps -ef | grep ./filebeat | grep -v grep | awk '{print $2}')\n\nif [[ -n \"$PID\" ]]; then\n echo \"Filebeat PID : $PID\"\n sudo kill -9 $PID\nelse\n echo \"Filebeat is not running.\"\nfi\n\necho \"Restarting Filebeat\"\ncd filebeat-7.14.1-linux-x86_64 && sudo chmod 644 filebeat.yml && nohup ./filebeat -e > filebeat.log 2>&1 &\ndisown\necho \"Filebeat restarted\"\n"
}
},
"commands": {
"01_run_install_filebeat": {
"command": "bash /tmp/install_filebeat.sh"
"command": "curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.14.1-x86_64.rpm",
"cwd": "/home/ec2-user"
},
"02_run_rpm_filebeat": {
"command": "rpm -ivh —replacepkgs filebeat-7.14.1-x86_64.rpm",
"cwd": "/home/ec2-user"
},
"02_run_make_filebeat_yml_script": {
"03_run_make_filebeat_yml_script": {
"command": "bash /tmp/make_filebeat_yml.sh"
},
"03_run_filebeat": {
"04_run_filebeat": {
"command": "bash /tmp/restart_filebeat.sh"
}
}
Expand Down

0 comments on commit 155308f

Please sign in to comment.