Skip to content

Commit

Permalink
change log level to debug logs
Browse files Browse the repository at this point in the history
Signed-off-by: Surya Sashank Nistala <snistala@amazon.com>
  • Loading branch information
eirsep committed Feb 29, 2024
1 parent 23409e8 commit 6e33100
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ dependencies {
implementation group: 'org.apache.commons', name: 'commons-lang3', version: "${versions.commonslang}"
implementation "org.antlr:antlr4-runtime:4.10.1"
implementation "com.cronutils:cron-utils:9.1.6"
api files("/Users/snistala/Documents/opensearch/common-utils/build/libs/common-utils-3.0.0.0-SNAPSHOT.jar")
api "org.opensearch:common-utils:${common_utils_version}@jar"
api "org.opensearch.client:opensearch-rest-client:${opensearch_version}"
implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"
compileOnly "org.opensearch:opensearch-job-scheduler-spi:${opensearch_build}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void onResponse(GetMappingsResponse getMappingsResponse) {
applyAliasMappings(getMappingsResponse.getMappings(), logType, aliasMappings, partial, new ActionListener<>() {
@Override
public void onResponse(Collection<CreateMappingResult> createMappingResponse) {
log.error("PERF_DEBUG_SAP: Completed create mappings for {}", indexName);
log.debug(Completed create mappings for {}", indexName);
// We will return ack==false if one of the requests returned that
// else return ack==true
Optional<AcknowledgedResponse> notAckd = createMappingResponse.stream()
Expand All @@ -113,7 +113,7 @@ public void onResponse(Collection<CreateMappingResult> createMappingResponse) {
@Override
public void onFailure(Exception e) {
log.error("PERF_DEBUG_SAP: Failed to create mappings for {}", indexName );
log.debug(Failed to create mappings for {}", indexName );
actionListener.onFailure(e);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,22 +222,22 @@ private void checkIndicesAndExecute(
ActionListener<IndexDetectorResponse> listener,
User user
) {
log.error("PERF_DEBUG_SAP: check indices and execute began");
log.debug(check indices and execute began");
String [] detectorIndices = request.getDetector().getInputs().stream().flatMap(detectorInput -> detectorInput.getIndices().stream()).toArray(String[]::new);
SearchRequest searchRequest = new SearchRequest(detectorIndices)
.source(SearchSourceBuilder.searchSource().size(1).query(QueryBuilders.matchAllQuery()));
searchRequest.setCancelAfterTimeInterval(TimeValue.timeValueSeconds(30));
client.search(searchRequest, new ActionListener<>() {
@Override
public void onResponse(SearchResponse searchResponse) {
log.error("PERF_DEBUG_SAP: check indices and execute completed. Took {} millis", searchResponse.getTook().millis());
log.debug(check indices and execute completed. Took {} millis", searchResponse.getTook().millis());
AsyncIndexDetectorsAction asyncAction = new AsyncIndexDetectorsAction(user, task, request, listener);
asyncAction.start();
}

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

StepListener<List<IndexMonitorResponse>> indexMonitorsStep = new StepListener<>();
Expand Down Expand Up @@ -853,12 +853,12 @@ private IndexMonitorRequest createDocLevelMonitorMatchAllRequest(
}

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

void start() {
log.error("PERF_DEBUG_SAP: stash context");
log.debug(stash context");
TransportIndexDetectorAction.this.threadPool.getThreadContext().stashContext();
log.error("PERF_DEBUG_SAP: log type check : {}", request.getDetector().getDetectorType());
log.debug(log type check : {}", request.getDetector().getDetectorType());
logTypeService.doesLogTypeExist(request.getDetector().getDetectorType().toLowerCase(Locale.ROOT), new ActionListener<>() {
@Override
public void onResponse(Boolean exist) {
if (exist) {
log.error("PERF_DEBUG_SAP: log type exists : {}", request.getDetector().getDetectorType());
log.debug(log type exists : {}", request.getDetector().getDetectorType());
try {
if (!detectorIndices.detectorIndexExists()) {
log.error("PERF_DEBUG_SAP: detector index creation");
log.debug(detector index creation");
detectorIndices.initDetectorIndex(new ActionListener<>() {
@Override
public void onResponse(CreateIndexResponse response) {
try {
log.error("PERF_DEBUG_SAP: detector index created in {}");
log.debug(detector index created in {}");
onCreateMappingsResponse(response);
prepareDetectorIndexing();
} catch (Exception e) {
log.error("PERF_DEBUG_SAP: detector index creation failed", e);
log.debug(detector index creation failed", e);
onFailures(e);
}
}
Expand All @@ -1140,19 +1140,19 @@ public void onFailure(Exception e) {
}
});
} else if (!IndexUtils.detectorIndexUpdated) {
log.error("PERF_DEBUG_SAP: detector index update mapping");
log.debug(detector index update mapping");
IndexUtils.updateIndexMapping(
Detector.DETECTORS_INDEX,
DetectorIndices.detectorMappings(), clusterService.state(), client.admin().indices(),
new ActionListener<>() {
@Override
public void onResponse(AcknowledgedResponse response) {
log.error("PERF_DEBUG_SAP: detector index mapping updated");
log.debug(detector index mapping updated");
onUpdateMappingsResponse(response);
try {
prepareDetectorIndexing();
} catch (Exception e) {
log.error("PERF_DEBUG_SAP: detector index mapping FAILED updation", e);
log.debug(detector index mapping FAILED updation", e);
onFailures(e);
}
}
Expand Down Expand Up @@ -1210,15 +1210,15 @@ void createDetector() {
if (!detector.getInputs().isEmpty()) {
try {
log.error("PERF_DEBUG_SAP: init rule index template");
log.debug(init rule index template");
ruleTopicIndices.initRuleTopicIndexTemplate(new ActionListener<>() {
@Override
public void onResponse(AcknowledgedResponse acknowledgedResponse) {
log.error("PERF_DEBUG_SAP: init rule index template ack");
log.debug(init rule index template ack");
initRuleIndexAndImportRules(request, new ActionListener<>() {
@Override
public void onResponse(List<IndexMonitorResponse> monitorResponses) {
log.error("PERF_DEBUG_SAP: monitors indexed");
log.debug(monitors indexed");
request.getDetector().setMonitorIds(getMonitorIds(monitorResponses));
request.getDetector().setRuleIdMonitorIdMap(mapMonitorIds(monitorResponses));
try {
Expand Down Expand Up @@ -1361,13 +1361,13 @@ public void initRuleIndexAndImportRules(IndexDetectorRequest request, ActionList
new ActionListener<>() {
@Override
public void onResponse(CreateIndexResponse response) {
log.error("PERF_DEBUG_SAP: prepackaged rule index created");
log.debug(prepackaged rule index created");
ruleIndices.onCreateMappingsResponse(response, true);
ruleIndices.importRules(RefreshPolicy.IMMEDIATE, indexTimeout,
new ActionListener<>() {
@Override
public void onResponse(BulkResponse response) {
log.error("PERF_DEBUG_SAP: rules imported");
log.debug(rules imported");
if (!response.hasFailures()) {
importRules(request, listener);
} else {
Expand All @@ -1377,7 +1377,7 @@ public void onResponse(BulkResponse response) {

@Override
public void onFailure(Exception e) {
log.error("PERF_DEBUG_SAP: failed to import rules", e);
log.debug(failed to import rules", e);
onFailures(e);
}
});
Expand Down Expand Up @@ -1556,7 +1556,7 @@ public void onResponse(GetIndexMappingsResponse getMappingsViewResponse) {
}
}
long took = System.currentTimeMillis() - start;
log.error("PERF_DEBUG_SAP: completed collecting rule_field_names in {} millis", took);
log.debug(completed collecting rule_field_names in {} millis", took);
} catch (Exception e) {
logger.error("PERF_DEBUG_SAP: Failure in parsing rule field names/aliases while " +
Expand Down Expand Up @@ -1648,11 +1648,11 @@ public void indexDetector() throws Exception {
.id(request.getDetectorId())
.timeout(indexTimeout);
}
log.error("PERF_DEBUG_SAP: indexing detector");
log.debug(indexing detector");
client.index(indexRequest, new ActionListener<>() {
@Override
public void onResponse(IndexResponse response) {
log.error("PERF_DEBUG_SAP: detector indexed success.");
log.debug(detector indexed success.");
Detector responseDetector = request.getDetector();
responseDetector.setId(response.getId());
onOperation(response, responseDetector);
Expand Down

0 comments on commit 6e33100

Please sign in to comment.