Skip to content

Commit 6e33100

Browse files
committed
change log level to debug logs
Signed-off-by: Surya Sashank Nistala <[email protected]>
1 parent 23409e8 commit 6e33100

File tree

3 files changed

+29
-29
lines changed

3 files changed

+29
-29
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ dependencies {
158158
implementation group: 'org.apache.commons', name: 'commons-lang3', version: "${versions.commonslang}"
159159
implementation "org.antlr:antlr4-runtime:4.10.1"
160160
implementation "com.cronutils:cron-utils:9.1.6"
161-
api files("/Users/snistala/Documents/opensearch/common-utils/build/libs/common-utils-3.0.0.0-SNAPSHOT.jar")
161+
api "org.opensearch:common-utils:${common_utils_version}@jar"
162162
api "org.opensearch.client:opensearch-rest-client:${opensearch_version}"
163163
implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"
164164
compileOnly "org.opensearch:opensearch-job-scheduler-spi:${opensearch_build}"

src/main/java/org/opensearch/securityanalytics/mapper/MapperService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void onResponse(GetMappingsResponse getMappingsResponse) {
9494
applyAliasMappings(getMappingsResponse.getMappings(), logType, aliasMappings, partial, new ActionListener<>() {
9595
@Override
9696
public void onResponse(Collection<CreateMappingResult> createMappingResponse) {
97-
log.error("PERF_DEBUG_SAP: Completed create mappings for {}", indexName);
97+
log.debug(Completed create mappings for {}", indexName);
9898
// We will return ack==false if one of the requests returned that
9999
// else return ack==true
100100
Optional<AcknowledgedResponse> notAckd = createMappingResponse.stream()
@@ -113,7 +113,7 @@ public void onResponse(Collection<CreateMappingResult> createMappingResponse) {
113113
114114
@Override
115115
public void onFailure(Exception e) {
116-
log.error("PERF_DEBUG_SAP: Failed to create mappings for {}", indexName );
116+
log.debug(Failed to create mappings for {}", indexName );
117117
actionListener.onFailure(e);
118118
}
119119
});

src/main/java/org/opensearch/securityanalytics/transport/TransportIndexDetectorAction.java

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -222,22 +222,22 @@ private void checkIndicesAndExecute(
222222
ActionListener<IndexDetectorResponse> listener,
223223
User user
224224
) {
225-
log.error("PERF_DEBUG_SAP: check indices and execute began");
225+
log.debug(check indices and execute began");
226226
String [] detectorIndices = request.getDetector().getInputs().stream().flatMap(detectorInput -> detectorInput.getIndices().stream()).toArray(String[]::new);
227227
SearchRequest searchRequest = new SearchRequest(detectorIndices)
228228
.source(SearchSourceBuilder.searchSource().size(1).query(QueryBuilders.matchAllQuery()));
229229
searchRequest.setCancelAfterTimeInterval(TimeValue.timeValueSeconds(30));
230230
client.search(searchRequest, new ActionListener<>() {
231231
@Override
232232
public void onResponse(SearchResponse searchResponse) {
233-
log.error("PERF_DEBUG_SAP: check indices and execute completed. Took {} millis", searchResponse.getTook().millis());
233+
log.debug(check indices and execute completed. Took {} millis", searchResponse.getTook().millis());
234234
AsyncIndexDetectorsAction asyncAction = new AsyncIndexDetectorsAction(user, task, request, listener);
235235
asyncAction.start();
236236
}
237237

238238
@Override
239239
public void onFailure(Exception e) {
240-
log.error("PERF_DEBUG_SAP: check indices and execute failed", e);
240+
log.debug(check indices and execute failed", e);
241241
if (e instanceof OpenSearchStatusException) {
242242
listener.onFailure(SecurityAnalyticsException.wrap(
243243
new OpenSearchStatusException(String.format(Locale.getDefault(), "User doesn't have read permissions for one or more configured index %s", detectorIndices), RestStatus.FORBIDDEN)
@@ -275,7 +275,7 @@ public void onResponse(List<DocLevelQuery> dlqs) {
275275
StepListener<List<IndexMonitorRequest>> bucketLevelMonitorRequests = new StepListener<>();
276276
buildBucketLevelMonitorRequests(bucketLevelRules, detector, refreshPolicy, Monitor.NO_ID, Method.POST, bucketLevelMonitorRequests);
277277
bucketLevelMonitorRequests.whenComplete(indexMonitorRequests -> {
278-
log.error("PERF_DEBUG_SAP: bucket level monitor request built");
278+
log.debug(bucket level monitor request built");
279279
monitorRequests.addAll(indexMonitorRequests);
280280
// Do nothing if detector doesn't have any monitor
281281
if (monitorRequests.isEmpty()) {
@@ -290,7 +290,7 @@ public void onResponse(List<DocLevelQuery> dlqs) {
290290
// https://github.com/opensearch-project/alerting/issues/646
291291
AlertingPluginInterface.INSTANCE.indexMonitor((NodeClient) client, monitorRequests.get(0), namedWriteableRegistry, addFirstMonitorStep);
292292
addFirstMonitorStep.whenComplete(addedFirstMonitorResponse -> {
293-
log.error("PERF_DEBUG_SAP: first monitor created id {} of type {}", addedFirstMonitorResponse.getId(), addedFirstMonitorResponse.getMonitor().getMonitorType());
293+
log.debug(first monitor created id {} of type {}", addedFirstMonitorResponse.getId(), addedFirstMonitorResponse.getMonitor().getMonitorType());
294294
monitorResponses.add(addedFirstMonitorResponse);
295295

296296
StepListener<List<IndexMonitorResponse>> indexMonitorsStep = new StepListener<>();
@@ -853,12 +853,12 @@ private IndexMonitorRequest createDocLevelMonitorMatchAllRequest(
853853
}
854854

855855
private void buildBucketLevelMonitorRequests(List<Pair<String, Rule>> queries, Detector detector, WriteRequest.RefreshPolicy refreshPolicy, String monitorId, RestRequest.Method restMethod, ActionListener<List<IndexMonitorRequest>> listener) throws Exception {
856-
log.error("PERF_DEBUG_SAP: bucket level monitor request starting");
857-
log.error("PERF_DEBUG_SAP: get rule field mappings request being made");
856+
log.debug(bucket level monitor request starting");
857+
log.debug(get rule field mappings request being made");
858858
logTypeService.getRuleFieldMappings(new ActionListener<>() {
859859
@Override
860860
public void onResponse(Map<String, Map<String, String>> ruleFieldMappings) {
861-
log.error("PERF_DEBUG_SAP: got rule field mapping success");
861+
log.debug(got rule field mapping success");
862862
List<String> ruleCategories = queries.stream().map(Pair::getRight).map(Rule::getCategory).distinct().collect(
863863
Collectors.toList());
864864
Map<String, QueryBackend> queryBackendMap = new HashMap<>();
@@ -1109,27 +1109,27 @@ class AsyncIndexDetectorsAction {
11091109
}
11101110

11111111
void start() {
1112-
log.error("PERF_DEBUG_SAP: stash context");
1112+
log.debug(stash context");
11131113
TransportIndexDetectorAction.this.threadPool.getThreadContext().stashContext();
1114-
log.error("PERF_DEBUG_SAP: log type check : {}", request.getDetector().getDetectorType());
1114+
log.debug(log type check : {}", request.getDetector().getDetectorType());
11151115
logTypeService.doesLogTypeExist(request.getDetector().getDetectorType().toLowerCase(Locale.ROOT), new ActionListener<>() {
11161116
@Override
11171117
public void onResponse(Boolean exist) {
11181118
if (exist) {
1119-
log.error("PERF_DEBUG_SAP: log type exists : {}", request.getDetector().getDetectorType());
1119+
log.debug(log type exists : {}", request.getDetector().getDetectorType());
11201120
try {
11211121
if (!detectorIndices.detectorIndexExists()) {
1122-
log.error("PERF_DEBUG_SAP: detector index creation");
1122+
log.debug(detector index creation");
11231123
detectorIndices.initDetectorIndex(new ActionListener<>() {
11241124
@Override
11251125
public void onResponse(CreateIndexResponse response) {
11261126
try {
1127-
log.error("PERF_DEBUG_SAP: detector index created in {}");
1127+
log.debug(detector index created in {}");
11281128
11291129
onCreateMappingsResponse(response);
11301130
prepareDetectorIndexing();
11311131
} catch (Exception e) {
1132-
log.error("PERF_DEBUG_SAP: detector index creation failed", e);
1132+
log.debug(detector index creation failed", e);
11331133
onFailures(e);
11341134
}
11351135
}
@@ -1140,19 +1140,19 @@ public void onFailure(Exception e) {
11401140
}
11411141
});
11421142
} else if (!IndexUtils.detectorIndexUpdated) {
1143-
log.error("PERF_DEBUG_SAP: detector index update mapping");
1143+
log.debug(detector index update mapping");
11441144
IndexUtils.updateIndexMapping(
11451145
Detector.DETECTORS_INDEX,
11461146
DetectorIndices.detectorMappings(), clusterService.state(), client.admin().indices(),
11471147
new ActionListener<>() {
11481148
@Override
11491149
public void onResponse(AcknowledgedResponse response) {
1150-
log.error("PERF_DEBUG_SAP: detector index mapping updated");
1150+
log.debug(detector index mapping updated");
11511151
onUpdateMappingsResponse(response);
11521152
try {
11531153
prepareDetectorIndexing();
11541154
} catch (Exception e) {
1155-
log.error("PERF_DEBUG_SAP: detector index mapping FAILED updation", e);
1155+
log.debug(detector index mapping FAILED updation", e);
11561156
onFailures(e);
11571157
}
11581158
}
@@ -1210,15 +1210,15 @@ void createDetector() {
12101210
12111211
if (!detector.getInputs().isEmpty()) {
12121212
try {
1213-
log.error("PERF_DEBUG_SAP: init rule index template");
1213+
log.debug(init rule index template");
12141214
ruleTopicIndices.initRuleTopicIndexTemplate(new ActionListener<>() {
12151215
@Override
12161216
public void onResponse(AcknowledgedResponse acknowledgedResponse) {
1217-
log.error("PERF_DEBUG_SAP: init rule index template ack");
1217+
log.debug(init rule index template ack");
12181218
initRuleIndexAndImportRules(request, new ActionListener<>() {
12191219
@Override
12201220
public void onResponse(List<IndexMonitorResponse> monitorResponses) {
1221-
log.error("PERF_DEBUG_SAP: monitors indexed");
1221+
log.debug(monitors indexed");
12221222
request.getDetector().setMonitorIds(getMonitorIds(monitorResponses));
12231223
request.getDetector().setRuleIdMonitorIdMap(mapMonitorIds(monitorResponses));
12241224
try {
@@ -1361,13 +1361,13 @@ public void initRuleIndexAndImportRules(IndexDetectorRequest request, ActionList
13611361
new ActionListener<>() {
13621362
@Override
13631363
public void onResponse(CreateIndexResponse response) {
1364-
log.error("PERF_DEBUG_SAP: prepackaged rule index created");
1364+
log.debug(prepackaged rule index created");
13651365
ruleIndices.onCreateMappingsResponse(response, true);
13661366
ruleIndices.importRules(RefreshPolicy.IMMEDIATE, indexTimeout,
13671367
new ActionListener<>() {
13681368
@Override
13691369
public void onResponse(BulkResponse response) {
1370-
log.error("PERF_DEBUG_SAP: rules imported");
1370+
log.debug(rules imported");
13711371
if (!response.hasFailures()) {
13721372
importRules(request, listener);
13731373
} else {
@@ -1377,7 +1377,7 @@ public void onResponse(BulkResponse response) {
13771377

13781378
@Override
13791379
public void onFailure(Exception e) {
1380-
log.error("PERF_DEBUG_SAP: failed to import rules", e);
1380+
log.debug(failed to import rules", e);
13811381
onFailures(e);
13821382
}
13831383
});
@@ -1556,7 +1556,7 @@ public void onResponse(GetIndexMappingsResponse getMappingsViewResponse) {
15561556
}
15571557
}
15581558
long took = System.currentTimeMillis() - start;
1559-
log.error("PERF_DEBUG_SAP: completed collecting rule_field_names in {} millis", took);
1559+
log.debug(completed collecting rule_field_names in {} millis", took);
15601560
15611561
} catch (Exception e) {
15621562
logger.error("PERF_DEBUG_SAP: Failure in parsing rule field names/aliases while " +
@@ -1648,11 +1648,11 @@ public void indexDetector() throws Exception {
16481648
.id(request.getDetectorId())
16491649
.timeout(indexTimeout);
16501650
}
1651-
log.error("PERF_DEBUG_SAP: indexing detector");
1651+
log.debug(indexing detector");
16521652
client.index(indexRequest, new ActionListener<>() {
16531653
@Override
16541654
public void onResponse(IndexResponse response) {
1655-
log.error("PERF_DEBUG_SAP: detector indexed success.");
1655+
log.debug(detector indexed success.");
16561656
Detector responseDetector = request.getDetector();
16571657
responseDetector.setId(response.getId());
16581658
onOperation(response, responseDetector);

0 commit comments

Comments
 (0)