假设我有一个疑问:
SELECT count(*) from Transaction where appName='applicationName' and requestUri like '/deviceId/%' and httpResponseCode = '404' LIMIT max FACET requestUri
其中 %
是作为端点参数的 deviceId 编号的占位符。
现在 New Relic 查询的结果是指标列表:
/deviceId/id1
出现次数,
/deviceId/id2
出现次数,
/deviceId/id3
出现次数
我想要实现的只是接收带有端点出现次数的结果,但不通过端点参数来区分它,如下所示:
/deviceId/%
出现 3 次。
我在互联网上搜索过,但大多数示例都涉及对整个
requestUri
进行分面,在我的例子中,这强制手动计算所有端点调用。
我将不胜感激有关如何解决上述查询的建议。
尝试应用正则表达式
RLIKE
来分面您的数据,例如:
SELECT count(*) FROM Transaction WHERE hostname RLIKE 'ip-10-351-[0-2]?[0-9]-.*'
有关更多详细信息和文档,请访问以下网址: https://docs.newrelic.com/whats-new/2021/04/nrql-updates/
您可以在
case
操作中使用 facet
。
它会是这样的:
SELECT count(*)
from Transaction
where appName='applicationName' and httpResponseCode = '404'
LIMIT max
FACET CASE(WHERE requestUri like '/deviceId/%' as device_path)
您还可以在
CASE
上添加更多选项。
SELECT count(*)
from Transaction where appName='applicationName' and httpResponseCode = '404'
LIMIT max
FACET CASE(
WHERE requestUri like '/deviceId/%' as device_path,
WHERE requestUri LIKE '/something/%' as something_path
)