Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds audit state in Alert #461

Merged
merged 1 commit into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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