<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: dashboard in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/dashboard/m-p/701149#M57478</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/257462"&gt;@Siddharthnegi&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;you can do this only displaying in your dashboard the records from a KV-Store lookup because Splunk isn't a database where you can delete records.&lt;/P&gt;&lt;P&gt;But a kv-store lookup is a database table in which you can store e.g. your open cases.&lt;/P&gt;&lt;P&gt;Then you have add an html button in your dashboard (Classic dashboard) and you have to create a java script that executes a search that deletes a record from the lookup and then displays again the updated lookup.&lt;/P&gt;&lt;P&gt;In other words, in the dashboard you ha to add:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;
        &amp;lt;button class="btn btn-primary button1"&amp;gt;Save&amp;lt;/button&amp;gt;
        &amp;lt;a class="btn btn-primary" href="all_cases"&amp;gt;Cancel&amp;lt;/a&amp;gt;
      &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
  &amp;lt;row&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;then you have to create a js like the following (obviously must to be adapted to your lookup to be inserted in $SPLUNK_HOME/etc/apps/&amp;lt;my_app&amp;gt;/appserver/static&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;require([
	"splunkjs/mvc",
	"splunkjs/mvc/searchmanager",
	"splunkjs/mvc/savedsearchmanager",
	"splunkjs/mvc/utils",
    "splunkjs/mvc/simplexml/ready!"
	], function(
		mvc,
		SearchManager,
        SavedSearchManager,
	) {
		var query;
		var tokens = mvc.Components.get("default");
		tokens.unset("status_to_update", null);
		tokens.unset("notes_to_update", null);
		tokens.unset("username_to_update", null);
	$(".button1").on("click", function (){
		//var tokens = mvc.Components.get("default");
		var username=Splunk.util.getConfigValue("USERNAME");      
		var mod_status = tokens.get("status_to_update");
		var mod_notes = tokens.get("notes_to_update");
		var mod_username = tokens.get("username_to_update");
		var username_updated = tokens.get("username_updated");
		var key = tokens.get("key");
		//alert(username_updated);
		//tokens.unset("status_to_update");		
		//tokens.unset("notes_to_update");
		//tokens.unset("username_to_update");
		if(mod_username==null) { } else { username=mod_username;}
		if (mod_status==null) {
			query = "| inputlookup open_cases | eval Notes=if(_key=\"" + key + "\",\"" + mod_notes + "\",Notes), Status=\"Work-in-progress\", User_Name=if(_key=\"" + key + "\",\"" + username + "\",User_Name) | search _key=\"" + key + "\" | outputlookup open_cases append=true | eval key=_key | collect addtime=true index=summary_alerts | eval Time=strftime(TimeStamp,\"%d/%m/%Y %H:%M:%S\"), key=_key | table key Time TimeStamp Alert_Name Description Status Notes User_Name";
			//alert (query);
		} else {
			query = "| inputlookup open_cases | eval Status=if(_key=\"" + key + "\",\"" + mod_status + "\",Status), Notes=if(_key=\"" + key + "\",\"" + mod_notes + "\",Notes), User_Name=if(_key=\"" + key + "\",\"" + username + "\",User_Name) | search _key=\"" + key + "\" | outputlookup open_cases append=true | eval key=_key | collect addtime=true index=summary_alerts | eval Time=strftime(TimeStamp,\"%d/%m/%Y %H:%M:%S\"), key=_key | table key Time TimeStamp Alert_Name Description Status Notes User_Name";
			//alert (query);
		}
		var ok = confirm("Are you sure?");
		if (ok){
			launchquery(query);
        } //else {
        //    alert('user did not click ok!');
        //}
    });
	function launchquery(query) {
		var mysearch = new SearchManager({
			id: "mysearch",
            autostart: "false",
            //search: "| inputlookup open_cases | eval Status=if(_key=\"$key$\",\"$status_updated$\",Status), Notes=if(_key=\"$key$\",\"$notes_updated$\",Notes), User_Name=if(_key=\"$key$\",\"$username_updated$\",User_Name) | search _key=\"$key$\" | outputlookup open_cases append=true | eval key=_key | collect addtime=true index=summary_alerts | eval Time=strftime(TimeStamp,\"%d/%m/%Y %H:%M:%S\"), key=_key | table key Time TimeStamp Alert_Name Description Status Notes User_Name"
			search: query
        });  
		mysearch.on('search:failed', function(properties) {
            // Print the entire properties object
            console.log("FAILED:", properties);
        });
        mysearch.on('search:progress', function(properties) {
            // Print just the event count from the search job
            console.log("IN PROGRESS.\nEvents so far:", properties.content.eventCount);
        });
        mysearch.on('search:done', function(properties) {
            // Print the search job properties
            console.log("DONE!\nSearch job properties:", properties.content);
        });
		window.location.reload();
	}
});&lt;/LI-CODE&gt;&lt;P&gt;I cannot help you more because I'm not an expert in JS developing.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
    <pubDate>Mon, 07 Oct 2024 07:19:52 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2024-10-07T07:19:52Z</dc:date>
    <item>
      <title>dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/dashboard/m-p/701148#M57477</link>
      <description>&lt;P&gt;Hi I have a Dashboard and i want to add a button , so when somebody solves that particular issue he/she can click on that button and it will change status to solved and it will be removed from dashboard.&lt;BR /&gt;&lt;BR /&gt;for eg: I have a issue on a device and i solved that issue so then i can click on that button and it will make that issue status solved or will be removed from the dashboard.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2024 06:45:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/dashboard/m-p/701148#M57477</guid>
      <dc:creator>Siddharthnegi</dc:creator>
      <dc:date>2024-10-07T06:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/dashboard/m-p/701149#M57478</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/257462"&gt;@Siddharthnegi&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;you can do this only displaying in your dashboard the records from a KV-Store lookup because Splunk isn't a database where you can delete records.&lt;/P&gt;&lt;P&gt;But a kv-store lookup is a database table in which you can store e.g. your open cases.&lt;/P&gt;&lt;P&gt;Then you have add an html button in your dashboard (Classic dashboard) and you have to create a java script that executes a search that deletes a record from the lookup and then displays again the updated lookup.&lt;/P&gt;&lt;P&gt;In other words, in the dashboard you ha to add:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;
        &amp;lt;button class="btn btn-primary button1"&amp;gt;Save&amp;lt;/button&amp;gt;
        &amp;lt;a class="btn btn-primary" href="all_cases"&amp;gt;Cancel&amp;lt;/a&amp;gt;
      &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
  &amp;lt;row&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;then you have to create a js like the following (obviously must to be adapted to your lookup to be inserted in $SPLUNK_HOME/etc/apps/&amp;lt;my_app&amp;gt;/appserver/static&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;require([
	"splunkjs/mvc",
	"splunkjs/mvc/searchmanager",
	"splunkjs/mvc/savedsearchmanager",
	"splunkjs/mvc/utils",
    "splunkjs/mvc/simplexml/ready!"
	], function(
		mvc,
		SearchManager,
        SavedSearchManager,
	) {
		var query;
		var tokens = mvc.Components.get("default");
		tokens.unset("status_to_update", null);
		tokens.unset("notes_to_update", null);
		tokens.unset("username_to_update", null);
	$(".button1").on("click", function (){
		//var tokens = mvc.Components.get("default");
		var username=Splunk.util.getConfigValue("USERNAME");      
		var mod_status = tokens.get("status_to_update");
		var mod_notes = tokens.get("notes_to_update");
		var mod_username = tokens.get("username_to_update");
		var username_updated = tokens.get("username_updated");
		var key = tokens.get("key");
		//alert(username_updated);
		//tokens.unset("status_to_update");		
		//tokens.unset("notes_to_update");
		//tokens.unset("username_to_update");
		if(mod_username==null) { } else { username=mod_username;}
		if (mod_status==null) {
			query = "| inputlookup open_cases | eval Notes=if(_key=\"" + key + "\",\"" + mod_notes + "\",Notes), Status=\"Work-in-progress\", User_Name=if(_key=\"" + key + "\",\"" + username + "\",User_Name) | search _key=\"" + key + "\" | outputlookup open_cases append=true | eval key=_key | collect addtime=true index=summary_alerts | eval Time=strftime(TimeStamp,\"%d/%m/%Y %H:%M:%S\"), key=_key | table key Time TimeStamp Alert_Name Description Status Notes User_Name";
			//alert (query);
		} else {
			query = "| inputlookup open_cases | eval Status=if(_key=\"" + key + "\",\"" + mod_status + "\",Status), Notes=if(_key=\"" + key + "\",\"" + mod_notes + "\",Notes), User_Name=if(_key=\"" + key + "\",\"" + username + "\",User_Name) | search _key=\"" + key + "\" | outputlookup open_cases append=true | eval key=_key | collect addtime=true index=summary_alerts | eval Time=strftime(TimeStamp,\"%d/%m/%Y %H:%M:%S\"), key=_key | table key Time TimeStamp Alert_Name Description Status Notes User_Name";
			//alert (query);
		}
		var ok = confirm("Are you sure?");
		if (ok){
			launchquery(query);
        } //else {
        //    alert('user did not click ok!');
        //}
    });
	function launchquery(query) {
		var mysearch = new SearchManager({
			id: "mysearch",
            autostart: "false",
            //search: "| inputlookup open_cases | eval Status=if(_key=\"$key$\",\"$status_updated$\",Status), Notes=if(_key=\"$key$\",\"$notes_updated$\",Notes), User_Name=if(_key=\"$key$\",\"$username_updated$\",User_Name) | search _key=\"$key$\" | outputlookup open_cases append=true | eval key=_key | collect addtime=true index=summary_alerts | eval Time=strftime(TimeStamp,\"%d/%m/%Y %H:%M:%S\"), key=_key | table key Time TimeStamp Alert_Name Description Status Notes User_Name"
			search: query
        });  
		mysearch.on('search:failed', function(properties) {
            // Print the entire properties object
            console.log("FAILED:", properties);
        });
        mysearch.on('search:progress', function(properties) {
            // Print just the event count from the search job
            console.log("IN PROGRESS.\nEvents so far:", properties.content.eventCount);
        });
        mysearch.on('search:done', function(properties) {
            // Print the search job properties
            console.log("DONE!\nSearch job properties:", properties.content);
        });
		window.location.reload();
	}
});&lt;/LI-CODE&gt;&lt;P&gt;I cannot help you more because I'm not an expert in JS developing.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2024 07:19:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/dashboard/m-p/701149#M57478</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2024-10-07T07:19:52Z</dc:date>
    </item>
  </channel>
</rss>

