-2

I am currently writing a Splunk Query to pull a report over the events and I am using this now to do it and it has to be using table only

index=1234 source="/apps/logs/*.log" AND "logType=API_RESPONSE"
| spath input=request
| spath input=response
| rename body.data.Item1 as Item1
| rename body.data.Item2 as Item2
| rename body.data.Item3 as Item3
| stats  count by URI   
| rename  count as NumberofTimes_Called_URI, URI as URI_Called
| table  Item1,Item2,Item3

Prerequisites

  1. The API_RESPONSE is a JSON response
  2. Item1, Item2, and Item3 are JSON fields in response.

Issue: Not able to render the Splunk table in the statistics for this part

| stats  count by URI   
| rename  count as NumberofTimes_Called_URI, URI as URI_Called

individually the above is working but when i combine and render the table it's not working.

Please help me fix this problem.

1 Answers1

0

"It's not working" is not a problem description, but I'm guessing you are getting all nulls in the results table. That's because stats is a transforming command so the only fields available after it are those used in it, namely count and URI.

Since table (also a transforming command) only displays Item1, Item2, and Item3, there is no need for stats or rename.

If you intend to add count and URI to the table then replace stats with eventstats, which is not transforming.

index=1234 source="/apps/logs/*.log" AND "logType=API_RESPONSE"
| spath input=request
| spath input=response
| rename body.data.Item1 as Item1
| rename body.data.Item2 as Item2
| rename body.data.Item3 as Item3
| eventstats  count as NumberofTimes_Called_URI by URI   
| rename URI as URI_Called
| table  Item1,Item2,Item3, URI, NumberofTimes_Called_URI
RichG
  • 9,063
  • 2
  • 18
  • 29
  • That didn't work @RichG – Pavan_Yalamanchili Aug 29 '22 at 19:46
  • How is anyone supposed to help you with information like that? Tell us what results you received and how those results differ from what you want. Run query one command at a time and verify you have results. When you stop getting what you expect then that is the command at fault. Let us know which one it is. – RichG Aug 30 '22 at 11:45