All Apps and Add-ons

Convert query results to line chart

karthi25
Path Finder

I have an oracle query as follows:

|dbxquery query="select trunc(start_dt) START_DT, count(0) ERR_CNT , 'WORKFLOW' as SOURCE from ***.WORKFLOW_LOG wl where WL.STATUS not in ('COMPLETED', 'INPROGRESS') and start_dt > SYSDATE - 30 group by trunc(start_dt) union select trunc(create_dt) START_DT, count(0) ERR_CNT , 'ESP' as SOURCE from ***.event_error_records eer where create_dt > SYSDATE - 30 group by trunc(create_dt)" connection="ABC_DADPP1"

And, the above query will produces the result below:
alt text

Now, I want to format the date and to create the the chart as below:
alt text

Can anyone please help to do it.

0 Karma
1 Solution

mayurr98
Super Champion

you can try something like this

| dbxquery query="select trunc(start_dt) START_DT, count(0) ERR_CNT , 'WORKFLOW' as SOURCE from ***.WORKFLOW_LOG wl where WL.STATUS not in ('COMPLETED', 'INPROGRESS') and start_dt > SYSDATE - 30 group by trunc(start_dt) union select trunc(create_dt) START_DT, count(0) ERR_CNT , 'ESP' as SOURCE from ***.event_error_records eer where create_dt > SYSDATE - 30 group by trunc(create_dt)" connection="ABC_DADPP1" 
| eval newtime=strptime(START_DT,"%Y-%m-%d %H:%M:%S") | eval _time=newtime
| timechart span=2d sum(ERR_CNT) by SOURCE

OR try this which is specific to your requirement

| dbxquery query="select trunc(start_dt) START_DT, count(0) ERR_CNT , 'WORKFLOW' as SOURCE from ***.WORKFLOW_LOG wl where WL.STATUS not in ('COMPLETED', 'INPROGRESS') and start_dt > SYSDATE - 30 group by trunc(start_dt) union select trunc(create_dt) START_DT, count(0) ERR_CNT , 'ESP' as SOURCE from ***.event_error_records eer where create_dt > SYSDATE - 30 group by trunc(create_dt)" connection="ABC_DADPP1" 
| eval newtime=strptime(START_DT,"%Y-%m-%d %H:%M:%S") | eval _time=newtime
| timechart span=2d sum(ERR_CNT) by SOURCE 
| rename _time as time 
| eval time=strftime(time,"%m-%d")

let me know if this helps!

View solution in original post

mayurr98
Super Champion

you can try something like this

| dbxquery query="select trunc(start_dt) START_DT, count(0) ERR_CNT , 'WORKFLOW' as SOURCE from ***.WORKFLOW_LOG wl where WL.STATUS not in ('COMPLETED', 'INPROGRESS') and start_dt > SYSDATE - 30 group by trunc(start_dt) union select trunc(create_dt) START_DT, count(0) ERR_CNT , 'ESP' as SOURCE from ***.event_error_records eer where create_dt > SYSDATE - 30 group by trunc(create_dt)" connection="ABC_DADPP1" 
| eval newtime=strptime(START_DT,"%Y-%m-%d %H:%M:%S") | eval _time=newtime
| timechart span=2d sum(ERR_CNT) by SOURCE

OR try this which is specific to your requirement

| dbxquery query="select trunc(start_dt) START_DT, count(0) ERR_CNT , 'WORKFLOW' as SOURCE from ***.WORKFLOW_LOG wl where WL.STATUS not in ('COMPLETED', 'INPROGRESS') and start_dt > SYSDATE - 30 group by trunc(start_dt) union select trunc(create_dt) START_DT, count(0) ERR_CNT , 'ESP' as SOURCE from ***.event_error_records eer where create_dt > SYSDATE - 30 group by trunc(create_dt)" connection="ABC_DADPP1" 
| eval newtime=strptime(START_DT,"%Y-%m-%d %H:%M:%S") | eval _time=newtime
| timechart span=2d sum(ERR_CNT) by SOURCE 
| rename _time as time 
| eval time=strftime(time,"%m-%d")

let me know if this helps!

FrankVl
Ultra Champion

Can you show what the output of the query looks like? Without that info it is rather hard to say what commands to use to transform it into something that can be visualized as a line chart.

0 Karma

karthi25
Path Finder

I have edited it.. 🙂

0 Karma
Get Updates on the Splunk Community!

Splunk APM & RUM | Upcoming Planned Maintenance

There will be planned maintenance of the streaming infrastructure for Splunk APM and Splunk RUM in the coming ...

Part 2: Diving Deeper With AIOps

Getting the Most Out of Event Correlation and Alert Storm Detection in Splunk IT Service Intelligence   Watch ...

User Groups | Upcoming Events!

If by chance you weren't already aware, the Splunk Community is host to numerous User Groups, organized ...