From 4a2d495e5397ac1347f14db8d0cb48ed948d408b Mon Sep 17 00:00:00 2001 From: Samuel Arogbonlo <47984109+samuelarogbonlo@users.noreply.github.com> Date: Tue, 19 Sep 2023 09:21:28 +0100 Subject: [PATCH] chore: install new relic on the benchmark service (#258) Signed-off-by: samuelarogbonlo --- .github/workflows/deploy-benchmark.yml | 2 ++ terraform/benchmark/.terraform.lock.hcl | 3 ++ terraform/benchmark/main.tf | 2 ++ terraform/benchmark/variable.tf | 12 +++++++ terraform/modules/benchmark/main.tf | 3 ++ terraform/modules/benchmark/service/init.sh | 34 ++++++++++++++++++++ terraform/modules/benchmark/variable.tf | 18 +++++++++++ terraform/modules/daily_snapshot/variable.tf | 2 +- terraform/modules/filecoin_node/variable.tf | 2 +- terraform/modules/sync_check/variable.tf | 2 +- 10 files changed, 77 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy-benchmark.yml b/.github/workflows/deploy-benchmark.yml index 33082b43f..57ca13898 100644 --- a/.github/workflows/deploy-benchmark.yml +++ b/.github/workflows/deploy-benchmark.yml @@ -34,5 +34,7 @@ jobs: aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} slack_token: ${{ secrets.SLACK_TOKEN }} + new_relic_account_id: ${{ secrets.NEW_RELIC_ACCOUNT_ID }} + new_relic_api_key: ${{ secrets.NEW_RELIC_API_KEY }} working_directory: terraform/benchmark environment: Benchmark Service diff --git a/terraform/benchmark/.terraform.lock.hcl b/terraform/benchmark/.terraform.lock.hcl index e4f85802d..ae80807ad 100644 --- a/terraform/benchmark/.terraform.lock.hcl +++ b/terraform/benchmark/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/digitalocean/digitalocean" { version = "2.29.0" constraints = "~> 2.0" hashes = [ + "h1:KSmD5RdWr/Go4Q5GlY9QsfSm1vtKxBJjJe3M5gaQXjg=", "h1:OLSxMaqLOUl6DjQ3vz14odCyMCcLA63ltBNPgrIQHG4=", "zh:0af0a1a2de818c5dc8ee7ad4dc4731452848e84cfa0c1ce514af1c7aad15c53c", "zh:27229f3162b4142be48554f56227265982f3b74e4c79fa5d2528c8a3912d1e19", @@ -29,6 +30,7 @@ provider "registry.terraform.io/hashicorp/external" { version = "2.3.1" constraints = "~> 2.1" hashes = [ + "h1:9rJggijNdRdFk//ViQPGZdK0xu9XU/9qBDijNsZJMg0=", "h1:bROCw6g5D/3fFnWeJ01L4IrdnJl1ILU8DGDgXCtYzaY=", "zh:001e2886dc81fc98cf17cf34c0d53cb2dae1e869464792576e11b0f34ee92f54", "zh:2eeac58dd75b1abdf91945ac4284c9ccb2bfb17fa9bdb5f5d408148ff553b3ee", @@ -49,6 +51,7 @@ provider "registry.terraform.io/hashicorp/local" { version = "2.4.0" constraints = "~> 2.1" hashes = [ + "h1:Bs7LAkV/iQTLv72j+cTMrvx2U3KyXrcVHaGbdns1NcE=", "h1:R97FTYETo88sT2VHfMgkPU3lzCsZLunPftjSI5vfKe8=", "zh:53604cd29cb92538668fe09565c739358dc53ca56f9f11312b9d7de81e48fab9", "zh:66a46e9c508716a1c98efbf793092f03d50049fa4a83cd6b2251e9a06aca2acf", diff --git a/terraform/benchmark/main.tf b/terraform/benchmark/main.tf index e445d4ef2..94d9a68d7 100644 --- a/terraform/benchmark/main.tf +++ b/terraform/benchmark/main.tf @@ -39,6 +39,8 @@ module "benchmark" { AWS_ACCESS_KEY_ID = var.AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY = var.AWS_SECRET_ACCESS_KEY digitalocean_token = var.do_token + NEW_RELIC_API_KEY = var.NEW_RELIC_API_KEY + NEW_RELIC_ACCOUNT_ID = var.NEW_RELIC_ACCOUNT_ID } # This ip address may be used in the future by monitoring software diff --git a/terraform/benchmark/variable.tf b/terraform/benchmark/variable.tf index 7205d992d..c4872c2a9 100644 --- a/terraform/benchmark/variable.tf +++ b/terraform/benchmark/variable.tf @@ -17,3 +17,15 @@ variable "slack_token" { description = "slack access token" type = string } + +variable "NEW_RELIC_API_KEY" { + description = "New Relic API KEY" + default = "" + type = string +} + +variable "NEW_RELIC_ACCOUNT_ID" { + description = "New Relic Account ID" + default = "" + type = string +} diff --git a/terraform/modules/benchmark/main.tf b/terraform/modules/benchmark/main.tf index 182f05215..d5c510f5b 100644 --- a/terraform/modules/benchmark/main.tf +++ b/terraform/modules/benchmark/main.tf @@ -65,6 +65,9 @@ locals { "echo 'export SLACK_NOTIF_CHANNEL=\"${var.slack_channel}\"' >> .forest_env", "echo 'export BENCHMARK_BUCKET=\"${var.benchmark_bucket}\"' >> .forest_env", "echo 'export BENCHMARK_ENDPOINT=\"${var.benchmark_endpoint}\"' >> .forest_env", + "echo 'export NEW_RELIC_API_KEY=\"${var.NEW_RELIC_API_KEY}\"' >> .forest_env", + "echo 'export NEW_RELIC_ACCOUNT_ID=\"${var.NEW_RELIC_ACCOUNT_ID}\"' >> .forest_env", + "echo 'export NEW_RELIC_REGION=\"${var.NEW_RELIC_REGION}\"' >> .forest_env", "echo 'export BASE_FOLDER=\"/chainsafe\"' >> .forest_env", "echo '. ~/.forest_env' >> .bashrc", ". ~/.forest_env", diff --git a/terraform/modules/benchmark/service/init.sh b/terraform/modules/benchmark/service/init.sh index 9e0b4f461..4770d2cc7 100755 --- a/terraform/modules/benchmark/service/init.sh +++ b/terraform/modules/benchmark/service/init.sh @@ -18,3 +18,37 @@ sudo docker run --detach \ --restart unless-stopped \ benchmark \ /bin/bash -c "ruby run_benchmark.rb" + +# If New Relic license key and API key are provided, +# install the new relic agent and New relic agent and OpenMetrics Prometheus integration. +if [ -n "${NEW_RELIC_API_KEY}" ]; then + curl -Ls https://download.newrelic.com/install/newrelic-cli/scripts/install.sh | bash && \ + sudo NEW_RELIC_API_KEY="${NEW_RELIC_API_KEY}" \ + NEW_RELIC_ACCOUNT_ID="${NEW_RELIC_ACCOUNT_ID}" \ + NEW_RELIC_REGION="${NEW_RELIC_REGION}" \ + /usr/local/bin/newrelic install -y + +# The provided configurations are specific to New Relic. To gain a deeper understanding of these configuration details, you can visit: +# https://docs.newrelic.com/docs/infrastructure/install-infrastructure-agent/configuration/infrastructure-agent-configuration-settings/#offline-time-to-reset +cat >> /etc/newrelic-infra.yml <