Skip to content

Commit

Permalink
chore: install new relic on the benchmark service (#258)
Browse files Browse the repository at this point in the history
Signed-off-by: samuelarogbonlo <[email protected]>
  • Loading branch information
samuelarogbonlo authored Sep 19, 2023
1 parent 6d8bcb6 commit 4a2d495
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deploy-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions terraform/benchmark/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions terraform/benchmark/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions terraform/benchmark/variable.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 3 additions & 0 deletions terraform/modules/benchmark/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
34 changes: 34 additions & 0 deletions terraform/modules/benchmark/service/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
include_matching_metrics:
process.name:
- regex "forest.*"
- regex "^fail2ban.*"
- regex "^rsyslog.*"
- regex "^syslog.*"
- regex "^gpg-agent.*"
metrics_network_sample_rate: -1
metrics_process_sample_rate: 600
metrics_system_sample_rate: 600
metrics_storage_sample_rate: 600
metrics_nfs_sample_rate: 600
container_cache_metadata_limit: 600
disable_zero_mem_process_filter: true
disable_all_plugins: true
disable_cloud_metadata: true
ignore_system_proxy: true
EOF

sudo systemctl restart newrelic-infra
fi
18 changes: 18 additions & 0 deletions terraform/modules/benchmark/variable.tf
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,21 @@ variable "project" {
type = string
default = "Forest-DEV" # Alternative: "Default"
}

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
}

variable "NEW_RELIC_REGION" {
description = "The New Relic Platform Region"
type = string
default = "EU"
}
2 changes: 1 addition & 1 deletion terraform/modules/daily_snapshot/variable.tf
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ variable "destination_addresses" {
}

variable "NEW_RELIC_REGION" {
description = "The New Relic Plathom Region"
description = "The New Relic Platform Region"
type = string
default = "EU"
}
Expand Down
2 changes: 1 addition & 1 deletion terraform/modules/filecoin_node/variable.tf
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ variable "NEW_RELIC_ACCOUNT_ID" {
}

variable "NEW_RELIC_REGION" {
description = "The New Relic Plathom Region"
description = "The New Relic Platform Region"
type = string
default = "EU"
}
Expand Down
2 changes: 1 addition & 1 deletion terraform/modules/sync_check/variable.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ variable "project" {
}

variable "NEW_RELIC_REGION" {
description = "The New Relic Plathom Region"
description = "The New Relic Platform Region"
type = string
default = "EU"
}
Expand Down

0 comments on commit 4a2d495

Please sign in to comment.