public Event(String tenantId, String id, long ctime, String dataSource, String dataId, String category, String text, Map<String, String> context, Map<String, String> tags) { this.tenantId = tenantId; this.id = id; setCtime(ctime); setDataSource(dataSource); this.dataId = dataId; this.category = category; this.text = text; this.context = context; this.tags = tags; this.eventType = EventType.EVENT.name(); }
@Override public String toString() { return "Alert [tenantId=" + tenantId + ", triggerId=" + getTriggerId() + ", severity=" + severity + ", status=" + status + ", ctime=" + ctime + ", lifecycle=" + lifecycle + ", resolvedEvalSets=" + resolvedEvalSets + "]"; }
public static EventField fromString(String name) { for (EventField field : EventField.values()) { if (field.equalsName(name)) { return field; } } return null; }
public Alert(Alert alert) { super((Event) alert); this.status = alert.getStatus(); this.severity = alert.getSeverity(); this.eventType = alert.getEventType(); this.lifecycle = new ArrayList<>(); for (LifeCycle item : alert.getLifecycle()) { this.lifecycle.add(new LifeCycle(item)); } for (Note note : alert.getNotes()) { this.notes.add(note); } this.resolvedEvalSets = alert.getResolvedEvalSets(); }
/** * Convenience constructor for an Alerting Event. * @param alert the Non-Thin Alert, it must be fully defined. */ public Event(Alert alert) { this(alert.getTenantId(), alert.getTrigger(), alert.getDampening(), alert.getEvalSets()); this.eventType = alert.getEventType(); }
@JsonIgnore public Long getLastStatusTime(Status status) { if (getLifecycle().isEmpty()) { return null; } Long statusTime = null; ListIterator<LifeCycle> iterator = getLifecycle().listIterator(getLifecycle().size()); while (iterator.hasPrevious()) { LifeCycle lifeCycle = iterator.previous(); if (lifeCycle.getStatus().equals(status)) { statusTime = lifeCycle.getStime(); break; } } return statusTime; }
public void addLifecycle(Status status, String user, long stime) { if (status == null || user == null) { throw new IllegalArgumentException("Lifecycle must have non-null state and user"); } setStatus(status); getLifecycle().add(new LifeCycle(status, user, stime)); }
public ExternalConditionEval(ExternalCondition condition, Event event) { super(Type.EXTERNAL, condition.match(event.getText()), event.getCtime(), event.getContext()); this.condition = condition; this.event = event; }
/** * Add a note on this alert * * @param user author of the comment * @param text content of the note */ public void addNote(String user, String text) { if (user == null || text == null) { throw new IllegalArgumentException("Note must have non-null user and text"); } getNotes().add(new Note(user, text)); }
public Alert(String tenantId, Trigger trigger, Dampening dampening, List<Set<ConditionEval>> evalSets) { super(tenantId, trigger, dampening, evalSets); this.status = Status.OPEN; this.severity = trigger.getSeverity(); this.eventType = EventType.ALERT.name(); addLifecycle(this.status, "system", this.ctime); }
public EventConditionEval(EventCondition condition, Event value) { super(Type.EVENT, condition.match(value), value.getCtime(), value.getContext()); this.condition = condition; this.value = value; }
@JsonIgnore public Long getLastAckTime() { return getLastStatusTime(Status.ACKNOWLEDGED); }
public Alert() { // for json assembly this.eventType = EventType.ALERT.name(); this.status = Status.OPEN; }
@Override public int hashCode() { int result = user != null ? user.hashCode() : 0; result = 31 * result + (status != null ? status.hashCode() : 0); result = 31 * result + (int) (stime ^ (stime >>> 32)); return result; }
public Action(String tenantId, String actionPlugin, String actionId, Event event) { super(tenantId, actionPlugin, actionId); this.event = event; if (event != null) { this.eventId = event.getId(); } this.ctime = System.currentTimeMillis(); }
public void removeTag(String name) { if (null == name) { throw new IllegalArgumentException("Tag must have non-null name"); } getTags().remove(name); }
@JsonIgnore public Long getLastOpenTime() { return getLastStatusTime(Status.OPEN); }
@Override public String toString() { return "Trigger [tenantId=" + tenantId + ", id=" + id + ", type=" + type.name() + ", eventType=" + eventType.name() + ", name=" + name + ", description=" + description + ", eventCategory=" + eventCategory + ", eventText=" + eventText + ", severity=" + severity + ", context=" + context + ", actions=" + actions + ", autoDisable=" + autoDisable + ", autoEnable=" + autoEnable + ", autoResolve=" + autoResolve + ", autoResolveAlerts=" + autoResolveAlerts + ", autoResolveMatch=" + autoResolveMatch + ", memberOf=" + memberOf + ", dataIdMap=" + dataIdMap + ", enabled=" + enabled + ", firingMatch=" + firingMatch + ", mode=" + mode + ", tags=" + tags + "]"; }
@JsonIgnore public Long getLastResolvedTime() { return getLastStatusTime(Status.RESOLVED); }