With NRQL, you can create queries that group results across time. For example, you can group results together based on timestamps by separating them into buckets that cover a specified range of dates and times.
To create your NRQL query, use a
FACET clause with a bucket function that works with a timestamp attribute. Run a standard
FACET query, but instead of faceting by an attribute, facet by time. For example:
SELECT count(*) FROM PageView SINCE 1 day ago FACET monthOf(account_created)
To perform multiple functions within the same query, use NRQL's multi-facet capability:
SELECT count(*) FROM PageView SINCE 1 day ago FACET dateOf(account_created), monthOf(account_created)
Returns the year of a timestamp.
Returns the quarter of the year. The returned value includes both the quarter and the year.
Returns the month and year of the timestamp.
Returns the week the timestamp occurred by naming the month and day of that week's Monday.
Returns the day of the week of the timestamp. The returned value loops back at the end of the week, allowing you to look at trends by weekday over time.
Returns the date of the timestamp. The returned value includes month, day and year.
Returns the numeric date within a single month of the timestamp, a value from 1 to 31. The returned value does not include the month.
Returns the hour of the timestamp.
The returned value does not include a prepended 0 for hours between 1am and 9am. This differs from functions and clauses such as
If you need more help, check out these support and learning resources:
- Browse the Explorers Hub to get help from the community and join in discussions.
- Find answers on our sites and learn how to use our support portal.
- Run New Relic Diagnostics, our troubleshooting tool for Linux, Windows, and macOS.
- Review New Relic's data security and licenses documentation.