如何显示前 5 URL 的 table 及其在 splunk 上的状态和百分比

How to display table of top 5 URL with their status and percentage on splunk

需要 table 来显示前 5 个 URL,如下面在 Splunk 中给出的。这在 Splunk 中可能吗?我尝试了很多方法,但我无法将 URL 的所有状态作为一行。

API                         200        204  400 401 499 500

/wodetails/ACP              895(50%)    -    -   -   -   1

这是可以使用chart命令的情况:

index="main"  source="access.log" sourcetype="access_combined"
| chart c(status) by uri, status
uri 200 204 400 499
/basic/status 11 1 1 1
/search/results 3 0 0 0

要添加百分比,您可以使用 eventstats

index="main"  source="access.log" sourcetype="access_combined"

| eventstats count as "totalCount" by uri
| eventstats count as "codecount" by uri, status
| eval percent=round((codecount/totalCount)*100)

| eval cell=codecount." (".percent."%)"

| chart values(cell) by uri,status
uri 200 204 400 499
/basic/status 11 (79%) 1 (7%) 1 (7%) 1 (7%)
/search/results 3 (100%)