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

Add logging for execution and indexes of monitors and workflows #1223

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
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 @@ -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 @@ -75,6 +75,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 @@ -62,6 +62,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 @@ -486,6 +486,13 @@ class TransportIndexMonitorAction @Inject constructor(
.setIfPrimaryTerm(request.primaryTerm)
.timeout(indexTimeout)

log.info(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to suggest put the monitor body into debug level log which is a long string

"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 @@ -648,6 +655,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
Loading