Index | About | Me | Jump to Menu Section

Malleable Checker

Last modified: Sat Jun 04 2022 10:23:43 GMT+0000 (Coordinated Universal Time)

Source Code:

Current status:

Overview

How it works?

For example, with the following datasource:

// Data source id = 32, name = 'users_with_email_null'
SELECT username from users where email is null;

You can create a new rule:

CheckerCase().assertLessThan(datasets['users_with_email_null'], 
42,
'There should be less than 42 users in that state') # Otherwise we are going to alarm

The interesting bits is that you can use Python code for it, so you could define your own helpers and write things like:


if bussiness_day():
CheckerCase().assertLessThan(datasets['users_with_email_null'], 42, 'There should be less than 42 users in that state')
else:
CheckerCase().assertLessThan(datasets['users_with_email_null'], 5, 'There should be less than 5 users in that state')

This is executed hourly by a cron job, if the assertion throws an exception an Alarm will be fired. After the alarm is fired an action is triggered as defined by the user (email, slack, page).

After saved, the alarm has two values red and green. Red means the checker failed and the alarm was triggered. Green means everything is ok.

flowchart TD
    CheckerScheduler -->|every 5 minutes| FetchDataSources
    FetchDataSources --> EvaluateRules
    EvaluateRules --> RunAssertions{Assertion Failed?}
    RunAssertions --> |False| SaveGreenState
    RunAssertions --> |True| TriggerAlarm
    TriggerAlarm --> |Send Message to a queue so user can consume and trigger other actions| MessageQueue
    TriggerAlarm --> SaveRedState

On Images

Basically, you type your SQL query:

Then you can either use the advanced option and write the rule in python or use a normal HTML form to create the rule: