Splunk Search

Creating a graph with two columns of a table

matansocher
Contributor

Hello,

I need to make a simple line chart with the values of two columns of a table. the first column is the x axis and the second column is the y axis. At the meeting point of the two columns on the graph I need to represent with a dot, and to connect with a line between the dots.
Here is an example of the result I need:
alt text

In this example I need the opposite. The dates should be on the x axis and the values should be on the y axis.

Here is the code I am using:

| inputcsv MPSMilstonesCSV 
| sort TaskDeadline 
| fieldformat TaskDeadline = strftime(TaskDeadline, "%d/%m/%Y") 
| table Report_Milestone TaskDeadline

I don't know if i should use xyseries or timechart or a regular chart.

Thank you

0 Karma

woodcock
Esteemed Legend

Like this:

| inputcsv MPSMilstonesCSV
| eval _time = strftime(TaskDeadline, "%d/%m/%Y")
| timechart span=1d avg(Report_Milestone)
| untable _time Report_Milestone count
| eval _time = strftime(_time, "%m/%d/%Y")
| xyseries Report_Milestone _time count

You might replace avg with first or sum but there has to be some kind of aggregating function when you use timechart (whether you "need one" or not). If you are sure that there is always 0 or 1 value for each Report_Milestone each day, then you can use first, but it is safest to use avg, just in case.

0 Karma

somesoni2
Revered Legend

Assuming TaskDeadline is in epoch (based on usage of strftime in your question), try this

| inputcsv MPSMilstonesCSV 
 | sort TaskDeadline | eval _time=TaskDeadline 
 | fieldformat _time=strftime(_time, "%d/%m/%Y") 
 | table  _time Report_Milestone
0 Karma

matansocher
Contributor

The query that you are suggesting really gives me the table I need, but not the chart I need.

Is there a way to create a chart like that?

http://imgur.com/a/OlXHQ

thank you

0 Karma

woodcock
Esteemed Legend

That link has no image that I can see.

0 Karma

matansocher
Contributor

http://i67.tinypic.com/2195k06.png

I need the opposite - the y axis should be the values (milestones) and the x axis should be the dates.
thank you.

0 Karma

woodcock
Esteemed Legend

Like this:

| inputcsv MPSMilstonesCSV
| sort TaskDeadline
| fieldformat TaskDeadline = strftime(TaskDeadline, "%d/%m/%Y")
| rename TaskDeadline AS _time
| table Report_Milestone TaskDeadline
| timechart avg(Report_Milestone)
0 Karma

matansocher
Contributor

the following code does not help me.
I did not understand why I should take the average in the timechart.
Also, the result doesn't give me the x axis as dates and the y axis as the names of the milestones(Report_Milestone).

Is there any other way to try this?

thank you

0 Karma

woodcock
Esteemed Legend

You are using the wrong terms. When you say X-axis in Splunkytown, everyone thinks that you are referring to the Visualizations tab and on that tab, you need the data formatted as I created in my answer.
I see now that when you say X-axis that you mean columns which is the term in Splunkytown that would cause us to think 'Statistics` tab. Now that I know what you are asking, check my latest answer (writing it now).

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...