Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into jerel/right-rail
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Jul 30, 2020
2 parents 38e304f + a0d490d commit 7beb48e
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 36 deletions.
38 changes: 23 additions & 15 deletions src/markdown-pages/automate-workflows/get-started-terraform.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,44 @@ path: '/automate-workflows/get-started-terraform'
duration: '20 min'
title: 'Set up New Relic using Terraform'
template: 'GuideTemplate'
description: "Learn how to provision New Relic resources using [Terraform](https://www.terraform.io/)."
description: 'Learn how to provision New Relic resources using [Terraform](https://www.terraform.io/).'
tileShorthand:
title: 'Set up New Relic using Terraform'
description: 'Learn how to provision New Relic resources using Terraform'
---

<Intro>

[Terraform](https://www.terraform.io/) is a popular infrastructure as code software tool by HashiCorp. You can use it to provision all kind of infrastructure and services, including New Relic entities.

In this guide you'll learn how to set up New Relic for the first time with [Terraform](https://www.terraform.io/). More specifically, you are going to provision an alert policy with notifications in your New Relic account using Terraform.

<Video id="vifxeilp2h" type="wistia"/>
<Video id="vifxeilp2h" type="wistia" />

</Intro>


## Before you begin

To use this guide, you should have some basic knowledge of both New Relic and Terraform.

* If you haven't deployed a New Relic agent yet, [install New Relic](https://docs.newrelic.com/docs/agents/manage-apm-agents/installation/install-agent) for your application.
* [Install Terraform CLI](https://www.terraform.io/intro/getting-started/install.html).
- If you haven't deployed a New Relic opensource agent yet, [install New Relic](https://docs.newrelic.com/docs/agents/manage-apm-agents/installation/install-agent) for your application.
- [Install Terraform CLI](https://www.terraform.io/intro/getting-started/install.html).

<Steps>
<Step>

## Bootstrap your provider configuration

New Relic's Terraform Provider detects the environment variables above when running Terraform commands.
New Relic's Terraform Provider detects the environment variables above when running Terraform commands.

You can set the environment variables in your `.bash_profile` or `.bashrc` file.

Set the following environment variables:

* Set your [New Relic Personal API key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#personal-api-key) with the `NEW_RELIC_API_KEY` environment variable. Most Personal API keys begin with the prefix `NRAK-`.
* Set your [New Relic Admin API key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#admin) with the `NEW_RELIC_ADMIN_API_KEY` environment variable. Most Admin API keys begin with the prefix `NRAA-`.
* Set your [New Relic Account ID](https://docs.newrelic.com/docs/accounts/install-new-relic/account-setup/account-id) with the `NEW_RELIC_ACCOUNT_ID` environment variable.
* Set your New Relic [region](https://docs.newrelic.com/docs/using-new-relic/welcome-new-relic/get-started/our-eu-us-region-data-centers#verifying-account) with the `NEW_RELIC_REGION` environment variable. Your region is `US` if your account settings page is located at `rpm.newrelic.com`, and `EU` if your account is located at `rpm.eu.newrelic.com`.
- Set your [New Relic Personal API key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#personal-api-key) with the `NEW_RELIC_API_KEY` environment variable. Most Personal API keys begin with the prefix `NRAK-`.
- Set your [New Relic Admin API key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#admin) with the `NEW_RELIC_ADMIN_API_KEY` environment variable. Most Admin API keys begin with the prefix `NRAA-`.
- Set your [New Relic Account ID](https://docs.newrelic.com/docs/accounts/install-new-relic/account-setup/account-id) with the `NEW_RELIC_ACCOUNT_ID` environment variable.
- Set your New Relic [region](https://docs.newrelic.com/docs/using-new-relic/welcome-new-relic/get-started/our-eu-us-region-data-centers#verifying-account) with the `NEW_RELIC_REGION` environment variable. Your region is `US` if your account settings page is located at `rpm.newrelic.com`, and `EU` if your account is located at `rpm.eu.newrelic.com`.

```bash lineNumbers=false
# Add this to your .bash_profile
Expand All @@ -51,6 +51,7 @@ export NEW_RELIC_REGION=US
# Or set it inline when running `terraform plan` or `terraform apply`:
$ NEW_RELIC_API_KEY=NRAK-... terraform apply
```

</Step>
<Step>

Expand Down Expand Up @@ -85,11 +86,12 @@ $ terraform init
$ terraform plan
```

`plan` performs a [dry run](https://en.wikipedia.org/wiki/Dry_run_(testing)) of your Terraform configuration, so nothing is actually provisioned. Always run `plan` to test your configuration before applying it.
`plan` performs a [dry run](<https://en.wikipedia.org/wiki/Dry_run_(testing)>) of your Terraform configuration, so nothing is actually provisioned. Always run `plan` to test your configuration before applying it.

</Step>
<Step>

## Add a data source
## Add a data source

The alert policy you defined in `main.tf` does not contain any alert condition. You are going to add an alert condition linked to your application.

Expand All @@ -109,6 +111,7 @@ resource "newrelic_alert_policy" "alert_policy_name" {
name = "My Alert Policy Name"
}
```

</Step>
<Step>

Expand Down Expand Up @@ -149,12 +152,13 @@ resource "newrelic_alert_condition" "alert_condition_name" {
}
}
```

</Step>
<Step>

## Add a notification channel

Alert policies use [notification channels](https://docs.newrelic.com/docs/alerts/new-relic-alerts/managing-notification-channels/notification-channels-control-where-send-alerts) to inform you about incidents and active alerts. To add a notification channel to your alert policy, add the following snippet to your configuration file.
Alert policies use [notification channels](https://docs.newrelic.com/docs/alerts/new-relic-alerts/managing-notification-channels/notification-channels-control-where-send-alerts) to inform you about incidents and active alerts. To add a notification channel to your alert policy, add the following snippet to your configuration file.

When the alert condition is triggered, the notification channel sends an email to the specified `recipients`. You can send notifications using different tools and channels, such as Slack, by changing the `type` of your [alert channel](https://www.terraform.io/docs/providers/newrelic/r/alert_channel.html).

Expand Down Expand Up @@ -191,6 +195,7 @@ To [apply](https://www.terraform.io/docs/commands/apply.html) the Terraform conf
Answer `yes` when prompted to apply the changes. Once the `apply` process is complete, you should see the new alert policy you've provisioned using Terraform, and its alert conditions, in your New Relic account.

You can run `terraform apply` every time you need to make changes to your configuration. To eliminate the resources you've provisioned, run [`terraform destroy`](https://www.terraform.io/docs/commands/destroy.html).

</Step>

<Step>
Expand All @@ -207,7 +212,7 @@ To use our `apm` module with Terraform:

Here is a configuration example with overridden default values. Initialize the working directory using `terraform init`to download and enable the module.

<Tip>
<Tip>

The `apm` module doesn't create a notification channel, so you would still have to define one.

Expand Down Expand Up @@ -260,6 +265,7 @@ resource "newrelic_alert_channel" "slack" {
}
}
```

<br />

Running `terraform plan` yields the following:
Expand All @@ -273,6 +279,7 @@ Running `terraform plan` yields the following:
name: "slack" => "slack"
type: "slack" => "slack"
```

<br />

To prevent Terraform from wrongly marking a resource as changed, add an [`ignore_changes`](https://www.terraform.io/docs/configuration/resources.html#ignore_changes) directive:
Expand All @@ -286,6 +293,7 @@ resource "newrelic_alert_channel" "slack" {
}
...
```

<br />

This avoids changes to resources caused by obfuscated items.
Expand All @@ -294,4 +302,4 @@ This avoids changes to resources caused by obfuscated items.

- [Terraform New Relic Provider](https://www.terraform.io/docs/providers/newrelic/index.html)
- [New Relic documentation](https://docs.newrelic.com)
- [Terraform documentation](https://www.terraform.io/docs/index.html)
- [Terraform documentation](https://www.terraform.io/docs/index.html)
14 changes: 3 additions & 11 deletions src/markdown-pages/collect-data/add-custom-attributes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,27 @@ redirects:

<Intro>

Custom attributes are fields that you define that will added to the standard events that New Relic collects, e.g. Transaction, TransactionError. By adding custom attributes to your data, you can see beyond your code and analyze your business in-depth. Custom attributes are a great way to filter and facet on your data, giving you greater insight into how your code affects your business.
There are countless filters and pivots you might want to apply to your data. By adding custom attributes to your data, you can see beyond your code and analyze your business in-depth.

</Intro>



A common pattern when using custom attributes is to capture user information, e.g. name, id, email, etc. This allows you to 'link' your operational data with your business data. For example, if you have the user information, you tie together your service desk and CRM data with the operational data in New Relic.

<Steps>

<Step>

You can add a `userid` custom attribute to your APM-reported data (`Transaction` and `TransactionError events`) with the Java APM agent's API.
You can add a `userid` custom attribute to your APM-reported data (`Transaction` and `TransactionError events`) with the opensource Java APM agent's API.

```
NewRelic.addCustomParameter("userid", userId);
```

</Step>



<Step>

Once added, you can run a NRQL query that uses the 'userid' custom attribute.
Once added, you can run a NRQL query that uses the 'userid' custom attribute.

Once you have added a custom attribute like 'userid', you can use it to filter and facet your NRQL queries.

Expand All @@ -47,14 +43,10 @@ Once you have added a custom attribute like 'userid', you can use it to filter a
SELECT count(*) FROM TransactionError WHERE userid = '1401961100' FACET dateOf(timestamp), `error.message` SINCE 1 week ago
```



</Step>

</Steps>



### Related Info

For more information, see [New Relic APM: Report custom attributes](https://docs.newrelic.com/docs/insights/insights-data-sources/custom-data/add-custom-attributes-new-relic-apm-data)
Expand Down
3 changes: 1 addition & 2 deletions src/markdown-pages/collect-data/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ description: ''

<Intro>

Through our agents or APIs, New Relic makes it easy to collect data from any source. The guides in this section provide strategies for collecting and querying data for use in your existing New Relic implementation, or in apps you build. The opportunities are endless.

Through our opensource agents or APIs, New Relic makes it easy to collect data from any source. The guides in this section provide strategies for collecting and querying data for use in your existing New Relic implementation, or in apps you build. The opportunities are endless.

<Video id="nyt3r6h9vq" type="wistia" />

Expand Down
4 changes: 2 additions & 2 deletions src/markdown-pages/collect-data/query-data-nrql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tileShorthand:
title: 'Query data with NRQL'
description: 'Query default event data, custom events, and attributes'
redirects:
- /technology/nrql
- /technology/nrql
---

<Intro>
Expand Down Expand Up @@ -44,7 +44,7 @@ SELECT function(attribute) [AS 'label'][, ...]

NRQL queries can be as simple as fetching rows of data in a raw tabular form to inspect individual events.

[Learn what events New Relic agents provide out of the box](https://docs.newrelic.com/docs/insights/insights-data-sources/default-data/insights-default-data-other-new-relic-products)
[Learn what events New Relic opensource agents provide out of the box](https://docs.newrelic.com/docs/insights/insights-data-sources/default-data/insights-default-data-other-new-relic-products)

```sql
-- Fetch a list of New Relic Browser PageView events
Expand Down
13 changes: 7 additions & 6 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ const IndexPage = ({ data, pageContext }) => {
start building right now. For free.
</p>
<p>
With our platform as your foundation, create custom
observability apps fast. Answer your unique questions, improve
your software, and deliver new value to your business.
Create an account and start using New Relic One as your
foundation to instrument everything. Ready to dive even deeper?
Create custom observability apps to better visualize your data
to answer your engineering problems.
</p>
<p>We're glad you are here. Let's start building.</p>
<p>Let's start building.</p>
</div>
<Video
className={styles.introVideo}
Expand All @@ -95,9 +96,9 @@ const IndexPage = ({ data, pageContext }) => {
<Button
as={ExternalLink}
variant={Button.VARIANT.PRIMARY}
href="https://newrelic.com/signup?partner=Developer+Edition"
href="https://newrelic.com/signup?utm_source=developer-site"
>
Create an account
Create a free account
</Button>
</header>
<GuideListing.List>
Expand Down

0 comments on commit 7beb48e

Please sign in to comment.