diff --git a/database/migrations/2022_05_30_084932_update-app-status-length.php b/database/migrations/2022_05_30_084932_update-app-status-length.php new file mode 100644 index 000000000000..258585dd467b --- /dev/null +++ b/database/migrations/2022_05_30_084932_update-app-status-length.php @@ -0,0 +1,32 @@ +string('app_status', 1024)->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('applications', function (Blueprint $table) { + $table->string('app_status', 8)->change(); + }); + } +} diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index e996cbd3c1a0..461c7b9af6e9 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -459,12 +459,15 @@ function update_application($app, $response, $metrics = [], $status = '') ]; if ($response != '' && $response !== false) { + // if the response indicates an error, set it and set app_status to the raw response if (Str::contains($response, [ 'Traceback (most recent call last):', ])) { $data['app_state'] = 'ERROR'; - } elseif (in_array($response, ['OK', 'ERROR', 'LEGACY', 'UNSUPPORTED'])) { - $data['app_state'] = $response; + $data['app_status'] = $response; + } elseif (preg_match('/^(ERROR|LEGACY|UNSUPPORTED)/', $response, $matches)) { + $data['app_state'] = $matches[1]; + $data['app_status'] = $response; } else { // should maybe be 'unknown' as state $data['app_state'] = 'OK'; diff --git a/misc/alert_rules.json b/misc/alert_rules.json index e0c19dc35b7e..f0127320fe9b 100644 --- a/misc/alert_rules.json +++ b/misc/alert_rules.json @@ -527,5 +527,10 @@ "rule": "applications.app_type = \"suricata\" && application_metrics.metric = \".total_error_delta\" && application_metrics.value >= \"2\"", "name": "Suricata Packet Error >= 2%", "severity": "critical" + }, + { + "rule": "applications.app_type = \"mysql\" && applications.app_state != \"OK\"", + "name": "MySQL Server not responding", + "severity":"critical" } ] diff --git a/misc/db_schema.yaml b/misc/db_schema.yaml index dd4d12285817..0b8f3b4ed3b9 100644 --- a/misc/db_schema.yaml +++ b/misc/db_schema.yaml @@ -168,7 +168,7 @@ applications: - { Field: app_state, Type: varchar(32), 'Null': false, Extra: '', Default: UNKNOWN } - { Field: discovered, Type: tinyint, 'Null': false, Extra: '', Default: '0' } - { Field: app_state_prev, Type: varchar(32), 'Null': true, Extra: '' } - - { Field: app_status, Type: varchar(8), 'Null': false, Extra: '' } + - { Field: app_status, Type: varchar(1024), 'Null': false, Extra: '' } - { Field: timestamp, Type: timestamp, 'Null': false, Extra: 'on update CURRENT_TIMESTAMP', Default: CURRENT_TIMESTAMP } - { Field: app_instance, Type: varchar(255), 'Null': false, Extra: '' } Indexes: