Kubernetes
Cronjob Monitoring
Google Kubernetes Engine
GKE
Cloud Automation

Monitor Cronjob running on GKE

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Introduction

Monitoring a CronJob on GKE means checking more than whether the schedule exists. You need visibility into whether the CronJob creates Jobs on time, whether those Jobs finish successfully, and whether failed runs are visible quickly enough for someone to act.

Start with the Kubernetes Objects

A Kubernetes CronJob creates Job objects on a schedule, and each Job creates one or more Pods. So the monitoring path is:

  • CronJob
  • Job
  • Pod
  • logs and events

Start with the CronJob itself:

bash
kubectl get cronjob
kubectl describe cronjob backup-job

describe is especially useful because it shows:

  • schedule
  • concurrency policy
  • last schedule time
  • recent events

Then inspect Jobs created by that CronJob:

bash
kubectl get jobs
kubectl describe job backup-job-29123456

If a run is missing, delayed, or repeatedly failing, the Job and its events usually reveal the first useful clue.

Check the Pod and Its Logs

When a Job exists but does not complete successfully, inspect the pod:

bash
kubectl get pods --selector=job-name=backup-job-29123456
kubectl logs job/backup-job-29123456

That is often the fastest operational check. If the CronJob fires but the workload crashes, the schedule is not the problem. The pod logs are.

For example, a simple CronJob might look like this:

yaml
1apiVersion: batch/v1
2kind: CronJob
3metadata:
4  name: backup-job
5spec:
6  schedule: "0 * * * *"
7  concurrencyPolicy: Forbid
8  successfulJobsHistoryLimit: 3
9  failedJobsHistoryLimit: 3
10  jobTemplate:
11    spec:
12      template:
13        spec:
14          restartPolicy: Never
15          containers:
16            - name: backup
17              image: busybox:1.36
18              command:
19                - sh
20                - -c
21                - echo "running backup"; date

Even with a valid manifest, the real question is whether each generated Job finishes and logs the expected work.

Use GKE Logging and Metrics

On GKE, Kubernetes logs and events also flow into Google Cloud tooling. That matters because kubectl is useful for spot checks, but long-term monitoring needs alerts and history.

Practical monitoring usually includes:

  • Cloud Logging queries for failed Job pods
  • Cloud Monitoring alerts on failed executions
  • dashboarding for Job success and failure counts

If your CronJob is business-critical, you should not rely only on someone manually running kubectl describe after something breaks.

A Useful Operational Pattern

A good monitoring approach is:

  1. use kubectl describe cronjob for schedule and event debugging
  2. use kubectl logs job/... for the actual workload output
  3. create alerts for failed Jobs or missing successful completions

That third point is important. A CronJob can fail silently from an operator perspective if nobody is watching for absence. Sometimes the problem is not "a failed run", but "no run happened when expected".

Watch the CronJob Settings That Affect Behavior

Some monitoring confusion comes from the CronJob spec itself:

  • 'concurrencyPolicy: Forbid can skip overlapping runs'
  • 'startingDeadlineSeconds can cause missed windows to be abandoned'
  • 'suspend: true pauses execution intentionally'
  • low history limits can remove old evidence quickly

If someone says "the CronJob did not run", the right answer may be that the controller skipped it according to policy rather than that the cluster broke.

Common Pitfalls

  • Looking only at the CronJob object and not at the Jobs and Pods it creates.
  • Assuming a valid schedule means the workload completed successfully.
  • Ignoring events, which often explain missed or blocked runs.
  • Relying only on ad hoc kubectl checks instead of Cloud Monitoring alerts for production jobs.
  • Forgetting that CronJob settings such as Forbid and suspend change runtime behavior intentionally.

Summary

  • Monitoring a GKE CronJob means following the chain from CronJob to Job to Pod to logs.
  • Use kubectl describe cronjob and kubectl logs job/... for the fastest debugging path.
  • In production, add Cloud Logging and Cloud Monitoring so failed or missing runs generate alerts.
  • Review CronJob settings such as concurrency policy and suspension before assuming the scheduler is broken.
  • A healthy CronJob is one that both starts on time and completes the expected work successfully.

Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.