Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[k8sclusterreceiver] add pod status reason as a metric #24034

Closed
povilasv opened this issue Jul 7, 2023 · 5 comments
Closed

[k8sclusterreceiver] add pod status reason as a metric #24034

povilasv opened this issue Jul 7, 2023 · 5 comments
Labels

Comments

@povilasv
Copy link
Contributor

povilasv commented Jul 7, 2023

Component(s)

receiver/k8scluster

Is your feature request related to a problem? Please describe.

I would like to get pod status reason as a metric:

In Kube State metrics there are 5 pod reasons being reported - "Evicted", "NodeAffinity", "NodeLost", "Shutdown", "UnexpectedAdmissionError"

In practice it looks like this:

kube_pod_status_reason{pod="otel-traces-app-59dccdc594-8x28b", reason="Evicted"}
0
kube_pod_status_reason{pod="otel-traces-app-59dccdc594-8x28b", reason="NodeAffinity"}
0
kube_pod_status_reason{pod="otel-traces-app-59dccdc594-8x28b", reason="NodeLost"}
0
kube_pod_status_reason{pod="otel-traces-app-59dccdc594-8x28b", reason="Shutdown"}
0
kube_pod_status_reason{pod="otel-traces-app-59dccdc594-8x28b", reason="UnexpectedAdmissionError"}

K8s API docs describe this field as:

	// A brief CamelCase message indicating details about why the pod is in this state.
	// e.g. 'Evicted'
	// +optional
	Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"`

Example from K8s kubectl get po -o yaml:

  message: 'The node was low on resource: ephemeral-storage. '
  phase: Failed
  qosClass: Burstable
  reason: Evicted
  startTime: "2023-07-21T10:44:19Z"

Any thoughts?

Describe the solution you'd like

There are two possible solutions:

  • Add 5 metrics as gauges set to either 0 or 1 (similiar to k8s.node.conditon_ready, k8s.node.condition_pid_pressure)

Alternatively:

  • we could encode to numbers, similarly as we do for pod phase:
func phaseToInt(phase corev1.PodPhase) int32 {
	switch phase {
	case corev1.PodPending:
		return 1
	case corev1.PodRunning:
		return 2
	case corev1.PodSucceeded:
		return 3
	case corev1.PodFailed:
		return 4
	case corev1.PodUnknown:
		return 5
	default:
		return 5
	}
}

I can work on this :)

Describe alternatives you've considered

No response

Additional context

No response

@povilasv povilasv added enhancement New feature or request needs triage New item requiring triage labels Jul 7, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jul 7, 2023

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@povilasv
Copy link
Contributor Author

povilasv commented Jul 7, 2023

REF #21234

@povilasv povilasv changed the title [k8sclusterreceiver] adding pod status reason as a metric [k8sclusterreceiver] add pod status reason as a metric Jul 21, 2023
@atoulme atoulme added receiver/k8scluster and removed needs triage New item requiring triage labels Jul 21, 2023
@github-actions
Copy link
Contributor

Pinging code owners for receiver/k8scluster: @dmitryax. See Adding Labels via Comments if you do not have permissions to add labels yourself.

@dmitryax
Copy link
Member

dmitryax commented Jul 21, 2023

If we add pod status reason as several metrics, we will also need to change the pod phase metric the same way. I wouldn't like to make this change to pod state metric until we have strict guidelines from the OTel Spec on how to represent this kind of data

If you want the pod state reason added right now, we can add it as one metric for consistency with the pod state and keep it optional (disabled by default) for now. Later we can reconsider it once we bring all the k8s metrics to the Semantic conventions.

But before that, we need to finalize #4367 to be able to add optional metrics at all.

@povilasv
Copy link
Contributor Author

povilasv commented Jul 26, 2023

Created an issue for optional metrics in #24568

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants