Skip to content

Commit

Permalink
Merge branch 'develop' into NR-343902-ccus-for-alert-conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
adutta-newrelic committed Jan 23, 2025
2 parents 26cd107 + 75c59ba commit 474ffc7
Show file tree
Hide file tree
Showing 509 changed files with 2,992 additions and 4,258 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,26 @@ When you [create or edit a query key](#register), you will see an example `curl`

* The [NRQL query string](/docs/insights/nrql-new-relic-query-language/using-nrql/introduction-nrql) must be [URL-encoded](http://www.w3schools.com/tags/ref_urlencode.asp).
* The query string must be less than 4000 bytes.
* The URL must contain a valid account ID.
* The URL must contain a valid [account ID](/docs/accounts-partnerships/accounts/account-setup/account-id).
* The `X-Query-Key` must contain a valid [query key](#register).
* The `Content-Type` must be `application/json`.

### Linux [#unix]

Here is a `curl` example:

```
curl -H "Accept: application/json" -H "X-Query-Key: YOUR_QUERY_KEY" "https://insights-api.newrelic.com/v1/accounts/<a href="/docs/accounts-partnerships/accounts/account-setup/account-id">YOUR_ACCOUNT_ID</a>/query?nrql=YOUR_URL_ENCODED_QUERY"
```sh
curl -H "Accept: application/json" \
-H "X-Query-Key: YOUR_QUERY_KEY" \
"https://insights-api.newrelic.com/v1/accounts/YOUR_ACCOUNT_ID/query?nrql=YOUR_URL_ENCODED_QUERY"
```

### Microsoft Windows [#windows]

You can use <DNT>**Powershell**</DNT> to query events via API:

```
Invoke-WebRequest -Uri https://insights-api.newrelic.com/v1/accounts/<a href="/docs/accounts-partnerships/accounts/account-setup/account-id">YOUR_ACCOUNT_ID</a>/query?nrql=YOUR_URL_ENCODED_QUERY -Headers @{"X-Query-Key"="YOUR_QUERY_KEY"} -ContentType "application/json" -Method GET
```powershell
Invoke-WebRequest -Uri https://insights-api.newrelic.com/v1/accounts/YOUR_ACCOUNT_ID/query?nrql=YOUR_URL_ENCODED_QUERY -Headers @{"X-Query-Key"="YOUR_QUERY_KEY"} -ContentType "application/json" -Method GET
```

## 3. Process the returned JSON [#process-result]
Expand All @@ -103,31 +105,31 @@ The Insights query API returns JSON data. Here's an example of a query, its quer
**Original NRQL query:**
</DNT>

```
```sql
SELECT count(appName) FROM PageView SINCE '2014-08-04 00:00:00+0500'
```

<DNT>**Query cURL request (with URL-encoded NRQL query)**</DNT>:

```
curl -H "Accept: application/json" -H "X-Query-Key: YOUR_QUERY_KEY" "https://insights-api.newrelic.com/v1/accounts/YOUR_ACCOUNT_ID/query?nrql=SELECT+count%28appName%29+FROM+PageView+SINCE+%272014-08-04+00%3A00%3A00%2B0500%27"
```sh
curl -H "Accept: application/json" \
-H "X-Query-Key: YOUR_QUERY_KEY" \
"https://insights-api.newrelic.com/v1/accounts/YOUR_ACCOUNT_ID/query?nrql=SELECT+count%28appName%29+FROM+PageView+SINCE+%272014-08-04+00%3A00%3A00%2B0500%27"
```

<DNT>
**Returned JSON data:**
</DNT>

```
```json
{
"results": [
{
"count": 80275388
}
],
"metadata": {
"eventTypes": [
"PageView"
],
"eventTypes": ["PageView"],
"eventType": "PageView",
"openEnded": true,
"beginTime": "2014-08-03T19:00:00Z",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Available parsing rule fields include:
<tbody>
<tr>
<td>
id
`id`
</td>

<td>
Expand All @@ -41,7 +41,7 @@ Available parsing rule fields include:

<tr>
<td>
parsingRules
`parsingRules`
</td>

<td>
Expand All @@ -51,7 +51,7 @@ Available parsing rule fields include:

<tr>
<td>
description
`description`
</td>

<td>
Expand All @@ -61,7 +61,7 @@ Available parsing rule fields include:

<tr>
<td>
grok
`grok`
</td>

<td>
Expand All @@ -71,7 +71,7 @@ Available parsing rule fields include:

<tr>
<td>
lucene
`lucene`
</td>

<td>
Expand All @@ -81,7 +81,7 @@ Available parsing rule fields include:

<tr>
<td>
accountId
`accountId`
</td>

<td>
Expand All @@ -91,21 +91,17 @@ Available parsing rule fields include:

<tr>
<td>
nrql
`nrql`
</td>

<td>
The NRQL query used for queries, if applicable; for example:

```
"SELECT * FROM Log WHERE `logtype` = 'testLogs'"
```
The NRQL query string used for queries, if applicable; for example: `"SELECT * FROM Log WHERE `logtype` = 'testLogs'"`
</td>
</tr>

<tr>
<td>
createdBy
`createdBy`
</td>

<td>
Expand All @@ -115,7 +111,7 @@ Available parsing rule fields include:

<tr>
<td>
updatedBy
`updatedBy`
</td>

<td>
Expand All @@ -125,7 +121,7 @@ Available parsing rule fields include:

<tr>
<td>
enabled
`enabled`
</td>

<td>
Expand All @@ -135,7 +131,7 @@ Available parsing rule fields include:

<tr>
<td>
deleted
`deleted`
</td>

<td>
Expand All @@ -152,7 +148,7 @@ This NerdGraph API request example gets all of the parsing rules for a given acc
```graphql
query{
actor {
account(id: 12345678) {
account(id: YOUR_ACCOUNT_ID) {
logConfigurations {
parsingRules {
accountId
Expand Down Expand Up @@ -185,7 +181,7 @@ query{

The response returned will look similar to this:

```graphql
```json
{
"data": {
"actor": {
Expand Down Expand Up @@ -225,7 +221,16 @@ This example creates a new log parsing rule. Before creating the rule, be sure t

```graphql
mutation {
logConfigurationsCreateParsingRule(accountId: 12345678, rule: {description: "example parsing rule", enabled: false, grok: "sampleattribute=%{NUMBER:test:int}", lucene: "logtype:testLogs", nrql: "SELECT * FROM Log WHERE `logtype` = 'testLogs'"}) {
logConfigurationsCreateParsingRule(
accountId: YOUR_ACCOUNT_ID
rule: {
description: "example parsing rule"
enabled: false
grok: "sampleattribute=%{NUMBER:test:int}"
lucene: "logtype:testLogs"
nrql: "SELECT * FROM Log WHERE `logtype` = 'testLogs'"
}
) {
rule {
id
enabled
Expand All @@ -246,7 +251,17 @@ This example updates the parsing rule whose `id` is `"123"`. You can update any

```graphql
mutation {
logConfigurationsUpdateParsingRule(accountId: 12345678, rule: {description: "example parsing rule", enabled: false, grok: "sampleattribute=%{NUMBER:test:int}", lucene: "logtype:testLogs", nrql: "SELECT * FROM Log WHERE `logtype` = 'testLogs'"}, id: "123") {
logConfigurationsUpdateParsingRule(
accountId: YOUR_ACCOUNT_ID
rule: {
description: "example parsing rule"
enabled: false
grok: "sampleattribute=%{NUMBER:test:int}"
lucene: "logtype:testLogs"
nrql: "SELECT * FROM Log WHERE `logtype` = 'testLogs'"
}
id: "123"
) {
errors {
message
type
Expand All @@ -267,7 +282,7 @@ Deleting a parsing rule doesn't delete data that has already been parsed. The da

```graphql
mutation {
logConfigurationsDeleteParsingRule(accountId: 123456789, id: "123") {
logConfigurationsDeleteParsingRule(accountId: YOUR_ACCOUNT_ID, id: "123") {
errors {
message
type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ This generates a list of users on our [original user model](/docs/accounts/origi

To obtain a list of all users on the [original user model](/docs/accounts/original-accounts-billing/original-product-based-pricing/overview-user-models) for your account, use this command:

```
```sh
curl -X GET 'https://api.newrelic.com/v2/users.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
```

The output will appear similar to this:

```
```json
HTTP/1.1 200 OK
Content-Type: application/json

Expand Down Expand Up @@ -70,9 +70,9 @@ If you know all or part of the user's email, you can use this command to return

<DNT>**Note:**</DNT> Character matching is a simple string. No regular expression capability is available, so multiple matches may occur if the selected string is not unique.

```
```sh
curl -X GET 'https://api.newrelic.com/v2/users.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 \
-d 'filter[email]=my.name'
```

Expand All @@ -82,17 +82,17 @@ The output for this command will be the same as the first entry in the [Listing

If you know the user `id`, you can use this command to return the role, name, and email. The `filter[ids]=` clause specifies the user `id`.

```
```sh
curl -X GET 'https://api.newrelic.com/v2/users.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 \
-d 'filter[ids]=123456'
```

You can also use this command, which embeds the user `id` in the URL and omits the filter.

```
```sh
curl -X GET 'https://api.newrelic.com/v2/users/123456.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
```

The output for this command will be the same as the first entry in the [Listing all account users](#list_all_users) example.
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,19 @@ Here are the HTTP headers that will appear in API responses if there is a genera

Here is an example API request indicating that the caller has consumed all of the available resources, and that further API calls will be allowed again at noon on Feb. 1, 2016:

```
```sh
curl -X GET 'https://api.newrelic.com/v2/applications.json' \
-H "Api-Key:<a href='/docs/apis/rest-api-v2/getting-started/introduction-new-relic-rest-api-v2#api_key'>$API_KEY</a>" -i
HTTP/1.1 429 Too Many Requests
Content-Type: application/json
...
X-RateLimit-Docs: https://docs.newrelic.com/docs/apis/rest-api-v2/requirements/api-overload-protection-preventing-429-errors
X-RateLimit-Reset: 1454313600
X-RateLimit-Remaining: 0
X-RateLimit-Limit: 1000
{}
-H "Api-Key:$API_KEY" -i
[output]
[output] HTTP/1.1 429 Too Many Requests
[output] Content-Type: application/json
[output] ...
[output] X-RateLimit-Docs: https://docs.newrelic.com/docs/apis/rest-api-v2/requirements/api-overload-protection-preventing-429-errors
[output] X-RateLimit-Reset: 1454313600
[output] X-RateLimit-Remaining: 0
[output] X-RateLimit-Limit: 1000
[output]
[output] {}
```

## Preventing rate limiting errors [#preventing-errors]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ freshnessValidatedDate: never

By default, New Relic REST API calls return a series of metric data values based on [time range restrictions](/docs/apm/apis/requirements/extracting-metric-data#time). To obtain the average of these values, include `&summarize=true` in your API call. For example:

```
```sh
curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics/data.json" \
-H "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:$API_KEY" -i \
-d 'names[]=Agent/MetricsReported/count&from=2014-08-11T14:42:00%2B08:00&to=2014-08-11T15:12:00%2B08:00&summarize=true'
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ Here is a summary of the metric value retrieval for the time ranges available.
</td>

<td rowSpan={5}>
10 evenly spaced
data points
10 evenly spaced data points
</td>
</tr>

Expand Down Expand Up @@ -259,9 +258,9 @@ Sometimes the output data's granularity may be too fine, or the time period for

<DNT>**Example #1:**</DNT> Following New Relic's [table summarizing granularity of collected data](#data-aggregation), the following API call would normally return data in 30-minute periods, since the request is for 4 days (`from=2018-02-13` and `to=2018-02-17`). By adding `period=3600`, the data will be returned as 60-minute periods.

```
```sh
curl -X GET "https://api.newrelic.com/v2/applications/$APP_ID/metrics/data.xml" \
-H "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:$API_KEY" -i \
-d'names[]=CPU/User+Time&from=2018-02-13T04:00:00+00:00&to=2018-02-17T04:00:00+00:00&period=3600'
```

Expand Down Expand Up @@ -339,7 +338,7 @@ A successful response will include a `200` status code and metadata about the re

Here is an example of output for a valid metric name, `HttpDispatcher`.

```
```json
HTTP/1.1 200 OK
etag: "0dc87c63d8dff6b1a9714bdf7531ec09"
Content-Type: application/json
Expand Down Expand Up @@ -376,7 +375,7 @@ cache-control: max-age=0, private, must-revalidate

Here is an example of output for a invalid metric name, `Foo`.

```
```json
HTTP/1.1 200 OK
etag: "e51782cf7c5a5596139a7f5340c3de23"
Content-Type: application/json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ The data returned per page depends on what data is requested. The number of page

To specify a page, add the `page=` parameter to the query. Here's an example:

```
```sh
curl -X GET 'https://api.newrelic.com/v2/alerts_incidents.json?page=3' \
-H "Api-Key:<a href='/docs/apis/get-started/intro-apis/types-new-relic-api-keys'>$API_KEY</a>" -i
-H "Api-Key:$API_KEY" -i
```

In the REST API Explorer, you can quickly [change the page being viewed](/docs/apm/apis/api-explorer-v2/parts-api-explorer#data_page).
Expand All @@ -54,8 +54,8 @@ The API call returns the `Link` header if the data is paginated. This indicates

To obtain this line using some implementations of `curl`, you may need to include the `-v` option.

```
curl -v -X GET 'https://api.newrelic.com/v2/applications/<a href="/docs/apis/rest-api-v2/requirements/finding-product-id">$APP_ID</a>/...'
```sh
curl -v -X GET 'https://api.newrelic.com/v2/applications/$APP_ID/...'
```

New Relic uses the [RFC 5988](http://www.rfc-editor.org/rfc/rfc5988.txt) standard format for links.
Expand Down
Loading

0 comments on commit 474ffc7

Please sign in to comment.