Skip to content

Commit

Permalink
Merge branch 'develop' into nb-alerts-fixing-urls
Browse files Browse the repository at this point in the history
  • Loading branch information
nbaenam authored Oct 14, 2024
2 parents ba4bb98 + 66769ac commit 7302cc2
Show file tree
Hide file tree
Showing 159 changed files with 3,047 additions and 3,587 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ For all methods except for our guided mode, the process for creating an alert co
>
You can use a NRQL query to define the signals you want an alert condition to use as the foundation for your alert. For this example, you will be using this query:

```
```sql
SELECT average(duration)
FROM PageView
WHERE appName = 'WebPortal'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,21 @@ The process for disabling or enabling a condition is the same general process fo

The following example shows how to disable a condition for an `apm_app_metric` condition. With the exception of the types of API calls required, the process is similar to the process for changing other condition types.

1. Obtain the <DNT>**policy_id**</DNT> of the policy you want to update. For an imaginary policy named `Logjam Alert`, the command would be:
1. Obtain the `policy_id` of the policy you want to update. For an imaginary policy named `Logjam Alert`, the command would be:

```
```shell
curl -X GET 'https://api.newrelic.com/v2/alerts_policies.json' \
-H "X-Api-Key:<a href='/docs/apis/rest-api-v2/getting-started/introduction-new-relic-rest-api-v2#api_key'>$API_KEY</a>" -i \
-G --data-urlencode 'filter[name]= Logjam Alert' <---<<< {policy_name}
-H "X-Api-Key:$API_KEY" -i \
-G --data-urlencode 'filter[name]= Logjam Alert' # policy_name
```

The output for this request might look like:

```
```json
{
"policies": [
{
"id": 85, <---<<< $POLICY_ID
"id": 85, // policy_id
"incident_preference": "PER_POLICY",
"name": "Logjam Alert",
"created_at": 1461176510393,
Expand All @@ -108,24 +108,24 @@ The following example shows how to disable a condition for an `apm_app_metric` c
]
}
```
2. List all of this policy's conditions and locate the `{condition_id}`:
2. List all of this policy's conditions and locate the `condition_id`:
```
```shell
curl -X GET 'https://api.newrelic.com/v2/alerts_conditions.json' \
-H "X-Api-Key:<a href='/docs/apis/rest-api-v2/getting-started/introduction-new-relic-rest-api-v2#api_key'>$API_KEY</a>" -i \
-H "X-Api-Key:$API_KEY" -i \
-G -d 'policy_id=85'
```
The output for this request might look like:
```
```json
{
"conditions": [
{
"id": 12345, <---<<< $CONDITION_ID
"id": 12345, // condition_id
"type": "apm_app_metric",
"name": "Apdex (Low)",
"enabled": true, <---<<< Note the condition is enabled
"enabled": true, // Note the condition is enabled
"entities": [
"8288171"
],
Expand All @@ -141,7 +141,7 @@ The following example shows how to disable a condition for an `apm_app_metric` c
]
},
{
"id": 2468, <---<<< another condition_id
"id": 2468, // another condition_id
"type": "apm_app_metric",
"name": "Throughput (Low)",
...
Expand All @@ -151,16 +151,16 @@ The following example shows how to disable a condition for an `apm_app_metric` c
```
3. Copy the JSON for only the condition in question and paste it in a text editor. Change `"enabled": true` to `"enabled": false`. The edited JSON would look like:
```
```shell lineHighlight=9
curl -X PUT 'https://api.newrelic.com/v2/alerts_conditions/12345.json' \
-H "X-Api-Key:<a href='/docs/apis/rest-api-v2/getting-started/introduction-new-relic-rest-api-v2#api_key'>$API_KEY</a>" -i \
-H "X-Api-Key:$API_KEY" -i \
-H 'Content-Type: application/json' \
-d \
'{
"condition": {
"type": "apm_app_metric",
"name": "Apdex (Low)",
"enabled": false, <---<<< Changed to false
"enabled": false,
"entities": [
"8288171"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,31 @@ The following example shows how to add a Ruby application named `TimberTime` in

Only the first step in this example is unique to choosing the Ruby app as the entity. The remaining steps will be the same for whichever entity you choose.

1. Get the `entity_id`; for example, `{application_id}`:
1. Get the `entity_id`; for example, `application_id`:

```bash
```shell

curl -X GET 'https://api.newrelic.com/v2/applications.json' \
-H "X-Api-Key:<a href='/docs/apis/rest-api-v2/getting-started/introduction-new-relic-rest-api-v2#api_key'>$API_KEY</a>" -i
-H $API_KEY -i
```

OR

If you know the application name, use this command and specify the `app_name`:

```bash
```shell
curl -X GET 'https://api.newrelic.com/v2/applications.json' \
-H "X-Api-Key:<a href='/docs/apis/rest-api-v2/getting-started/introduction-new-relic-rest-api-v2#api_key'>$API_KEY</a>" -i \
-H $API_KEY -i \
-d 'filter[name]=TimberTime'
```
2. Review the output to find the `{application_id}`, and use it as the `{entity_id}`:
2. Review the output to find the `application_id`, and use it as the `entity_id`:

```json
{
"applications": [
{
"id": 12345, <---<<< {application_id} == {entity_id}
"id": 12345, // application_id == entity_id
"name": "TimberTime",
"language": "ruby",
"health_status": "gray",
Expand All @@ -81,29 +83,33 @@ Only the first step in this example is unique to choosing the Ruby app as the en
```
3. Get the `policy_id` you want to update; for example, the `TimberTime` app's `Logjam Alert` policy. To get the `policy_id`, use this command:
```bash
```shell
curl -X GET 'https://api.newrelic.com/v2/alerts_policies.json' \
-H "X-Api-Key:<a href='/docs/apis/rest-api-v2/getting-started/introduction-new-relic-rest-api-v2#api_key'>$API_KEY</a>" -i \
-G -d 'filter[name]= Logjam Alert' <---<<< {policy_name}
-H $API_KEY -i \
-G -d 'filter[name]= Logjam Alert' # policy_name
```
4. Review the policy output; for example:
```json
{
"policies": [
{
"id": 85, <---<<< {policy_id}
"id": 85, // policy_id
"incident_preference": "PER_POLICY",
"name": "Logjam Alert",
"created_at": 1461176510393,
"updated_at": 1461176510393
},
```
5. List all of this policy's conditions and locate the `{condition_id}`:
5. List all of this policy's conditions and locate the `condition_id`:
```shell
```bash
curl -X GET 'https://api.newrelic.com/v2/alerts_conditions.json' \
-H "X-Api-Key:<a href='/docs/apis/rest-api-v2/getting-started/introduction-new-relic-rest-api-v2#api_key'>$API_KEY</a>" -i \
-H $API_KEY -i \
-G -d 'policy_id=85'
```
Expand All @@ -113,12 +119,12 @@ Only the first step in this example is unique to choosing the Ruby app as the en
{
"conditions": [
{
"id": 234567, <---<<< {condition_id}
"id": 234567, // condition_id
"type": "apm_app_metric",
"name": "Throughput (web) (High)",
"enabled": true,
"entities": [
"8288171" <---<<< Entity currently included in the policy
"8288171" // Entity currently included in the policy
],
"metric": "response_time_web",
"terms": [
Expand All @@ -136,19 +142,22 @@ Only the first step in this example is unique to choosing the Ruby app as the en
```
6. Use API requests to add entities to or remove entities from the policy's condition:
To add `{entity_id}` 12345 to `{condition_id}` 234567, with `{entity_type}` set as `application`:
To add `entity_id` 12345 to `condition_id` 234567, with `entity_type` set as `Application`:
```shell
```bash
curl -X PUT 'https://api.newrelic.com/v2/alerts_entity_conditions/12345.json' \
-H "X-Api-Key:<a href='/docs/apis/rest-api-v2/getting-started/introduction-new-relic-rest-api-v2#api_key'>$API_KEY</a>" -i \
-H $API_KEY -i \
-H 'Content-Type: application/json' \
-G -d 'entity_type=Application&condition_id=234567'
```
To remove `{entity_id}` 8288171 from `{condition_id}` 234567, with `{entity_type}` set as `application`:
To remove `entity_id` 8288171 from `condition_id` 234567, with `entity_type` set as `Application`:
```shell
```bash
curl -X DELETE 'https://api.newrelic.com/v2/alerts_entity_conditions/8288171.json' \
-H "X-Api-Key:<a href='/docs/apis/rest-api-v2/getting-started/introduction-new-relic-rest-api-v2#api_key'>$API_KEY</a>" -i \
-H $API_KEY -i \
-G -d 'entity_type=Application&condition_id=234567'
```
Loading

0 comments on commit 7302cc2

Please sign in to comment.