New trigger: db error string matching

triggers

#1

All: here is a trigger that is hopefully useful - it’ll match against an error string and increment a counter and detail (i.e. who received the error and how many times).

/*
Author: Matt Cauthorn, Extrahop Networks, Inc.
Description: Checks for a specfic string in a DB error.
Event: DB_RESPONSE
*/

/*
The variables below should be changed to match your environment. 
First, setup the lookup keys. These are the key names that you will use to fetch 
the counts from the data store. Use all lower case, with uderscores for spaces.

Next, set up the error string you want to track. That's it for config.
After that head over to your device, bind the trigger, and setup a custom page
to show you this data. You can alert on it too, of course.
*/

// Key names below.
var counter_name = "connection_errors"; // Change this to match your counter key for lookups. 
var counter_detail = "connection_errors_detail"; // Change this to your counter detail key.

// Error string to search on below. 
var error_string = "file format"; // Change this to match your string.
var error = DB.error || null; 

if(error !=null){

   // debug("error is: " + error); 
if(error.indexOf(error_string) != -1) {
    //debug("error is: " + error + " => incrementing counter"); 
    Device.metricAddCount(counter_name, 1); // change name
    Device.metricAddDetailCount(counter_detail,Flow.client.ipaddr, 1);
   }
}

I hope this is useful! If so, please upvote :slight_smile: