Skip to content

Add k8s resourcequota metrics#2113

Merged
jsuereth merged 4 commits intoopen-telemetry:mainfrom
ChrsMark:add_k8s_resourcequota_metrics
Jun 18, 2025
Merged

Add k8s resourcequota metrics#2113
jsuereth merged 4 commits intoopen-telemetry:mainfrom
ChrsMark:add_k8s_resourcequota_metrics

Conversation

@ChrsMark
Copy link
Copy Markdown
Member

@ChrsMark ChrsMark commented Apr 14, 2025

Fixes #2076

Changes

This PR introduces the following metrics as part of #1032:

k8s.resourcequota.cpu.limit.{hard, used}
k8s.resourcequota.cpu.request.{hard, used}
k8s.resourcequota.memory.limit.{hard, used}
k8s.resourcequota.memory.request.{hard, used}
k8s.resourcequota.hugepages.request.{hard, used}
k8s.resourcequota.storage.request.{hard, used}
k8s.resourcequota.ephemeral_storage.limit.{hard, used}
k8s.resourcequota.ephemeral_storage.request.{hard, used}
k8s.resourcequota.persistentvolumeclaims.request.{hard, used}
k8s.resourcequota.object_count.{hard, used}

This addition follows the K8s spec and compute docs:

Is aligned with the respective Resource Attributes:

- id: resource.k8s.resourcequota

Merge requirement checklist

Extra context

A ResourceQuota object will come with a status like the following:

status:
  hard:
    limits.cpu: "2"
    limits.memory: 2Gi
    requests.cpu: "1"
    requests.memory: 1Gi
  used:
    limits.cpu: 800m
    limits.memory: 800Mi
    requests.cpu: 400m
    requests.memory: 600Mi

(ref)

Collector implementation reference: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/9bb671ca7ab3a9e0861d068f15b146aaa55766c2/receiver/k8sclusterreceiver/documentation.md?plain=1#L271-L291. Note that this PR does not follow the schema that the existing implementation follows (see #2076 (comment)).

@ChrsMark ChrsMark requested review from a team as code owners April 14, 2025 12:33
@ChrsMark ChrsMark self-assigned this Apr 14, 2025
@ChrsMark ChrsMark force-pushed the add_k8s_resourcequota_metrics branch from fc1f9e0 to c3d0534 Compare April 14, 2025 12:34
@github-actions github-actions Bot added the enhancement New feature or request label Apr 14, 2025
@ChrsMark ChrsMark force-pushed the add_k8s_resourcequota_metrics branch from c3d0534 to 3a0e762 Compare April 14, 2025 12:39
Copy link
Copy Markdown
Contributor

@rogercoll rogercoll left a comment

Choose a reason for hiding this comment

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

Are those metrics specific per k8s namespace? Should we add the k8s.namespace.name attribute?

@ChrsMark
Copy link
Copy Markdown
Member Author

Are those metrics specific per k8s namespace? Should we add the k8s.namespace.name attribute?

The min requirement is k8s.resourcequota.uid and k8s.resourcequota.name that we mention at https://github.com/open-telemetry/semantic-conventions/pull/2113/files#diff-bc357ba83c440c197ef2b49741508f83f85ad2829e7d1abd64b1a84b04135ca5R491.

In any case we will need to revisit this as part of #1421.

For the records, today the Collector reports the namespace as well:

Resource attributes:
     -> k8s.resourcequota.uid: Str(31c6317a-d8d4-48ea-adb0-e35074818623)
     -> k8s.resourcequota.name: Str(mem-cpu-demo)
     -> k8s.namespace.name: Str(default)

(ref)

Comment thread docs/system/k8s-metrics.md Outdated
@lmolkova lmolkova moved this from Untriaged to Awaiting SIG approval in Semantic Conventions Triage Apr 19, 2025
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 3, 2025

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions Bot added the Stale label May 3, 2025
@ChrsMark
Copy link
Copy Markdown
Member Author

ChrsMark commented May 5, 2025

Still valid, waiting for #2076..

@github-actions github-actions Bot removed the Stale label May 6, 2025
@ChrsMark ChrsMark force-pushed the add_k8s_resourcequota_metrics branch from 7b69824 to 3ed2067 Compare May 20, 2025 08:34
@ChrsMark ChrsMark force-pushed the add_k8s_resourcequota_metrics branch 4 times, most recently from 3efbe70 to e3c20fb Compare May 20, 2025 11:42
@ChrsMark
Copy link
Copy Markdown
Member Author

@jinja2 @dmitryax I have updated this PR based on #2076 (comment). Please take a look when you find the time. Thank's!

Comment thread model/k8s/metrics.yaml Outdated
Comment thread model/k8s/metrics.yaml Outdated
@ChrsMark ChrsMark requested a review from jinja2 May 21, 2025 07:48
@ChrsMark ChrsMark changed the title Add resourcequota cpu and memory metrics Add resourcequota metrics May 21, 2025
@ChrsMark ChrsMark force-pushed the add_k8s_resourcequota_metrics branch from 62032b3 to c737467 Compare June 6, 2025 14:37
@ChrsMark
Copy link
Copy Markdown
Member Author

ChrsMark commented Jun 6, 2025

@dashpole eventually I changed the instrument types to updowncounters (ref)

@jinja2 please take a look as well when you get the chance :)

Comment thread model/k8s/registry.yaml Outdated
@ChrsMark ChrsMark force-pushed the add_k8s_resourcequota_metrics branch from e90dd04 to f776b08 Compare June 10, 2025 07:57
Comment thread model/k8s/registry.yaml
Signed-off-by: ChrsMark <[email protected]>
@ChrsMark ChrsMark force-pushed the add_k8s_resourcequota_metrics branch from 2226e8d to a31fd3d Compare June 11, 2025 08:08
@ChrsMark ChrsMark requested review from dashpole and jinja2 June 11, 2025 08:09
Comment thread model/k8s/metrics.yaml
Signed-off-by: ChrsMark <[email protected]>
Comment thread model/k8s/metrics.yaml Outdated
Signed-off-by: ChrsMark <[email protected]>
@ChrsMark ChrsMark requested a review from jinja2 June 13, 2025 05:25
@ChrsMark ChrsMark moved this from In Review to Approved by K8s SIG in K8s SemConv SIG Jun 16, 2025
@ChrsMark ChrsMark moved this from Awaiting SIG approval to Needs More Approval in Semantic Conventions Triage Jun 16, 2025
@ChrsMark
Copy link
Copy Markdown
Member Author

This one has already 2 approvals from K8s SIG. @open-telemetry/specs-semconv-approvers @open-telemetry/specs-semconv-maintainers feel free to take a look :)

@jsuereth jsuereth added this pull request to the merge queue Jun 18, 2025
Merged via the queue into open-telemetry:main with commit 37fc32d Jun 18, 2025
14 checks passed
@github-project-automation github-project-automation Bot moved this from Approved by K8s SIG to Done in K8s SemConv SIG Jun 18, 2025
ChrsMark added a commit to ChrsMark/semantic-conventions that referenced this pull request Jun 18, 2025
ChrsMark added a commit to ChrsMark/semantic-conventions that referenced this pull request Jun 18, 2025
jherbage pushed a commit to jherbage/semantic-conventions that referenced this pull request Jul 1, 2025
spurplewang pushed a commit to spurplewang/semantic-conventions that referenced this pull request Jul 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:k8s enhancement New feature or request

Projects

Status: Done
Archived in project

Development

Successfully merging this pull request may close these issues.

[k8s] Define semantic conventions for k8s resource quota metrics

7 participants