Event

Represents NetXMS event object.

Instance attributes

code: int

Event code

customMessage: String

Custom message, set by an event processing policy rule filter script through the global variable CUSTOM_MESSAGE or by assigning this attribute. Available in macros as %M. Deprecated and will be removed in a future version.

dci: DCI

DCI object of class DCI that is source for this event or NULL if generated not by threshold

dciId: int

DCI id that is source for this event or 0 if generated not by threshold

id: int64

Unique event identifier.

lastAlarmId: int

ID of the last alarm associated with this event, or 0 if none.

Added in version 6.0

lastAlarmKey: String

Key for last generated alarm for this event or null.

Added in version 6.0

lastAlarmMessage: String

Message of the last alarm associated with this event, or null if none.

Added in version 6.0

message: String

Event message. Get/set attribute.

name: String

Event name.

origin: int

Origin of the event. See EventOrigin constants for named constants.

  • 0 - SYSTEM

  • 1 - AGENT

  • 2 - CLIENT

  • 3 - SYSLOG

  • 4 - SNMP

  • 5 - NXSL

  • 6 - REMOTE_SERVER

  • 7 - WINDOWS_EVENT

  • 8 - OPENTELEMETRY

originTimestamp: int

Unix timestamp of the time when the event was generated in the origin.

parameters: Array

List of event parameters. Starting index is 1.

parameterNames: Array

List of named event parameters (e.g. "dciId"), which can be accessed by object.parameterName.

rootId: int64

Id of event that is root cause of this event or 0 if there is no such event.

severity: int

Event severity code. Get/set attribute; values outside the 0–4 range are ignored on assignment.

source: NetObj

Source object (inherited from NetObj, exact type can be checked with classof function) for the event.

sourceId: int

ID of the source object for the event.

tags: Array

Event tags as an array of strings.

tagList: String

Event tags as a comma separated list.

timestamp: int

Unix timestamp of the event.

$1…$n

Shortcut for parameters[n] (e.g. "$event.parameters[3]" can be replaced with "$event.$3").

$…

Named event parameters can be accessed directly by the name (e.g $event.dciId). List of available named parameters can be accessed with parameterNames attribute. Get/set attribute.

Instance methods

addParameter(name, value): void

Append new parameter to the event

Table 1. Parameters

name

String

Parameter name. Optional; if the method is called with one argument, that argument is the value and the parameter is added without a name.

value

String

Parameter value.

addTag(tag): void

Set event tag, which can be later accessed via tags attribute.

Table 2. Parameters

tag

String tag

correlateTo(eventId): void

Sets root cause id for the event

Table 3. Parameters

eventId

Root cause event id

expandString(string): String

Expand string by replacing macros with their values.

Table 4. Parameters

string

String to expand

Return

Formated string

>>> $event.expandString("%N")
SYS_THRESHOLD_REACHED
getParameter(name): String

Get parameter value by name or by index. Unlike $1…$n, parameters and setParameter(), a numeric index here is zero-based: getParameter(0) returns the first parameter.

Table 5. Parameters

name

Parameter name (String) or zero-based index (Integer)

Return

Parameter value or null

hasTag(tag): bool

Return if event has specific tag.

Table 6. Parameters

tag

String tag

removeTag(tag): void

Remove tag from event tag list

Table 7. Parameters

tag

String tag

setMessage(message): void

Set event message to message.

Table 8. Parameters

message

Message string

setNamedParameter(name, value): void

Set named parameter or change value of existing named parameter

Table 9. Parameters

name

String name of parameter

value

String value of parameter

setParameter(index, value): void

Set value of parameter or change value of existing parameter. If index corresponds to existing parameter, the value will be set. If index is higher then existing number of parameters, new parameter(s) will be added (if needed, parameters with empty values will be added to reach the number of parameters indicated by index).

Table 10. Parameters

index

Integer index of parameter, starting from 1

value

String value of parameter

setSeverity(severityCode): void

Change event severity to severityCode.

Table 11. Parameters

severityCode

Numeric severity code. Values outside the 0–4 range are ignored.

toJson(): String

Serialize object to JSON.

Return

String representation of the object in JSON format.