• /
  • EnglishEspañol日本語한국어Português
  • Inicia sesiónComenzar ahora

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 going to one.newrelic.com > Query builder.
  2. Learn more by reading our NRQL documentation.
  3. Check out our newrelic.com/blog with example queries.
Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.