Flecs: Alerts
Description: A fast entity component system (ECS) for C & C++

| Flecs v4.0 A fast entity component system (ECS) for C & C++

Loading...
Searching...
No Matches
Alerts
C API » Addons

Create alerts from monitoring queries. More...

Collaboration diagram for Alerts:

## Classes
struct | EcsAlertInstance
| Component added to alert instance. More...
struct | EcsAlertsActive
| Map with active alerts for entity. More...
struct | ecs_alert_severity_filter_t
| Alert severity filter. More...
struct | ecs_alert_desc_t
| Alert descriptor, used with ecs_alert_init(). More...

## Macros
#define | ECS_ALERT_MAX_SEVERITY_FILTERS (4)
#define | ecs_alert(world, ...)
| Create a new alert.

## Typedefs
typedef struct EcsAlertInstance | EcsAlertInstance
| Component added to alert instance.
typedef struct EcsAlertsActive | EcsAlertsActive
| Map with active alerts for entity.
typedef struct ecs_alert_severity_filter_t | ecs_alert_severity_filter_t
| Alert severity filter.
typedef struct ecs_alert_desc_t | ecs_alert_desc_t
| Alert descriptor, used with ecs_alert_init().

## Functions
FLECS_API | ECS_COMPONENT_DECLARE (FlecsAlerts)
| Module id.
FLECS_API | ECS_COMPONENT_DECLARE (EcsAlert)
| Component added to alert, and used as first element of alert severity pair.
FLECS_API | ECS_COMPONENT_DECLARE (EcsAlertInstance)
| Component added to alert instance.
FLECS_API | ECS_COMPONENT_DECLARE (EcsAlertsActive)
| Component added to alert source which tracks how many active alerts there are.
FLECS_API | ECS_COMPONENT_DECLARE (EcsAlertTimeout)
| Component added to alert which tracks how long an alert has been inactive.
FLECS_API | ECS_TAG_DECLARE (EcsAlertInfo)
| Info alert severity.
FLECS_API | ECS_TAG_DECLARE (EcsAlertWarning)
| Warning alert severity.
FLECS_API | ECS_TAG_DECLARE (EcsAlertError)
| Error alert severity.
FLECS_API | ECS_TAG_DECLARE (EcsAlertCritical)
| Critical alert severity.
FLECS_API ecs_entity_t | ecs_alert_init (ecs_world_t *world, const ecs_alert_desc_t *desc)
| Create a new alert.
FLECS_API int32_t | ecs_get_alert_count (const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t alert)
| Return number of active alerts for entity.
FLECS_API ecs_entity_t | ecs_get_alert (const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t alert)
| Return alert instance for specified alert.
FLECS_API void | FlecsAlertsImport (ecs_world_t *world)
| Alert module import function.

## Detailed Description

Create alerts from monitoring queries.

## Macro Definition Documentation

## ◆ ecs_alert

#define ecs_alert | ( |  | world,
|  |  | ... )

Value:
ecs_alert_init(world, &(ecs_alert_desc_t)__VA_ARGS__)
ecs_alert_init
FLECS_API ecs_entity_t ecs_alert_init(ecs_world_t *world, const ecs_alert_desc_t *desc)
Create a new alert.
ecs_alert_desc_t
Alert descriptor, used with ecs_alert_init().
Definition alerts.h:77

Create a new alert.

See also
  ecs_alert_init()

Definition at line 168 of file alerts.h.

## ◆ ECS_ALERT_MAX_SEVERITY_FILTERS

#define ECS_ALERT_MAX_SEVERITY_FILTERS (4)

Definition at line 31 of file alerts.h.

## Typedef Documentation

## ◆ ecs_alert_severity_filter_t

typedef struct ecs_alert_severity_filter_t ecs_alert_severity_filter_t

Alert severity filter.

A severity filter can adjust the severity of an alert based on whether an entity in the alert query has a specific component. For example, a filter could check if an entity has the "Production" tag, and increase the default severity of an alert from Warning to Error.

## Function Documentation

## ◆ ecs_alert_init()

FLECS_API ecs_entity_t ecs_alert_init | ( | ecs_world_t * | world,
|  | const ecs_alert_desc_t * | desc )

Create a new alert.

An alert is a query that is evaluated periodically and creates alert instances for each entity that matches the query. Alerts can be used to automate detection of errors in an application.

Alerts are automatically cleared when a query is no longer true for an alert instance. At most one alert instance will be created per matched entity.

Alert instances have three components:

- AlertInstance: contains the alert message for the instance
- MetricSource: contains the entity that triggered the alert
- MetricValue: contains how long the alert has been active

Alerts reuse components from the metrics addon so that alert instances can be tracked and discovered as metrics. Just like metrics, alert instances are created as children of the alert.

When an entity has active alerts, it will have the EcsAlertsActive component which contains a map with active alerts for the entity. This component will be automatically removed once all alerts are cleared for the entity.

Parameters

  world | The world.
  desc | Alert description.

Returns
  The alert entity.

## ◆ ecs_get_alert()

FLECS_API ecs_entity_t ecs_get_alert | ( | const ecs_world_t * | world,
|  | ecs_entity_t | entity,
|  | ecs_entity_t | alert )

Return alert instance for specified alert.

This operation returns the alert instance for the specified alert. If the alert is not active for the entity, the operation will return 0.

Parameters

  world | The world.
  entity | The entity.
  alert | The alert to test for.

Returns
  The alert instance for the specified alert.

## ◆ ecs_get_alert_count()

FLECS_API int32_t ecs_get_alert_count | ( | const ecs_world_t * | world,
|  | ecs_entity_t | entity,
|  | ecs_entity_t | alert )

Return number of active alerts for entity.

When a valid alert entity is specified for the alert parameter, the operation will return whether the specified alert is active for the entity. When no alert is specified, the operation will return the total number of active alerts for the entity.

Parameters

  world | The world.
  entity | The entity.
  alert | The alert to test for (optional).

Returns
  The number of active alerts for the entity.

## ◆ FlecsAlertsImport()

FLECS_API void FlecsAlertsImport | ( | ecs_world_t * | world | ) |

Alert module import function.

Usage:

ECS_IMPORT(world, FlecsAlerts)
ECS_IMPORT
#define ECS_IMPORT(world, id)
Wrapper around ecs_import().
Definition module.h:119

Parameters

  world | The world.