Hi Everyone,
Is it possible to concatenate current date and time with dashboard label e.g. my dashboard label is "Monthly status report" and I want to show it as "Monthly status report" + "Current date and time".Please suggest me how to do it and if it is not possible with concatenate then how I can achieve this ?
Thanks in advance
by using the simple xml code and combination of javascript and read only text box I achieved this...thanks everyone for your valuable inputs..
by using the simple xml code and combination of javascript and read only text box I achieved this...thanks everyone for your valuable inputs..
If you want implement the date as a text label in your dashboard using Javascript, you can also do the following (again, I'm assuming you're using advanced XML and SideView Utils' HTML module);
<module name="HTML">
<param name="html">
<![CDATA[
<script>
var theDate = new Date();
$$(function() {
$$( "#ReportTitle" ).text(theDate);
});
</script>
<h3>Monthly status report <Label id="ReportTitle" ></h3>
]]>
</param>
</module>
I hope this helps!
@jhowkins thanks for quick response..I am not using SideView Utils, I am working on simple XML .Is it possible with simple XML..?
Assuming you are using advanced XML for your dashboard and you're willing to use SideView Utils' HTML module, the following will work;
<module name="HiddenSearch" autoRun="True">
<param name="search">index=_internal | stats count | eval ReportLabel = "Monthly status report ".strftime( time(), "%B %e, %Y %k:%M:%S %p") | table ReportLabel</param>
<module name="HTML">
<param name="html">
<![CDATA[
<p>$results[0].ReportLabel$</p>
]]>
</param>
</module>
</module>
You don't necessarily need to concatenate with an eval either. You could change the code above as follows:
eval = strftime( time(), "%B %e, %Y %k:%M:%S %p")
and
<![CDATA[
<p>Monthly status report $results[0].ReportLabel$</p>
]]>
Note: index=_internal can be swapped for whatever index you feel comfortable using
You can format the date/time using Splunk's date and time format variables: http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Commontimeformatvariables
You can concatenate fields values in an eval
command using the dot as separator.
examples :
<mywonderfulsearch> | eval newfield=fieldA.fieldB | table newfield
<mywonderfulsearch> | eval newfield=fieldA." and my other information is ".fieldB | table newfield
If you have fields names already in a string with spaces, you will have to use double quotes, so it may mess up the eval.
I recommend to use simple fields names, and rename then at the end at display time.
understood, the eval works for the results, not the panels names.
the javascript is the way to go.
@yannK Thanks for the reply but how I can use eval command with label .I can use it in search bar only....
I have prepared a javascript which shows me a date in an alert now how I can link this to label ...
do you have javascript available to you?