Skip to content

Commit

Permalink
Merge pull request #263 from newrelic/mdw-fix-add-custom-attributes
Browse files Browse the repository at this point in the history
Fix - Add custom attributes guide.
  • Loading branch information
mmfred authored Jun 27, 2020
2 parents 5575304 + 0b48fb9 commit c196f68
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/markdown-pages/collect-data/add-custom-attributes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,45 @@ redirects:
<Intro>

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>

You can add a `userid` custom attribute to your APM-reported data (`Transaction` and `TransactionError events`) with the Java APM agent's API.
<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.

```
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.

![UC2-sec1-query.png](https://developer.newrelic.com/content/dam/component-assets/developer/d09-screencap/UC2-sec1-query.png)

```
-- Get a count of errors experienced by a single filtered userid faceted by date and error message
SELECT count(*) FROM TransactionError WHERE userid = '616e6472-6577-7340-7961-686f6f2e636f' FACET dateOf(timestamp), `error.message` SINCE 1 week ago
```

[Learn more about NRQL](https://developer.newrelic.com/technology/nrql)

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

![UC2-sec1-query.png](https://developer.newrelic.com/content/dam/component-assets/developer/d09-screencap/UC2-sec1-query.png)
</Step>

</Steps>

</Intro>


### 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)

For more about the New Relic Query Language, see [Learn more about NRQL](https://developer.newrelic.com/technology/nrql)

0 comments on commit c196f68

Please sign in to comment.