在 Splunk 中将带参数的 url 合并为 1
我正在为我们的服务创建仪表板。我想为URL请求创建指标。 假设有一个类似的URL类似的URL:
/api/v1/users/{userId}/settings
我在Splunk中有关注的查询,
url=*/api/v1/users/*/settings
| stats avg(timeTaken) as avg_latency, p99(timeTaken) as "p99(ms)", perc75(timeTaken) as "p75(ms)", count as total_requests, count(eval(responseStatus=500)) as failed_requests by url
| eval "success_rate"=round((total_requests - failed_requests)/total_requests*100,2)
| eval avg = round(avg)
| sort success_rate
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您要创建一个url的字段,该字段是URL减去用户ID部分,因此统计数据将分组为url。
您可以使用
split(URL,“/”)
来做到这一点,以制作URL的MV字段,并根据URL取出两种方式之一。mvfilter(evar(x!= userId))
或创建了一个新的mvfield,并使用以下方式在mvfield中删除了userId: add/edit/edit/edit/delete/delete mvfield
只要您对所有URL做同样的事情,就可以选择用“ {UserId}”替换用户ID,而不是删除用户ID。
然后,您可以使用
mvjoin(url,“/”)
重新加入URL,希望我能正确理解您的问题,这对您有帮助!
You want to create a field which is the URL minus the UserId part, And therefore the stats will be grouped by which url is called.
You can do this by using
split(url,"/")
to make a mv field of the url, and take out the UserId by one of two ways depending on the URLs.Mvfilter: Eg:
mvfilter(eval(x!=userId))
Or created a new mvfield with the userId removed by it's index in the mvfield using this: Add/Edit/Delete mvfield
Instead of removing you could also choose to replace the UserId with "{userId}", so long as you do the same for all Urls.
And then you can rejoin the url using
mvjoin(url,"/")
I hope I understood your question correctly and this helps you!
您可以尝试使用
eval
在调用stats
之前:如果结果表明用户 ID 很重要,请在运行之前将其拉入自己的字段
replace()
:注释扩展
对于 URL 的多种可能结尾,请尝试如下操作:
这会将“类型”(注销、配置文件、设置)提取到新字段中,然后清理 URL删除从 userid 到末尾的所有内容
You could try doing a
replace()
on your URL field witheval
before callingstats
:If it turns out the userid is important to hold onto, pull it into its own field prior to running
replace()
:expansion for comment
For multiple possible endings of your URL, try something like this:
This will extract the "type" (logout, profile, settings) into a new field, then cleanup the URL by removing everything from userid to the end