Querying for something with substring matching

Right now, when I try to query for something, it uses exact matching, like: SELECT max(diskUsedPercent) FROM StorageSample WHERE AppName= ‘appsample’

however is it possible for query to implement substring matching like: SELECT max(diskUsedPercent) FROM StorageSample LIKE AppName= ‘appsample’

so if I have appsample1, then it will get selected for, or if I change its name to appsample2, it will also get selected for as well.
I’m a bit new to New Relic, but I did not find any solutions in the NRQL documentation, and the discussion forum didn’t have a clear solution.

@Stanley.Wong - yup, you can use a query like:

SELECT max(diskUsedPercent) FROM StorageSample WHERE AppName LIKE  ‘appsample%’

In this case, % is the wildcard character, so the query will return details for any app with a name beginning appsample

See more here:

https://docs.newrelic.com/docs/insights/nrql-new-relic-query-language/nrql-reference/nrql-syntax-components-functions#sel-where

3 Likes

I am pretty new to NewRelic and i have the below doubt.

Is there a way to implement something like the below one :

WHERE ContactName LIKE ‘a%o’ : Finds any values that starts with “a” and ends with “o”

Hi, @ajay.tk: Have you tried it?

Yes, it worked as expected. Do you know a way to find the difference in timestamp between 2 consecutive records using NRQL ? Im looking for something similar to LEAD(), LAG() in SQL

@akay.tk: I do not think that is possible in NRQL. You can see a complete list of NRQL clauses and functions here: https://docs.newrelic.com/docs/query-your-data/nrql-new-relic-query-language/get-started/nrql-syntax-clauses-functions.