Skip to content

Setup New Relic dashboards and alerts with terraform #1109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ sed_i() {
export -f sed_i

# Define the file types to search for
file_types=("yml" "yaml" "erb" "rb" "json")
file_types=("yml" "yaml" "erb" "rb" "json" "tf")

for file_type in "${file_types[@]}"
do
Expand Down
2 changes: 1 addition & 1 deletion config/newrelic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

common: &default_settings
# Required license key associated with your New Relic account.
license_key: <%= ENV['NEW_RELIC_API_KEY'] %>
license_key: <%= ENV['NEW_RELIC_LICENSE_KEY'] %>

# Your application name. Renaming here affects where data displays in New
# Relic. For more details, see https://docs.newrelic.com/docs/apm/new-relic-apm/maintenance/renaming-applications
Expand Down
5 changes: 5 additions & 0 deletions infra/new_relic/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
NEW_RELIC_ACCOUNT_ID=1234
NEW_RELIC_API_KEY=NRAK-**
NEW_RELIC_REGION=US

TF_VAR_account_id=1234
3 changes: 3 additions & 0 deletions infra/new_relic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.terraform
.env
terraform.tfstate*
27 changes: 27 additions & 0 deletions infra/new_relic/.terraform.lock.hcl

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

44 changes: 44 additions & 0 deletions infra/new_relic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Preconditions

## Entities
Create one New Relic entity for each environment. Current setup assumes one entity for "development", "staging" and "production" environments. For example, if your app name is "rails_api_base", it expects to have "rails_api_base - development" entity for dev.

## Slack
Set up the Slack integration from [New Relic](https://docs.newrelic.com/docs/alerts/get-notified/notification-integrations/). You will need to replace `slack_destination_id` local variable with the id generated by the integration, and `slack_channel_id` with the channel id where you want to send notifications.

# Installation

Follow the [Terraform installation docs](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli) to install Terraform CLI.

## Environment variables
Make sure you copy the `.env.sample` file into `.env` and fill all the variables.

## Usage

There are only three commands that need to be run in order to apply this terraform template and fully setup your New Relic monitoring.

```bash
# Init
terraform init

# Plan
terraform plan

# Apply
terraform apply
```

# Docker usage

If you want to use Docker to avoid installing Terraform, we recommend to use one of the latest versions of the Dockerfile.

```bash
# Init
docker run -w /app -v .:/app --env-file .env -it hashicorp/terraform:latest init

# Plan
docker run -w /app -v .:/app --env-file .env -it hashicorp/terraform:latest plan

# Apply
docker run -w /app -v .:/app --env-file .env -it hashicorp/terraform:latest apply
```
Loading