• /
  • Log in
  • Free account

Extract valuable data with regex capture

June 24, 2021

Finding patterns in strings easily with this powerful tool

We've made it easier than ever to query and extract useful data from strings such as URLs, log messages, and more, using Regex capture. Regular expressions are an extremely powerful tool for finding patterns in strings—and with Regex capture, you can now leverage that power to improve your NRQL queries.

Regex capture works directly within NRQL using the capture function, allowing you to use regular expressions in your queries to extract focused data, such as this:

capture(request_url, r'.*/accounts/(?P<account>\d+).*')

The capture function takes two arguments. The first is the request_url: the attribute containing the URL string. The second argument is a regular expression pattern. Regex capture is built on Re2 syntax, a regular expression library created by Google.

As an example, the below query will find which accounts are using specific service endpoints (the request_url) most frequently:

FROM Transaction SELECT count(*) WHERE request_url LIKE '%data%' LIMIT 50 FACET capture(request_url, r'.*/accounts/(?P<account>\d+).*')

Get started today

  1. Start using Regex capture in your NRQL queries by choosing Query your Data in the New Relic One UI.
  2. Learn more by reading our NRQL documentation.
  3. Check out our newrelic.com/blog with example queries.
Create issueEdit page
Copyright © 2021 New Relic Inc.