This guide shows you how to monitor Kubernetes CronJobs with the SigNoz k8s-infra OpenTelemetry collection agent.
Prerequisites
k8s-infrais already installed in your cluster. If you have not installed it yet, follow Install K8s Infra.- You have
kubectlaccess to the cluster where your CronJobs run. - You have a SigNoz backend available to receive telemetry.
If you already have CronJobs running in your cluster, you can skip Step 1 and Step 2 and go directly to Default telemetry from k8s-infra and Validate.
Step 1. Create a CronJob
Apply the following manifest to create a CronJob that runs every minute and writes logs to standard output:
apiVersion: v1
kind: Namespace
metadata:
name: batch-jobs
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: reporting-demo
namespace: batch-jobs
labels:
app.kubernetes.io/name: reporting-demo
spec:
schedule: "*/1 * * * *"
timeZone: "Etc/UTC"
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 1
jobTemplate:
spec:
template:
metadata:
labels:
app.kubernetes.io/name: reporting-demo
spec:
restartPolicy: OnFailure
containers:
- name: reporter
image: busybox:1.36
command:
- /bin/sh
- -c
- |
echo "cronjob=reporting-demo start=$(date -Iseconds)"
sleep 5
echo "cronjob=reporting-demo finished=$(date -Iseconds)"This example keeps the CronJob simple but still uses a few Kubernetes defaults that are useful for production:
timeZone: Makes the schedule explicit instead of relying on the controller's local time zoneconcurrencyPolicy: Forbid: Prevents overlapping runssuccessfulJobsHistoryLimitandfailedJobsHistoryLimit: Keeps recent execution history available for debugging
Apply it:
kubectl apply -f cronjob-demo.yamlStep 2. Wait for the first execution
Check that Kubernetes creates a Job and a Pod for the CronJob:
kubectl -n batch-jobs get cronjob,jobs,podsYou should see:
- The
reporting-demoCronJob - A Job created from that CronJob
- A completed Pod for that Job after the run finishes
Default telemetry from k8s-infra
No extra CronJob-specific Helm values are required for the default monitoring flow. If k8s-infra is already installed with metrics and logs collection enabled, it automatically collects CronJob pod logs and Kubernetes Job metrics when the CronJob runs. K8s Infra installed with Foundry collects the same logs and metrics by default, with no change to casting.yaml.
Default logs
All logs emitted by CronJob pods are captured automatically in Logs Explorer with Kubernetes resource attributes such as:
k8s.namespace.namek8s.cronjob.namek8s.job.namek8s.pod.name
Use:
k8s.cronjob.nameto see all executions for one CronJobk8s.job.nameto inspect one specific execution
Default metrics
In the validated k8s-infra setup for this guide, these CronJob-related Kubernetes metrics were emitted by default:
k8s.cronjob.active_jobsk8s.job.active_podsk8s.job.successful_podsk8s.job.failed_podsk8s.job.desired_successful_podsk8s.job.max_parallel_pods
These metrics come from the OpenTelemetry k8sclusterreceiver. They are attached to Kubernetes Job resources, so k8s.job.name is the main dimension to use when you want to inspect one CronJob run in Metrics Explorer.
Validate
Validate logs in SigNoz
Open Logs Explorer and filter with these resource attributes:
k8s.cluster.name = <your-cluster-name>k8s.namespace.name = batch-jobsk8s.cronjob.name = reporting-demo
Replace <your-cluster-name> with the clusterName you set when you installed k8s-infra, or with K8S_CLUSTER_NAME from your Foundry casting.yaml.
You should see log lines from every run of the CronJob.
Use k8s.job.name when you want to inspect one specific execution, because Kubernetes creates a new Job name for every schedule.
Validate metrics in SigNoz
Open Metrics Explorer and query one or more of these metrics:
k8s.job.active_podsk8s.job.successful_podsk8s.job.failed_podsk8s.job.desired_successful_podsk8s.job.max_parallel_podsk8s.cronjob.active_jobs
Filter with:
k8s.cluster.name = <your-cluster-name>k8s.namespace.name = batch-jobs
Replace <your-cluster-name> with the clusterName you set when you installed k8s-infra, or with K8S_CLUSTER_NAME from your Foundry casting.yaml.
Group by k8s.job.name to see each CronJob execution separately.
Visualize with the prebuilt dashboard
SigNoz publishes a prebuilt Kubernetes CronJobs dashboard that uses the same metrics this guide validates. It shows current Job state and recent Job runs in one view, with cluster, namespace, Job, and CronJob filters.
- Dashboard reference page: Kubernetes CronJobs Dashboard
- Direct JSON:
k8s-infra-metrics/kubernetes-cronjobs.json
To use it, open Dashboards in SigNoz, click New Dashboard, choose Import JSON, and paste the JSON from the link above.
Limit log collection to CronJob namespace (Optional)
Prefer namespace-based filters for CronJobs. Pod names and Job names change on every run, so namespace rules are easier to maintain.
Only collect logs from your CronJob namespace
If you keep CronJobs in a dedicated namespace, enable a whitelist for that namespace:
presets:
logsCollection:
whitelist:
enabled: true
namespaces:
- batch-jobsApply the updated values to your existing release:
helm upgrade <release-name> signoz/k8s-infra -n <namespace> -f override-values.yamlVerify these values:
<release-name>: Your existingk8s-infraHelm release name<namespace>: The namespace wherek8s-infrais installed
If you keep CronJobs in a dedicated namespace, add this to the agent's document in casting.yaml to collect container logs from that namespace only:
spec:
collector:
spec:
config:
data:
collector/agent/agent.yaml: |
receivers:
filelog/k8s:
include:
- /var/log/pods/batch-jobs_*/*/*.logLists replace, so include holds only the batch-jobs namespace. Then run this from the directory that contains casting.yaml:
foundryctl cast -f casting.yamlExclude noisy namespaces from log collection
If shared cluster namespaces create too much log noise, exclude them:
presets:
logsCollection:
blacklist:
enabled: true
namespaces:
- kube-system
- defaultApply the updated values to your existing release:
helm upgrade <release-name> signoz/k8s-infra -n <namespace> -f override-values.yamlVerify these values:
<release-name>: Your existingk8s-infraHelm release name<namespace>: The namespace wherek8s-infrais installed
Foundry excludes kube-system by default. To exclude another namespace, such as default, add this to the agent's document in casting.yaml:
spec:
collector:
spec:
config:
data:
collector/agent/agent.yaml: |
receivers:
filelog/k8s:
exclude:
- /var/log/pods/signoz_signoz-collector-*/*/*.log
- /var/log/pods/kube-system_*/*/*.log
- /var/log/pods/default_*/*/*.logLists replace, so restate Foundry's two default exclusions (the first two entries) before your own. The first one skips the collectors' own logs and follows <namespace>_<metadata.name>-collector-*. Then run this from the directory that contains casting.yaml:
foundryctl cast -f casting.yamlTroubleshooting
I can see logs, but I do not see Job metrics
Verify that the cluster-level k8s-infra collector deployment is running. The Job metrics in this guide came from the cluster-level collector, not from the node-level daemon.
For example, check the k8s-infra namespace where you installed the chart:
kubectl get deployments -n <k8s-infra-namespace>
kubectl get pods -n <k8s-infra-namespace>You should see a running deployment such as my-release-k8s-infra-otel-deployment with pods in Running status. If the deployment is missing, re-install k8s-infra by following Install K8s Infra.
The Job metrics come from the deployment collector, signoz-collector-deployment, not from the agent on each node. Run this on the machine where you use kubectl to check that it is running:
kubectl get deployment signoz-collector-deployment -n signozREADY shows 1/1 when it runs. signoz is metadata.name, which is also the namespace unless the foundry.signoz.io/kubernetes-namespace annotation sets another. If the deployment is missing, check that casting.yaml has the deployment collector's document (collector.kind: deployment), then run foundryctl cast -f casting.yaml again from the directory that contains it.
I can see Job metrics, but I do not see CronJob logs
Check these points:
presets.logsCollection.enabledis still enabled in yourk8s-infravalues- Your namespace is not excluded by a
logsCollection.blacklistrule - The CronJob container writes logs to standard output or standard error
For a Foundry install, check the agent's document in casting.yaml instead of the first two points: the logs pipeline still lists filelog/k8s, no exclude entry under filelog/k8s matches your namespace, and include, if you set it, covers your namespace.
My Job names keep changing on every run
That is expected Kubernetes behavior. A CronJob creates a new Job for every scheduled execution.
Use:
k8s.cronjob.namein Logs Explorer to see all runs for one CronJobk8s.job.namein Metrics Explorer or Logs Explorer to inspect one specific execution
Next steps
- Use Logs Explorer to search CronJob executions across namespaces and filter by
k8s.cronjob.name - Use Query Builder to group CronJob metrics by
k8s.job.nameand compare recent runs - Set up alerts to notify on failed CronJob runs or missing expected executions