Skip to content

Commit a6dbeb5

Browse files
Setup New Relic dashboards and alerts with terraform (#1109)
1 parent ee1b7ee commit a6dbeb5

File tree

8 files changed

+852
-2
lines changed

8 files changed

+852
-2
lines changed

bin/bootstrap.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ sed_i() {
7171
export -f sed_i
7272

7373
# Define the file types to search for
74-
file_types=("yml" "yaml" "erb" "rb" "json")
74+
file_types=("yml" "yaml" "erb" "rb" "json" "tf")
7575

7676
for file_type in "${file_types[@]}"
7777
do

config/newrelic.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

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

1616
# Your application name. Renaming here affects where data displays in New
1717
# Relic. For more details, see https://docs.newrelic.com/docs/apm/new-relic-apm/maintenance/renaming-applications

infra/new_relic/.env.sample

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
NEW_RELIC_ACCOUNT_ID=1234
2+
NEW_RELIC_API_KEY=NRAK-**
3+
NEW_RELIC_REGION=US

infra/new_relic/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.terraform
2+
.env
3+
terraform.tfstate*

infra/new_relic/.terraform.lock.hcl

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

infra/new_relic/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Preconditions
2+
3+
## Entities
4+
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.
5+
6+
## Slack
7+
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.
8+
9+
# Installation
10+
11+
Follow the [Terraform installation docs](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli) to install Terraform CLI.
12+
13+
## Environment variables
14+
Make sure you copy the `.env.sample` file into `.env` and fill all the variables.
15+
16+
## Usage
17+
18+
There are only three commands that need to be run in order to apply this terraform template and fully setup your New Relic monitoring.
19+
20+
```bash
21+
# Init
22+
terraform init
23+
24+
# Plan
25+
terraform plan
26+
27+
# Apply
28+
terraform apply
29+
```
30+
31+
# Docker usage
32+
33+
If you want to use Docker to avoid installing Terraform, we recommend to use one of the latest versions of the Dockerfile.
34+
35+
```bash
36+
# Init
37+
docker run -w /app -v .:/app --env-file .env -it hashicorp/terraform:latest init
38+
39+
# Plan
40+
docker run -w /app -v .:/app --env-file .env -it hashicorp/terraform:latest plan
41+
42+
# Apply
43+
docker run -w /app -v .:/app --env-file .env -it hashicorp/terraform:latest apply
44+
```

0 commit comments

Comments
 (0)