From 6f1d9b74113c9ddde07f59a10dbf2cc5cdb8bf8a Mon Sep 17 00:00:00 2001 From: Annie Lee Date: Fri, 11 Mar 2022 16:35:35 -0800 Subject: [PATCH] Add logs and try to add routes Signed-off-by: Annie Lee --- .../alerting/resthandler/RestGetFindingsSearchAction.kt | 9 ++++++++- .../transport/TransportGetFindingsSearchAction.kt | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/resthandler/RestGetFindingsSearchAction.kt b/alerting/src/main/kotlin/org/opensearch/alerting/resthandler/RestGetFindingsSearchAction.kt index ed1624caf..1b653e7c8 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/resthandler/RestGetFindingsSearchAction.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/resthandler/RestGetFindingsSearchAction.kt @@ -6,6 +6,7 @@ package org.opensearch.alerting.resthandler import org.apache.logging.log4j.LogManager +import org.opensearch.alerting.AlertingPlugin import org.opensearch.alerting.action.GetFindingsSearchAction import org.opensearch.alerting.action.GetFindingsSearchRequest import org.opensearch.alerting.model.Table @@ -13,8 +14,11 @@ import org.opensearch.alerting.util.context import org.opensearch.client.node.NodeClient import org.opensearch.rest.BaseRestHandler import org.opensearch.rest.BaseRestHandler.RestChannelConsumer +import org.opensearch.rest.RestHandler import org.opensearch.rest.RestHandler.Route import org.opensearch.rest.RestRequest +import org.opensearch.rest.RestRequest.Method.GET +import org.opensearch.rest.RestRequest.Method.POST import org.opensearch.rest.action.RestActions import org.opensearch.rest.action.RestToXContentListener import org.opensearch.search.fetch.subphase.FetchSourceContext @@ -31,7 +35,10 @@ class RestGetFindingsSearchAction : BaseRestHandler() { } override fun routes(): List { - return listOf() + return listOf( + Route(POST, "${AlertingPlugin.FINDING_BASE_URI}/_search"), + Route(GET, "${AlertingPlugin.MONITOR_BASE_URI}/_search") + ) } override fun prepareRequest(request: RestRequest, client: NodeClient): RestChannelConsumer { diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetFindingsSearchAction.kt b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetFindingsSearchAction.kt index 3cc9bc17f..fcc94b9c7 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetFindingsSearchAction.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetFindingsSearchAction.kt @@ -112,6 +112,7 @@ class TransportGetFindingsSearchAction @Inject constructor( actionListener: ActionListener, user: User? ) { + log.info("Entering RestGetFindingsSearchAction.kt.") if (user == null) { // user is null when: 1/ security is disabled. 2/when user is super-admin. search(searchSourceBuilder, actionListener) @@ -131,6 +132,7 @@ class TransportGetFindingsSearchAction @Inject constructor( } fun search(searchSourceBuilder: SearchSourceBuilder, actionListener: ActionListener) { + log.info("Entering RestGetFindingsSearchAction.kt.") val searchRequest = SearchRequest() .source(searchSourceBuilder) .indices(".opensearch-alerting-findings")