flexmeasures.cli.monitor

CLI commands for monitoring functionality.

Functions

flexmeasures.cli.monitor.automation_page_url(automation) → str | None

Link to the Automations page of the automation’s asset, opening that automation’s info, if the server knows its own address.

flexmeasures.cli.monitor.compose_automation_digest(failures: list[AutomationFailures], stuck_after: timedelta, for_host: bool = True) → tuple[str, str]

Return the subject and body of a digest about these failed automations.

Parameters:

for_host – Whether the digest goes to the host, who can check the logs, rather than to a user of the assets’ organisations.

flexmeasures.cli.monitor.describe_automation_failures(failures: AutomationFailures) → str

Describe the failed runs of one automation in a few lines, for the monitoring digest.

flexmeasures.cli.monitor.get_absent_users(last_seen_delta: timedelta, account_ids: list[int], client_account_ids: list[int] | None = None, account_role: str | None = None, user_role: str | None = None) → list[User]

Get users whose last contact is too old, narrowed down by account and role filters.

flexmeasures.cli.monitor.get_default_monitoring_email_recipients()
flexmeasures.cli.monitor.get_monitoring_email_recipients(recipients: tuple[str, ...] = ()) → list[str]
flexmeasures.cli.monitor.send_automation_digests_to_users(failures: list[AutomationFailures], stuck_after: timedelta)

Email each account admin and consultant a digest of the failed automations they may read.

The runs are already marked as reported, so a digest that cannot be sent is logged rather than tried again.

flexmeasures.cli.monitor.send_lastseen_monitoring_alert(users: list[User], last_seen_delta: timedelta, alerted_users: bool, account_ids: list[int] | None = None, client_account_ids: list[int] | None = None, consultant_account_id: int | None = None, account_role: str | None = None, user_role: str | None = None, txt_about_already_alerted_users: str = '', email_recipients: list[str] | None = None)

Tell monitoring recipients and Sentry about user(s) we haven’t seen in a while.

flexmeasures.cli.monitor.send_task_monitoring_alert(task_name: str, msg: str, latest_run: LatestTaskRun | None = None, custom_msg: str | None = None, email_recipients: list[str] | None = None)

Send any monitoring message per Sentry and per email. Also log an error.