Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(apps/mysql): add error-state to non-responsive mysql-servers #13993

Merged
merged 12 commits into from Jun 10, 2022
Merged
32 changes: 32 additions & 0 deletions database/migrations/2022_05_30_084932_update-app-status-length.php
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class UpdateAppStatusLength extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('applications', function (Blueprint $table) {
$table->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();
});
}
}
7 changes: 5 additions & 2 deletions includes/polling/functions.inc.php
Expand Up @@ -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';
Expand Down
5 changes: 5 additions & 0 deletions misc/alert_rules.json
Expand Up @@ -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\"",
murrant marked this conversation as resolved.
Show resolved Hide resolved
"name": "MySQL Server not responding",
"severity":"critical"
}
]
2 changes: 1 addition & 1 deletion misc/db_schema.yaml
Expand Up @@ -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:
Expand Down