Skip to content

Add result object namespace to the metrics #681

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

Merged

Conversation

koshkarov
Copy link
Contributor

@koshkarov koshkarov commented Apr 30, 2025

Closes #

📑 Description

This feature adds a result object namespace to the k8sgpt_number_of_results and k8sgpt_number_of_results_by_type metrics, enabling the creation of more granular dashboards.

Currently, we can only see the total number of results and result types across the cluster. With this change, we will be able to query results by the namespace of the result object.

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

ℹ Additional Information

Initiaal slack thread: https://k8sgpt.slack.com/archives/C050SKW7SHF/p1745417335572699

Testing

Covered with unit tests
Performed testing running the operator in Local mode with in-cluster K8sGPT service:

# HELP k8sgpt_number_of_results The total number of results
# TYPE k8sgpt_number_of_results gauge
k8sgpt_number_of_results{k8sgpt="k8sgpt-cluster-config",object_namespace="fortio"} 1
k8sgpt_number_of_results{k8sgpt="k8sgpt-cluster-config",object_namespace="istio-system"} 1
k8sgpt_number_of_results{k8sgpt="k8sgpt-cluster-config",object_namespace="k8sgpt-operator-system"} 2
k8sgpt_number_of_results{k8sgpt="k8sgpt-cluster-config",object_namespace="kube-system"} 3
# HELP k8sgpt_number_of_results_by_type The total number of results by type
# TYPE k8sgpt_number_of_results_by_type gauge
k8sgpt_number_of_results_by_type{k8sgpt="k8sgpt-cluster-config",kind="Service",name="fortio/fortio-server-deployment-2-canary",object_namespace="fortio"} 1
k8sgpt_number_of_results_by_type{k8sgpt="k8sgpt-cluster-config",kind="Service",name="k8sgpt-operator-system/k8sgpt-k8sgpt-operat-controller-manager-metrics-service",object_namespace="k8sgpt-operator-system"} 1
k8sgpt_number_of_results_by_type{k8sgpt="k8sgpt-cluster-config",kind="Service",name="kube-system/kube-prometheus-stack-kube-controller-manager",object_namespace="kube-system"} 1
k8sgpt_number_of_results_by_type{k8sgpt="k8sgpt-cluster-config",kind="Service",name="kube-system/kube-prometheus-stack-kube-etcd",object_namespace="kube-system"} 1
k8sgpt_number_of_results_by_type{k8sgpt="k8sgpt-cluster-config",kind="Service",name="kube-system/kube-prometheus-stack-kube-scheduler",object_namespace="kube-system"} 1
k8sgpt_number_of_results_by_type{k8sgpt="k8sgpt-cluster-config",kind="StatefulSet",name="k8sgpt-operator-system/k8sgpt-interplex",object_namespace="k8sgpt-operator-system"} 1

… k8sgpt_number_of_results_by_type metrics

Signed-off-by: Volodymyr Koshkarov <volodymyr.koshkarov@gmail.com>
@koshkarov koshkarov force-pushed the add-result-target-namespace-to-metrics branch from ecc1586 to e5fa8a6 Compare May 1, 2025 15:48
@koshkarov koshkarov marked this pull request as ready for review May 1, 2025 15:53
@koshkarov koshkarov requested review from a team as code owners May 1, 2025 15:53
@AlexsJones AlexsJones merged commit ad791b4 into k8sgpt-ai:main May 1, 2025
6 of 7 checks passed
@koshkarov koshkarov deleted the add-result-target-namespace-to-metrics branch May 1, 2025 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants