NicolasLM / sauna

Lightweight daemon that runs and reports health checks
https://sauna.readthedocs.io
BSD 2-Clause "Simplified" License
18 stars 10 forks source link

PGSQL Query based alert #43

Closed wayt closed 6 years ago

wayt commented 8 years ago

I was wondering how to implement alerts based on a PostgreSQL query. My need here is to trigger a critical status if I have an entry older than XXX in my database.

Would a PostgresSQL plugin with custom query support be relevant ? Or is it too specific, and I should use the command plugin ?

bewiwi commented 8 years ago

I think your need is specific but you can create a generic check that something with a conf like this:

  - type: SqlCheck
    checks:
      - type: IntQueries
        sql: SELECT 1
        warn: 2
        crit: 4
      - type: StringQueries
        sql: SELECT 'OK'
        result: 'OK'
      [...]
    config:
        connection: psql://user@password.......

In all case you can create a python plugin and import check even if not in this repo, just use extra_plugin -> https://sauna.readthedocs.io/en/latest/dev/custom.html#custom

wayt commented 8 years ago

yep, that's what I had in mind. I'll take a look on how to implement an sql plugin

NicolasLM commented 8 years ago

I agree with @bewiwi, I'm unsure how to deal with different databases though since they can require different drivers. Anyway if would be a great addition to the list of plugins.