Getting Data In

How to extract JSON into a chart?

goe
Engager

Hello,

I have JSON string in the following format,

{"status":"503"}

and I would like to create a pie chart with the values of status, the number of occurrences for a time period.

So far I create this and I think I am close,

ERROR | spath output=status path=status | timechart count as "Error" by status
0 Karma
1 Solution

goe
Engager

Hey thanks! I managed to solve it using rex because it's JSON within regular text.

My solution is similiar to this.

But instead of displaying in table I did,

| rex field=_raw "status\":\"(?P<msg>.[^\"\"]*)" | chart count msg

View solution in original post

0 Karma

goe
Engager

Hey thanks! I managed to solve it using rex because it's JSON within regular text.

My solution is similiar to this.

But instead of displaying in table I did,

| rex field=_raw "status\":\"(?P<msg>.[^\"\"]*)" | chart count msg
0 Karma

somesoni2
Revered Legend

@goe, glad you were able to work out your issue. Please accept this answer to close the question. If possible, if you can add the solution (by editing this Answer), that'll help other Splunkers with similar issues.

0 Karma

p_gurav
Champion

Can you try:

| makeresults | eval abc="{\"status\":\"503\"}"  | spath input=abc output=status path=status | timechart count by status
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...