Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions jsonnet/telemeter/rules.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -202,25 +202,25 @@
// returns 0 for any cluster reporting core capacity, used to improve performance of cluster:capacity_effective_cpu_cores
record: 'cluster:cpu_capacity_cores:_id',
expr: |||
group by(_id, tenant_id) (cluster:capacity_cpu_cores:sum{label_node_openshift_io_os_id="rhcos"}) * 0
group by(_id, tenant_id) (cluster:capacity_cpu_cores:sum{label_node_openshift_io_os_id=~"rhcos|rhel"}) * 0
Copy link
Copy Markdown

@juzhao juzhao Mar 26, 2026

Choose a reason for hiding this comment

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

label_node_openshift_io_os_id=~"rhcos|rhel"} is safe
I think since 4.19+ the os id is changed to rhel now, how about leave rhel only
label_node_openshift_io_os_id="rhel"}), same for others

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review! If we stop backporting this in 4.19+ then that'd be fine. Using only label_node_openshift_io_os_id="rhel" would fix 4.19+ but would stop matching clusters still on 4.18 and earlier, where the label remains rhcos.

My main concern here is that telemeter rules run against the full fleet, so we may need both values. The regex keeps backward compatibility with the original rhcos filter and adds rhel for 4.19+, wdyt?

Copy link
Copy Markdown

@juzhao juzhao Mar 26, 2026

Choose a reason for hiding this comment

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

I see, you are right, since the telemeter server side configuration only have main branch for production, example: https://github.com/rhobs/configuration/blob/main/resources/services/rhobs-thanos-operator/staging/telemeter-rules.yaml#L149-L160, keep rhcos is right for 4.18 and below, add rhel is for 4.19+, and seems we also need to update in the rhobs for the same after this PR merged

|||,
},
{
// OpenShift Cluster effective cores for subscription usage.
// This counts both worker nodes and, when the control plane is schedulable, control plane nodes.
// Only CoreOS nodes are counted.
// Only CoreOS nodes are counted (label_node_openshift_io_os_id rhcos on 4.18 and earlier, rhel on 4.19+).
// 1. x86_64 nodes need the cores value adjusted to account for 2 threads per core (* 0.5).
// 2. Other CPU architectures are assumed to have accurate values in cluster:capacity_cpu_cores:sum.
record: 'cluster:capacity_effective_cpu_cores',
expr: |||
# worker amd64
(sum by (_id, tenant_id) (cluster:capacity_cpu_cores:sum{label_node_openshift_io_os_id="rhcos",label_node_role_kubernetes_io!="master",label_node_role_kubernetes_io!="infra",label_kubernetes_io_arch="amd64"}) / 2.0 or cluster:cpu_capacity_cores:_id) +
(sum by (_id, tenant_id) (cluster:capacity_cpu_cores:sum{label_node_openshift_io_os_id=~"rhcos|rhel",label_node_role_kubernetes_io!="master",label_node_role_kubernetes_io!="infra",label_kubernetes_io_arch="amd64"}) / 2.0 or cluster:cpu_capacity_cores:_id) +
# worker non-amd64
(sum by (_id, tenant_id) (cluster:capacity_cpu_cores:sum{label_node_openshift_io_os_id="rhcos",label_node_role_kubernetes_io!="master",label_node_role_kubernetes_io!="infra",label_kubernetes_io_arch!="amd64"}) or cluster:cpu_capacity_cores:_id) +
(sum by (_id, tenant_id) (cluster:capacity_cpu_cores:sum{label_node_openshift_io_os_id=~"rhcos|rhel",label_node_role_kubernetes_io!="master",label_node_role_kubernetes_io!="infra",label_kubernetes_io_arch!="amd64"}) or cluster:cpu_capacity_cores:_id) +
# schedulable control plane amd64
(sum by (_id, tenant_id) (cluster:capacity_cpu_cores:sum{label_node_openshift_io_os_id="rhcos",label_node_role_kubernetes_io="master",label_kubernetes_io_arch="amd64"}) * on(_id, tenant_id) group by(_id, tenant_id) (cluster_master_schedulable == 1) / 2.0 or cluster:cpu_capacity_cores:_id) +
(sum by (_id, tenant_id) (cluster:capacity_cpu_cores:sum{label_node_openshift_io_os_id=~"rhcos|rhel",label_node_role_kubernetes_io="master",label_kubernetes_io_arch="amd64"}) * on(_id, tenant_id) group by(_id, tenant_id) (cluster_master_schedulable == 1) / 2.0 or cluster:cpu_capacity_cores:_id) +
# schedulable control plane non-amd64
(sum by (_id, tenant_id) (cluster:capacity_cpu_cores:sum{label_node_openshift_io_os_id="rhcos",label_node_role_kubernetes_io="master",label_kubernetes_io_arch!="amd64"}) * on(_id, tenant_id) group by(_id, tenant_id) (cluster_master_schedulable == 1) or cluster:cpu_capacity_cores:_id)
(sum by (_id, tenant_id) (cluster:capacity_cpu_cores:sum{label_node_openshift_io_os_id=~"rhcos|rhel",label_node_role_kubernetes_io="master",label_kubernetes_io_arch!="amd64"}) * on(_id, tenant_id) group by(_id, tenant_id) (cluster_master_schedulable == 1) or cluster:cpu_capacity_cores:_id)
|||,
},
{
Expand Down
10 changes: 10 additions & 0 deletions test/rulestests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ tests:
exp_samples:
- labels: 'cluster:capacity_effective_cpu_cores{_id="non-amd64_infra",tenant_id="tenant_id"}'
value: 0
# cluster:capacity_effective_cpu_cores — 4.19+ nodes expose label_node_openshift_io_os_id=rhel (still CoreOS)
- input_series:
- series: 'cluster:capacity_cpu_cores:sum{label_node_openshift_io_os_id="rhel",label_kubernetes_io_arch="amd64",_id="rhel_amd64_worker",tenant_id="tenant_id"}'
values: '8'
promql_expr_test:
- expr: cluster:capacity_effective_cpu_cores{_id="rhel_amd64_worker"}
eval_time: 0
exp_samples:
- labels: 'cluster:capacity_effective_cpu_cores{_id="rhel_amd64_worker",tenant_id="tenant_id"}'
value: 4
# acm_capacity_effective_cpu_cores tests
- input_series:
# self-managed OpenShift cluster
Expand Down