Skip to content

Commit

Permalink
adds audit state in Alert (#461)
Browse files Browse the repository at this point in the history
Signed-off-by: Surya Sashank Nistala <[email protected]>
  • Loading branch information
eirsep authored Jun 21, 2023
1 parent fcb853e commit f1c0f1d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,12 @@ data class Alert(
)

enum class State {
ACTIVE, ACKNOWLEDGED, COMPLETED, ERROR, DELETED
ACTIVE, ACKNOWLEDGED, COMPLETED, ERROR, DELETED,
// Alerts are created in audit state when they are generated by delegate monitors of a workflow.
// since chained alerts can be configured and acknowledged, the underlying monitors' alerts are simply
// for evaluating chained alert triggers and auditing purpose.
// Audit state alerts will be created in the history index and do not need to be acknowledged by users.
AUDIT
}

@Throws(IOException::class)
Expand Down
12 changes: 11 additions & 1 deletion src/test/kotlin/org/opensearch/commons/alerting/AlertTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.opensearch.commons.alerting.model.Alert
import kotlin.test.assertTrue
import java.time.Instant
import java.time.temporal.ChronoUnit

class AlertTests {
@Test
Expand Down Expand Up @@ -60,6 +61,15 @@ class AlertTests {
Assertions.assertFalse(activeAlert.isAcknowledged(), "Alert is acknowledged")
}

@Test
fun `test alert in audit state`() {
val auditAlert = Alert(
randomQueryLevelMonitor(), randomQueryLevelTrigger(), Instant.now().truncatedTo(ChronoUnit.MILLIS),
null, actionExecutionResults = listOf(randomActionExecutionResult())
)
Assertions.assertFalse(auditAlert.isAcknowledged(), "Alert should not be in acknowledged state")
}

@Test
fun `test chained alert`() {
val workflow = randomWorkflow()
Expand Down

0 comments on commit f1c0f1d

Please sign in to comment.