Skip to content

Instantly share code, notes, and snippets.

@doytsujin
Forked from Simonx123/metricsbeat.sh
Created March 23, 2022 12:18
Show Gist options
  • Save doytsujin/b1b0d90d35cf2c2ac07237b930e0b7a1 to your computer and use it in GitHub Desktop.
Save doytsujin/b1b0d90d35cf2c2ac07237b930e0b7a1 to your computer and use it in GitHub Desktop.
################### INSTALL METRICSBEAT ######################
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
echo 'deb https://artifacts.elastic.co/packages/oss-6.x/apt stable main' | sudo tee /etc/apt/sources.list.d/beats.list
sudo apt-get update && sudo apt-get install metricbeat
sudo metricbeat keystore create
echo "${elastic_pw}" | sudo bin/metricbeat-keystore add ES_PASSWORD
# echo "setup.dashboards.enabled: true" >> /etc/metricbeat/metricbeat.yml
cat <<EOT >> /etc/metricbeat/metricbeat.yml
output.elasticsearch:
hosts: ['https://${internal_lb_ip}:9200']
username: 'elastic'
password: '${ES_PASSWORD}'
protocol: 'http'
ssl:
certificate_authorities: ['/etc/kibana/elasticsearch-ca.pem']
verification_mode: 'none'
setup.kibana:
host: '0.0.0.0:8080'
username: 'elastic'
password: '${ES_PASSWORD}'
EOT
sudo systemctl enable metricbeat
sudo systemctl start metricbeat
cd /etc/metricbeat
sudo metricbeat modules enable elasticsearch-xpack
cat <<EOT >> /etc/metricbeat/modules.d/elasticsearch-xpack.yml
hosts: ['https://${internal_lb_ip}:9200']
username: 'elastic'
password: '${ES_PASSWORD}'
ssl:
certificate_authorities: ['/etc/kibana/elasticsearch-ca.pem']
verification_mode: 'none'
EOT
sudo systemctl restart kibana.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment