Heka Alert Module

Sends alert messages for consumption by the alert output sandbox.

Plugins that make use of this module require a valid alert configuration.

At a high level there are two modes of operation for this module, static alerting and alerting with a lookup module. The mode of operation is dependent on if the lookup configuration parameter is set, and the sub-modules specified in the modules configuration.

Static operating mode will always send alerts to the same destination. This mode is useful if a plugin does not need to modify a destination for an alert. Static operating mode is set by not setting a lookup plugin, and by specifying the required Heka alert modules in the modules configuration.

If the lookup parameter is set, it should be set to the name of a valid alerting lookup module. In this mode, the get_message function of the lookup plugin will be called with lookup data, and the lookup plugin will make a decision on where to route the alert and return an alert message for submission. In lookup mode, the modules configuration should include only a configuration for the desired lookup module.

1. Lookup Data

When using a lookup module, the plugin calling the alert.send function needs to provide lookup data for the lookup plugin to make a decision on alert routing.

-- example lookup data
local ldata = {
    sendglobal = true,      -- The alert should be sent to a global alerting destination (nil/false for off)
    senderror  = false,     -- Don't send the alert to any error destination (nil/false for off)
    senduser   = true,      -- The alert should be sent directly to the identity (nil/false for off)
    subject    = "userid"   -- This alert is for this specific identity (nil for none)
}
-- send the alert, specifying our lookup data
alert.send("myalert", subject, payload, 0, ldata)

Any combination of parameters is valid and it is up to the configured lookup module to determine how to route the alert.

2. Sample Configuration

alert = {
    lookup   = nil,   -- optional, if specified a string indicating a heka alerting lookup module
    disabled = false, -- optional
    prefix   = false, -- optional prefix plugin information to the summary and detail strings
    throttle = 90,    -- optional number of minutes to wait before another alert with this ID will be sent
    modules  = {
      -- module_name = {}, -- see the heka.alert.modules_name documentation for the configuration options
      -- e.g., email = {recipients = {"foo@example.com"}},
    }
    thresholds = {
      -- alert_id = {}, -- per id alert specific configuration for an analyis plugin
    }
}

3. Variables

  • thresholds - the thresholds configuration table

4. Functions

4.1. get_dashboard_uri

Returns the URI of the dashboard output

Arguments

  • id (string)
  • extension (string/nil) - defaults to cbuf

Return

  • URI (string)

4.2. get_threshold

Gets the value of the threshold setting associated with the specified id. If the id is not found the value of the '*' key is returned otherwise nil is returned.

Arguments

  • id (string)

Return

  • threshold - configuration value

4.3. throttled

Check if an alert is currently throttled, this is useful to avoid running expensive tests.

Arguments

  • id (string)
  • throttle (integer, nil) - override the throttle value (nil uses the configured value)

Return

  • throttled (boolean) - true if the alert is currently throttled

4.4. has_lookup

Return true if the alert module has a lookup function associated with it.

Arguments

  • None

Return

  • func (boolean) - true if alert module has lookup function

4.5. send

Send an alert message

Arguments

  • id (string) - unique id for alert throttling
  • summary (string) - alert summary
  • detail (string) - alert detail
  • throttle (integer, nil) - override the throttle value (nil for configured, 0 for none)
  • ldata (table, nil) - lookup data table, used if module is in lookup mode

Return

  • sent (boolean) - true if sent, false if throttled/disabled/empty

source code: alert.lua

results matching ""

    No results matching ""