Hi Team/Kamlesh,
Below is my json object and i want find the count of exception_type whose value is "Application Exception" in last 1 hour which is child element of error object and i should display the count in table.
I am very new to splunk, plz help me by giving the splunk query.
Please help me
THANK YOU SO MUCH in advance.
{
"class_name": "com.verizon.vsib.addressval.services.CameoClient",
"VSAD_ID": "GYEV",
"True_ip": "10.118.142.156",
"log_message": "Missing Company Code",
"server_port": "443",
"error": {
"exception_type": "Application Exception",
"exception_code": "P0106",
"exception_details": "Missing Company Code"
},
"user_agent": "PostmanRuntime/7.25.0",
"@timestamp": "2020-12-24T05:41:18.181Z",
"log_time_stamp": 1608788478110,
"status_code": 500,
"api_url": "https://vsib-dev.ebiz.verizon.com/addressValidation/validateAddress?null",
"log_level": "info",
"server_host": "10.118.143.141",
"app_environment": "dev",
"@version": "1",
"requestId": "TestSplunk-17",
"vast_id": 25439,
"log_date": "",
"logger_class": "com.verizon.vsib.addressval.services.CameoClient",
"time": 1608788478.181,
"app_name": "VSIB",
"function_name": "pushApplicationError"
}
Regards,
Murali P.
Hello @muralip543
You can get all the events having exception_type="Application Exception" by this search. You will get all the event for all the apps.
index="gyev_np" error.exception_type="Application Exception"
if you want to get particular app events then just add one more filter
index="gyev_np" error.exception_type="Application Exception" app_name = "VSIB"
With these event if you want over all count with selected period.
Just add `| stats count`
index="gyev_np" error.exception_type="Application Exception" app_name = "VSIB" | stats count
If you want app wise count then remove app_name filter and add `by app_name`
index="gyev_np" error.exception_type="Application Exception" app_name = "VSIB" | stats count by app_name
In case you need hourly count for selected period then use timechart with span option. Here you will have data for trending chart.
index="gyev_np" error.exception_type="Application Exception" app_name = "VSIB" | timechart count span=1h
index="gyev_np" error.exception_type="Application Exception" app_name = "VSIB" | timechart count span=1h by app_name
Just execute above search, you will get idea about search and the search results which you expected.
if you can share your expected search output please share with us so we will help you on it.
Thanks
Happy Splunking
@kamlesh_vaghela If we want to capture the stats for both application exceptions and system exceptions and success transactions ?
index="gyev_np" | search "app_name" = "VSIB" | stats count(eval(status_code="500")) as Failures count(eval(status_code="200")) as Success
The above is perfectly working fine but the below one is not working
index="gyev_np" error.exception_type="Application Exception" error.exception_type="System Exception" app_name = "VSIB" | stats count
I want to display both application exception and system exception counts as columns and graphical representation
Please help me.
Thanks in advance
Try this.
index="gyev_np" ( error.exception_type="Application Exception" OR error.exception_type="System Exception" ) app_name = "VSIB" | stats count
Try this also for column representation.
index="gyev_np" ( error.exception_type="Application Exception" OR error.exception_type="System Exception" ) app_name = "VSIB" | stats count(eval('error.exception_type'="Application Exception")) as "Application Exception" count(eval('error.exception_type'="System Exception")) as "System Exception"
For graphical representation try below search with Column, Pie or Bar chart visualisation.
index="gyev_np" ( error.exception_type="Application Exception" OR error.exception_type="System Exception" ) app_name = "VSIB" |chart count by "error.exception_type"
Just switch Visualization tab for the same.
https://docs.splunk.com/Documentation/Splunk/8.1.1/Viz/CreateCharts
@kamlesh_vaghela Thank you so much Kamlesh...really thanks a lot
cool @muralip543
If you got your expected resolution then please accept this answer to close the question.
Thanks
Kamlesh
index=_internal | head 1 | fields _raw _time
| eval _raw="{\"class_name\":\"com.verizon.vsib.addressval.services.CameoClient\",\"VSAD_ID\":\"GYEV\",\"True_ip\":\"10.118.142.156\",\"log_message\":\"Missing Company Code\",\"server_port\":\"443\",\"error\":{\"exception_type\":\"Application Exception\",\"exception_code\":\"P0106\",\"exception_details\":\"Missing Company Code\"},\"user_agent\":\"PostmanRuntime/7.25.0\",\"@timestamp\":\"2020-12-24T05:41:18.181Z\",\"log_time_stamp\":1608788478110,\"status_code\":500,\"api_url\":\"https://vsib-dev.ebiz.verizon.com/addressValidation/validateAddress?null\",\"log_level\":\"info\",\"server_host\":\"10.118.143.141\",\"app_environment\":\"dev\",\"@version\":\"1\",\"requestId\":\"TestSplunk-17\",\"vast_id\":25439,\"log_date\":\"\",\"logger_class\":\"com.verizon.vsib.addressval.services.CameoClient\",\"time\":1608788478.181,\"app_name\":\"VSIB\",\"function_name\":\"pushApplicationError\"}"
| kv
| rename COMMENT as "this is your sample. from here, the logic"
| bin _time span=1h
| stats count(eval('error.exception_type'="Application Exception")) as count by _time
@kamlesh_vaghela Thank you so much for help, really thank you so much..
Hi, thank you so much for your quick response
actually my requirement is
we are pushing all our api logs which includes both success transactions and failure transactions to splunk, from the splunk i should find out the count of transactions which are failed i.e. whose exception type is application exception as mentioned above, above is my sample json log for failure transaction.
I have tried the below query:
index="gyev_np" | search "app_name" = "VSIB" | stats count(eval('error.exception_type'="Application Exception")) as count by _time
Please help me here
THANK YOU SO MUCH in advance