Created
April 4, 2022 10:52
-
-
Save j4zzcat/6905c3b5fa89c7fa1c25253adfee660a to your computer and use it in GitHub Desktop.
Installation script for New Relic infra agent and the Elasticsearch integration
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
# run this on ES master(s) and data nodes | |
# no need to install on the so call 'client' nodes | |
# assuming ubuntu 16.04 and up | |
# assuming that curl, gnupg2, sudo and systemctl are already installed and configured (default for ubuntu) | |
# config | |
NR_LICENSE_KEY="YOUR LICENSE KEY HERE" | |
ES_ENV="prod" | |
ES_NAME="my-es-cluster" | |
ES_USERNAME="" | |
ES_PASSWORD="" | |
ES_CLUSTER_NAME="es-${ES_NAME}-${ES_ENV}" | |
UBUNTU_CODE_NAME=$(lsb_release -sc) | |
DEBIAN_FRONTEND=noninteractive | |
# install the NR infra agent | |
echo "license_key: ${NR_LICENSE_KEY}" | sudo tee -a /etc/newrelic-infra.yml \ | |
&& curl -s https://download.newrelic.com/infrastructure_agent/gpg/newrelic-infra.gpg | sudo apt-key add - \ | |
&& printf "deb https://download.newrelic.com/infrastructure_agent/linux/apt ${UBUNTU_CODE_NAME} main" | sudo tee -a /etc/apt/sources.list.d/newrelic-infra.list \ | |
&& sudo apt-get update \ | |
&& sudo apt-get install newrelic-infra -y | |
# install and config es integration | |
sudo apt install -y nri-elasticsearch | |
sudo bash -c 'cat <<EOF >/etc/newrelic-infra/integrations.d/elasticsearch-config.yml | |
integrations: | |
- name: nri-elasticsearch | |
env: | |
CLUSTER_ENVIRONMENT: '${ES_CLUSTER_NAME}' | |
HOSTNAME: localhost | |
USERNAME: '${ES_USERNAME}' | |
PASSWORD: '${ES_PASSWORD}' | |
PORT: 9200 | |
TIMEOUT: 30 | |
USE_SSL: false | |
COLLECT_INDICES: true | |
COLLECT_PRIMARIES: true | |
inventory_source: config/elasticsearch | |
interval: 15 | |
labels: | |
env: '${ES_ENV}' | |
EOF' | |
# restart agent | |
sudo systemctl restart newrelic-infra |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment