@lianlim
So what I was trying to do was have a table with an "Alert" column so that people could add alerts to a specific part in the table. Each row was an application that was being monitored then we wanted people to be able to add alerts to applications if needed. So I used a Jquery Dialog to create the prompt to get information to add to the alert column but a Javascript prompt also works:
element1.on("click", function(e) {
e.preventDefault();
if(e.field == "Alert"){
e.preventDefault();
var appname = e.data["row.App"];
var type = "User";
var dialog = $('<p>Enter an alert note for <b>' + appname + '</b> or clear the previous alert note. </p>').dialog({
position: myPos,
buttons: {
"Enter Alert Note": function(){
var note = prompt("Enter alert note for '" + appname + "'","");
var username = prompt("Enter Your Name: ", "");
if(note && username){
notesearch.settings.attributes.search = "| makeresults | eval Notes=\"" + note + "\" | eval application=\"" + appname + "\" | eval type=\"" + type + "\" | eval name=\"" + username + "\" | collect index=splunk-test source=app_alerts";
notesearch.startSearch();
setTimeout(function(){search1.startSearch();},2000);
$(this).dialog("close");
}
$(this).dialog("close");
},
"Clear Previous Note": function(){
notesearch.settings.attributes.search = "| makeresults | eval application=\"" + appname + "\" | eval type=\"" + type + "\" | collect index=splunk-test source=app_alerts";
notesearch.startSearch();
setTimeout(function(){search1.startSearch();},2000);
$(this).dialog("close");
}
},
width:350
}).css("font-size", "15px");
}
So I added a click event for the table and when the user clicked on the "Alert" field they would be prompted to enter an alert note for the application (row) that they clicked on. I used makeresults to set all the values I needed from the variables gathered from the dialog and the collect command to save my alerts in a certain index and source so that when the search for the table runs again it will pick up the alert. I just created a blank searchelement called notesearch and changed it to run the search i needed. So my main table search does a join on application and retrieves the latest alert from the app_alerts source so that it is displayed on the table after refreshing. Hope this helps.
... View more