The New Relic Query Language (NRQL) is a powerful, SQL-like query syntax in New Relic Insights that lets you access your data, including custom events and attributes you’ve added.
Here are a few example NRQL queries to get you started.
--Discover what web transactions have the most errors across all your applications
SELECT count(*) FROM TransactionError FACET transactionName
--Graph the last day of page views that took over 2 seconds to complete broken down by the client's browser
SELECT count(*) FROM PageView WHERE duration > 2 SINCE 1 day ago FACET userAgentName TIMESERIES AUTO
--Show me the top 100 processes by CPU utilizations across all of my hosts for the last hour
SELECT average(cpuPercent) FROM ProcessSample FACET processDisplayName LIMIT 100 SINCE 60 minutes ago
New Relic APM, Browser, and Mobile agents include language-specific APIs that can extend functionality and data reporting.
Here's some example code to insert new custom attributes and custom events through the Java APM agent.
// Add a custom attribute to be added to existing APM events in Java
// Add a new custom event named "MyCustomEvent" to NRDB in Java
Map<String, Object> eventAttributes = new HashMap<String, Object>();