Skip to content

Commit

Permalink
Add logging for execution and indexes of monitors and workflows (#1223)…
Browse files Browse the repository at this point in the history
… (#1225)

(cherry picked from commit 0a15bfd)

Signed-off-by: Ashish Agrawal <ashisagr@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent dc1b9bf commit 742f844
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,15 @@ object MonitorRunnerService : JobRunner, CoroutineScope, AbstractLifecycleCompon
}

if (job is Workflow) {
logger.info("Executing scheduled workflow - id: ${job.id}, periodStart: $periodStart, periodEnd: $periodEnd, dryrun: $dryrun")
CompositeWorkflowRunner.runWorkflow(workflow = job, monitorCtx, periodStart, periodEnd, dryrun)
}
val monitor = job as Monitor
val executionId = "${monitor.id}_${LocalDateTime.now(ZoneOffset.UTC)}_${UUID.randomUUID()}"
logger.info(
"Executing scheduled monitor - id: ${monitor.id}, type: ${monitor.monitorType.name}, periodStart: $periodStart, " +
"periodEnd: $periodEnd, dryrun: $dryrun, executionId: $executionId"
)
val runResult = if (monitor.isBucketLevelMonitor()) {
BucketLevelMonitorRunner.runMonitor(monitor, monitorCtx, periodStart, periodEnd, dryrun, executionId = executionId)
} else if (monitor.isDocLevelMonitor()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ class TransportExecuteMonitorAction @Inject constructor(
val (periodStart, periodEnd) =
monitor.schedule.getPeriodEndingAt(Instant.ofEpochMilli(execMonitorRequest.requestEnd.millis))
try {
log.info(
"Executing monitor from API - id: ${monitor.id}, type: ${monitor.monitorType.name}, " +
"periodStart: $periodStart, periodEnd: $periodEnd, dryrun: ${execMonitorRequest.dryrun}"
)
val monitorRunResult = runner.runJob(monitor, periodStart, periodEnd, execMonitorRequest.dryrun)
withContext(Dispatchers.IO) {
actionListener.onResponse(ExecuteMonitorResponse(monitorRunResult))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ class TransportExecuteWorkflowAction @Inject constructor(
val (periodStart, periodEnd) =
workflow.schedule.getPeriodEndingAt(Instant.ofEpochMilli(execWorkflowRequest.requestEnd.millis))
try {
log.info(
"Executing workflow from API - id: ${workflow.id}, periodStart: $periodStart, periodEnd: $periodEnd, " +
"dryrun: ${execWorkflowRequest.dryrun}"
)
val workflowRunResult =
MonitorRunnerService.runJob(workflow, periodStart, periodEnd, execWorkflowRequest.dryrun)
withContext(Dispatchers.IO, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,13 @@ class TransportIndexMonitorAction @Inject constructor(
.setIfPrimaryTerm(request.primaryTerm)
.timeout(indexTimeout)

log.info(
"Creating new monitor: ${request.monitor.toXContentWithUser(
jsonBuilder(),
ToXContent.MapParams(mapOf("with_type" to "true"))
)}"
)

try {
val indexResponse: IndexResponse = client.suspendUntil { client.index(indexRequest, it) }
val failureReasons = checkShardsFailure(indexResponse)
Expand Down Expand Up @@ -665,6 +672,13 @@ class TransportIndexMonitorAction @Inject constructor(
.setIfPrimaryTerm(request.primaryTerm)
.timeout(indexTimeout)

log.info(
"Updating monitor, ${currentMonitor.id}, from: ${currentMonitor.toXContentWithUser(
jsonBuilder(),
ToXContent.MapParams(mapOf("with_type" to "true"))
)} \n to: ${request.monitor.toXContentWithUser(jsonBuilder(), ToXContent.MapParams(mapOf("with_type" to "true")))}"
)

try {
val indexResponse: IndexResponse = client.suspendUntil { client.index(indexRequest, it) }
val failureReasons = checkShardsFailure(indexResponse)
Expand Down

0 comments on commit 742f844

Please sign in to comment.