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

[Backport 2.11] changes to add start_time and end_time filters to getAlertsRequest #1553

Merged
merged 1 commit into from
May 22, 2024
Merged
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 @@ -37,6 +37,7 @@ import org.opensearch.commons.alerting.model.ScheduledJob
import org.opensearch.commons.authuser.User
import org.opensearch.commons.utils.recreateObject
import org.opensearch.core.action.ActionListener
import org.opensearch.core.common.io.stream.NamedWriteableRegistry
import org.opensearch.core.xcontent.NamedXContentRegistry
import org.opensearch.core.xcontent.XContentParser
import org.opensearch.core.xcontent.XContentParserUtils
Expand All @@ -60,6 +61,7 @@ class TransportGetAlertsAction @Inject constructor(
actionFilters: ActionFilters,
val settings: Settings,
val xContentRegistry: NamedXContentRegistry,
val namedWriteableRegistry: NamedWriteableRegistry
) : HandledTransportAction<ActionRequest, GetAlertsResponse>(
AlertingActions.GET_ALERTS_ACTION_NAME,
transportService,
Expand All @@ -81,7 +83,7 @@ class TransportGetAlertsAction @Inject constructor(
actionListener: ActionListener<GetAlertsResponse>,
) {
val getAlertsRequest = request as? GetAlertsRequest
?: recreateObject(request) { GetAlertsRequest(it) }
?: recreateObject(request, namedWriteableRegistry) { GetAlertsRequest(it) }
val user = readUserFromThreadContext(client)

val tableProp = getAlertsRequest.table
Expand All @@ -92,7 +94,7 @@ class TransportGetAlertsAction @Inject constructor(
sortBuilder.missing(tableProp.missing)
}

val queryBuilder = QueryBuilders.boolQuery()
val queryBuilder = getAlertsRequest.boolQueryBuilder ?: QueryBuilders.boolQuery()

if (getAlertsRequest.severityLevel != "ALL") {
queryBuilder.filter(QueryBuilders.termQuery("severity", getAlertsRequest.severityLevel))
Expand Down
Loading