Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Feature request - NRQL string functions

feature-request
nrql
rfb

#21

Are there any string utilities in NRQL? E.g., what I’d like to do is

SELECT count(*) FROM PageView WHERE appName='myapp' FACET re.search('https://(www\.)?slated\.com/films/', pageUrl).group() LIMIT 25 SINCE 1 day ago

(using python re language here), where I can extract a substring out of a FACET or SELECT argument.


#22

We do have a LIKE functionality in NRQL that’s analogous to SQL’s LIKE (see https://docs.newrelic.com/docs/insights/new-relic-insights/using-new-relic-query-language/nrql-reference#clauses). There’s not a more sophisticated type of text matching currently. Can you tell us what you’re wanting to accomplish, and whether the LIKE functionality meets your needs? If not, that will help us create a proposal for our product team with your use case.


#23

In this particular example, I’m trying to group my urlpaths by the first path element. I ended up adding a custom parameter in my request handler middleware that looks like

    path = request.path.split('/',2)
    # leave '/films/' as is, but change '/films/123/' to 'films/...'
    if len(path) > 2 and path[2]:
        path[2] = '...'
    log_newrelic_parameter('path_top', '/'.join(path))

However, newrelic already captures pathUrl, so it seems like I should be able to simply write a query that selects/groups on a string computed from the pathUrl, rather than adding that to my server stack.


#24

So it sounds like just using pageUrl LIKE '%films%' would not work for you?

It also sounds like you might want to take a gander at the browserTransactionName attribute. This will generally be grouping URL paths in a more useful way than the raw URLs. If it’s not working for you, we can help you get your browser transaction names set up in a way that might work.


#25

I believe what is needed here (and what I’d need as well) is a way to map multiple values of an attribute to the same facet value, e.g. count all name values that begin with “foo” to facet value “foo” and all values that begin with “bar” to facet value bar. If you have hundreds of similar transaction names and you like to group them by their type (which can be derived by a string operation), the only workaround I currently see is to have a custom attribute that does the job. As we have dozens of applications and servers we cannot just bring down / change the source, we would need to do this as part of RSQL, preferably with a regexp matching function:
select count(*) from Transaction facet REGEXP_MATCH("^(foo|bar).*", name)


#26

Awesome detail again @jnicolai - I have added this to you request.


#27

Does REGEXP_MATCH function is available in NRSQL as of today ?


#28

Hey @PPitroda – This sort of functionality has not been developed at this time, but we can certainly add your +1 to our feature request tracker so that your need for this reaches our Product Management team. We appreciate the feedback!


#29

:+1:

We’d love having this functionality too!


#30

Thanks for letting me know, @marcadores-com! I’ll pass this idea along—feel free to provide a use case or any other info you think will be helpful to us! :thumbsup:


#31

+1 regex in NRQL would be very useful.


#32

+1 have a use case for sub grouping a Facet


#33

Some kind of substring that would then also be useful in a facet would be nice. Perhaps whatever is matched with the current LIKE could then be the thing that is returned or grouped on, instead of the AS name you must give currently.


#34

Are there any plans to develop this feature in the nearest future? :smiley:


#35

add another +1 here for the ability to group longer attributes
facets to a shorter name


#36

+1 this would be really helpful!


#37

+1 I too wish this existed


#38

Thanks for the +1s folks - getting this submitted internally right now :smiley: