N
N
Nikita Reshetnyak2021-04-20 07:17:15
elasticsearch
Nikita Reshetnyak, 2021-04-20 07:17:15

Is there a rule somewhere for elastalert to monitor postgres?

Good day! Tell me if it is possible to make a request to postgres with tlastalert, something like SELECT * FROM table LIMIT 1 to know if the database is alive, maybe someone has a rule, thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikita Reshetnyak, 2021-04-21
@nreshetnyak

The problem was that the flatline type rules are triggered when the threshold value is passed. That is, if at the time of adding or updating the elastalert rule, the number of documents was already below the threshold parameter, then the alert will not be sent.
Working example below

es_host: <ELASTIC HOST>
es_port: 9200
# es_username: elastic
# es_password: changeme

name: ":warning:WARNING : POSTGRES probably unavailable:warning:"
description: "postgres probably unavailable"
severity: "warning"

index: app-prod-metrics*

filter: 
- query:
    query_string:
      query: "postgresql.activity.query: \"SELECT * FROM pg_stat_database\""

type: flatline
threshold: 4
timeframe:
  minutes: 1
realert:
  seconds: 10

query_key: postgresql.activity.query

alert:
- "telegram"
alert_text: "
Too few metrics from\n
*Postgres on Host*   : host name\n
*ElastAlert Node*    : alert host name"
alert_text_type: alert_text_only

telegram_bot_token: <TOKEN>
telegram_room_id: "@<CHAT_ID>"

D
Dmitry, 2021-04-20
@q2digger

what is the postgres request? it's not his job..
elastalert's job is to keep track of the elastic index and work when something is found *in the index*.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question