on
09 Dec 2025
08:04 AM
- edited on
02 Jan 2026
02:48 PM
by
Michal_Gebacki
When a CronJob is configured with failedJobsHistoryLimit: 0, and the job fails after reaching the backoffLimit, the BackoffLimitExceeded event is triggered. However, the cloud-application is missing on the event, resulting in no problem being connected to the workload.
The failed job is not retained when failedJobsHistoryLimit is set to 0, preventing the problem from being connected to the workload.
Increase the failedJobsHistoryLimit to 1 in your CronJob configuration:
failedJobsHistoryLimit: 1
Let’s break it down with an example:
apiVersion: batch/v1
kind: CronJob
metadata:
name: zai-cronjob
spec:
schedule: "* * * * *"
failedJobsHistoryLimit: 0
jobTemplate:
spec:
backoffLimit: 0
template:
spec:
containers:
- name: zai-pod
image: docker.io/library/bash:5
command: ["sh", "-c", "sleep 120; exit 1"]
restartPolicy: Never
The above CronJob runs every minute and creates the following Kubernetes entities:
To clarify the timewise relationship between the CronJob, the Job, and the Pod, here’s a detailed explanation with a timeline.
sleep 120 command and exit 1.failedJobsHistoryLimit is reached.sleep 120).Below is an example timeline for a CronJob configured with failedJobsHistoryLimit: 0:
| Entity | Visibility Timeline |
|---|---|
| CronJob | Runs indefinitely |
| Job 1 | Visible from 12:00 to 12:02 |
| Pod 1 | Visible from 12:00 to 12:02 |
| Job 2 | Visible from 12:01 to 12:03 |
| Pod 2 | Visible from 12:01 to 12:03 |
| Job 3 | Visible from 12:02 to 12:04 |
| Pod 3 | Visible from 12:02 to 12:04 |
In Dynatrace, CronJobs and Pods are saved, but Jobs are not visible in the GUI. Jobs are only available at runtime as long as they are:
These Controllers are updated every minute to reflect the current cluster state.
Each job will trigger the BackoffLimitExceeded event exactly 2 minutes after it starts, because:
sleep 120).1 (failure).backoffLimit: 0, the job fails immediately without retries.When failedJobsHistoryLimit: 0, the failed job is not retained after failure, meaning the BackoffLimitExceeded event cannot be associated with the workload. This results in no problem shown on workload level.
To ensure that the failed job is available when the BackoffLimitExceeded event is triggered, update the CronJob configuration to include failedJobsHistoryLimit: 1:
apiVersion: batch/v1
kind: CronJob
metadata:
name: zai-cronjob
spec:
schedule: "* * * * *"
failedJobsHistoryLimit: 1
jobTemplate:
spec:
backoffLimit: 0
template:
spec:
containers:
- name: zai-pod
image: docker.io/library/bash:5
command: ["sh", "-c", "sleep 120; exit 1"]
restartPolicy: Never
failedJobsHistoryLimit| Configuration | Job Lifespan | Pod Lifespan |
|---|---|---|
failedJobsHistoryLimit: 0 |
Ends immediately after fail | Ends immediately after fail |
failedJobsHistoryLimit: 1 |
Retained until next failure | Retained until next failure |
With this configuration:
BackoffLimitExceeded event will be associated with the workload.
failedJobsHistoryLimitAccording to the Kubernetes documentation, the default value for failedJobsHistoryLimit is 1. Therefore, one alternative solution is simply removing the limit instead of explicitly setting it to 1.
failedJobsHistoryLimit: 0?In some scenarios, failedJobsHistoryLimit: 0 may be configured to:
failedJobsHistoryLimit: 0Pros:
Cons:
BackoffLimitExceeded.While setting failedJobsHistoryLimit: 0 may be suitable for certain use cases, it is generally recommended to retain at least one failed job by keeping the default value of 1. This ensures that important events like BackoffLimitExceeded are properly associated with workloads and visible in monitoring systems like Dynatrace.
If there are specific reasons for setting the limit to 0, it may be helpful to evaluate the trade-offs and consider whether retaining failed jobs would provide greater value for monitoring and troubleshooting.
If you found this article unhelpful or if it did not resolve your issue, we encourage you to open a support ticket for further assistance. When submitting your ticket, please reference this article to provide context for your inquiry. Additionally, make sure to include the relevant YAML file for the cronjob configuration as part of your ticket submission. This will help the support team better understand your situation and provide more accurate and efficient assistance.