Skip to content

Commit 36fccd7

Browse files
committed
Add k8s metrics for jobs and cronjobs
Signed-off-by: ChrsMark <[email protected]>
1 parent 373a695 commit 36fccd7

File tree

3 files changed

+224
-0
lines changed

3 files changed

+224
-0
lines changed

.chloggen/add_k8s_jobs.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Use this changelog template to create an entry for release notes.
2+
#
3+
# If your change doesn't affect end users you should instead start
4+
# your pull request title with [chore] or use the "Skip Changelog" label.
5+
6+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
7+
change_type: enhancement
8+
9+
# The name of the area of concern in the attributes-registry, (e.g. http, cloud, db)
10+
component: k8s
11+
12+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
13+
note: Add k8s metrics for job and cronjob
14+
15+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
16+
# The values here must be integers.
17+
issues: []
18+
19+
# (Optional) One or more lines of additional information to render under the primary note.
20+
# These lines will be padded with 2 spaces and then inserted directly into the document.
21+
# Use pipe (|) for multiline entries.
22+
subtext:

docs/system/k8s-metrics.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,5 +329,143 @@ This metric is [recommended][MetricRecommended].
329329
<!-- END AUTOGENERATED TEXT -->
330330
<!-- endsemconv -->
331331

332+
### Metric: `k8s.job.active_pods`
333+
334+
This metric is [recommended][MetricRecommended].
335+
336+
<!-- semconv metric.k8s.job.active_pods -->
337+
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
338+
<!-- see templates/registry/markdown/snippet.md.j2 -->
339+
<!-- prettier-ignore-start -->
340+
<!-- markdownlint-capture -->
341+
<!-- markdownlint-disable -->
342+
343+
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
344+
| -------- | --------------- | ----------- | -------------- | --------- |
345+
| `k8s.job.active_pods` | Gauge | `{pod}` | The number of pending and actively running pods for a job [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
346+
347+
**[1]:** This metric aligns with the `active` field of the
348+
[K8s JobStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch)
349+
350+
<!-- markdownlint-restore -->
351+
<!-- prettier-ignore-end -->
352+
<!-- END AUTOGENERATED TEXT -->
353+
<!-- endsemconv -->
354+
355+
### Metric: `k8s.job.failed_pods`
356+
357+
This metric is [recommended][MetricRecommended].
358+
359+
<!-- semconv metric.k8s.job.failed_pods -->
360+
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
361+
<!-- see templates/registry/markdown/snippet.md.j2 -->
362+
<!-- prettier-ignore-start -->
363+
<!-- markdownlint-capture -->
364+
<!-- markdownlint-disable -->
365+
366+
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
367+
| -------- | --------------- | ----------- | -------------- | --------- |
368+
| `k8s.job.failed_pods` | Gauge | `{pod}` | The number of pods which reached phase Failed for a job [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
369+
370+
**[1]:** This metric aligns with the `failed` field of the
371+
[K8s JobStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch)
372+
373+
<!-- markdownlint-restore -->
374+
<!-- prettier-ignore-end -->
375+
<!-- END AUTOGENERATED TEXT -->
376+
<!-- endsemconv -->
377+
378+
### Metric: `k8s.job.successful_pods`
379+
380+
This metric is [recommended][MetricRecommended].
381+
382+
<!-- semconv metric.k8s.job.successful_pods -->
383+
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
384+
<!-- see templates/registry/markdown/snippet.md.j2 -->
385+
<!-- prettier-ignore-start -->
386+
<!-- markdownlint-capture -->
387+
<!-- markdownlint-disable -->
388+
389+
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
390+
| -------- | --------------- | ----------- | -------------- | --------- |
391+
| `k8s.job.successful_pods` | Gauge | `{pod}` | The number of pods which reached phase Succeeded for a job [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
392+
393+
**[1]:** This metric aligns with the `succeeded` field of the
394+
[K8s JobStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch)
395+
396+
<!-- markdownlint-restore -->
397+
<!-- prettier-ignore-end -->
398+
<!-- END AUTOGENERATED TEXT -->
399+
<!-- endsemconv -->
400+
401+
### Metric: `k8s.job.desired_successful_pods`
402+
403+
This metric is [recommended][MetricRecommended].
404+
405+
<!-- semconv metric.k8s.job.desired_successful_pods -->
406+
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
407+
<!-- see templates/registry/markdown/snippet.md.j2 -->
408+
<!-- prettier-ignore-start -->
409+
<!-- markdownlint-capture -->
410+
<!-- markdownlint-disable -->
411+
412+
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
413+
| -------- | --------------- | ----------- | -------------- | --------- |
414+
| `k8s.job.desired_successful_pods` | Gauge | `{pod}` | The desired number of successfully finished pods the job should be run with [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
415+
416+
**[1]:** This metric aligns with the `completions` field of the
417+
[K8s JobSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobspec-v1-batch)
418+
419+
<!-- markdownlint-restore -->
420+
<!-- prettier-ignore-end -->
421+
<!-- END AUTOGENERATED TEXT -->
422+
<!-- endsemconv -->
423+
424+
### Metric: `k8s.job.max_parallel_pods`
425+
426+
This metric is [recommended][MetricRecommended].
427+
428+
<!-- semconv metric.k8s.job.max_parallel_pods -->
429+
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
430+
<!-- see templates/registry/markdown/snippet.md.j2 -->
431+
<!-- prettier-ignore-start -->
432+
<!-- markdownlint-capture -->
433+
<!-- markdownlint-disable -->
434+
435+
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
436+
| -------- | --------------- | ----------- | -------------- | --------- |
437+
| `k8s.job.max_parallel_pods` | Gauge | `{pod}` | The max desired number of pods the job should run at any given time [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
438+
439+
**[1]:** This metric aligns with the `parallelism` field of the
440+
[K8s JobSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobspec-v1-batch
441+
442+
<!-- markdownlint-restore -->
443+
<!-- prettier-ignore-end -->
444+
<!-- END AUTOGENERATED TEXT -->
445+
<!-- endsemconv -->
446+
447+
### Metric: `k8s.cronjob.active_jobs`
448+
449+
This metric is [recommended][MetricRecommended].
450+
451+
<!-- semconv metric.k8s.cronjob.active_jobs -->
452+
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
453+
<!-- see templates/registry/markdown/snippet.md.j2 -->
454+
<!-- prettier-ignore-start -->
455+
<!-- markdownlint-capture -->
456+
<!-- markdownlint-disable -->
457+
458+
| Name | Instrument Type | Unit (UCUM) | Description | Stability |
459+
| -------- | --------------- | ----------- | -------------- | --------- |
460+
| `k8s.cronjob.active_jobs` | Gauge | `{job}` | The number of actively running jobs for a cronjob [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
461+
462+
**[1]:** This metric aligns with the `active` field of the
463+
[K8s CronJobStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#cronjobstatus-v1-batch)
464+
465+
<!-- markdownlint-restore -->
466+
<!-- prettier-ignore-end -->
467+
<!-- END AUTOGENERATED TEXT -->
468+
<!-- endsemconv -->
469+
332470
[DocumentStatus]: https://opentelemetry.io/docs/specs/otel/document-status
333471
[MetricRecommended]: /docs/general/metric-requirement-level.md#recommended

model/k8s/metrics.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,67 @@ groups:
126126
attributes:
127127
- ref: network.interface.name
128128
- ref: network.io.direction
129+
130+
# k8s.job.* metrics
131+
- id: metric.k8s.job.active_pods
132+
type: metric
133+
metric_name: k8s.job.active_pods
134+
stability: experimental
135+
brief: "The number of pending and actively running pods for a job"
136+
instrument: gauge
137+
unit: "{pod}"
138+
note: |
139+
This metric aligns with the `active` field of the
140+
[K8s JobStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch)
141+
- id: metric.k8s.job.failed_pods
142+
type: metric
143+
metric_name: k8s.job.failed_pods
144+
stability: experimental
145+
brief: "The number of pods which reached phase Failed for a job"
146+
instrument: gauge
147+
unit: "{pod}"
148+
note: |
149+
This metric aligns with the `failed` field of the
150+
[K8s JobStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch)
151+
- id: metric.k8s.job.successful_pods
152+
type: metric
153+
metric_name: k8s.job.successful_pods
154+
stability: experimental
155+
brief: "The number of pods which reached phase Succeeded for a job"
156+
instrument: gauge
157+
unit: "{pod}"
158+
note: |
159+
This metric aligns with the `succeeded` field of the
160+
[K8s JobStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch)
161+
- id: metric.k8s.job.desired_successful_pods
162+
type: metric
163+
metric_name: k8s.job.desired_successful_pods
164+
stability: experimental
165+
brief: "The desired number of successfully finished pods the job should be run with"
166+
instrument: gauge
167+
unit: "{pod}"
168+
note: |
169+
This metric aligns with the `completions` field of the
170+
[K8s JobSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobspec-v1-batch)
171+
- id: metric.k8s.job.max_parallel_pods
172+
type: metric
173+
metric_name: k8s.job.max_parallel_pods
174+
stability: experimental
175+
brief: "The max desired number of pods the job should run at any given time"
176+
instrument: gauge
177+
unit: "{pod}"
178+
note: |
179+
This metric aligns with the `parallelism` field of the
180+
[K8s JobSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobspec-v1-batch
181+
182+
# k8s.job.* metrics
183+
- id: metric.k8s.cronjob.active_jobs
184+
type: metric
185+
metric_name: k8s.cronjob.active_jobs
186+
stability: experimental
187+
brief: "The number of actively running jobs for a cronjob"
188+
instrument: gauge
189+
unit: "{job}"
190+
note: |
191+
This metric aligns with the `active` field of the
192+
[K8s CronJobStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#cronjobstatus-v1-batch)

0 commit comments

Comments
 (0)