Skip to content

Commit

Permalink
use metric list during check
Browse files Browse the repository at this point in the history
  • Loading branch information
bdrennz committed Dec 3, 2024
1 parent 14b87d4 commit e68ec94
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/diagnostic/kms/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (c *checker) Check(_ context.Context, client *http.Client, accessor status.
}

metrics := string(body)
requiredMetrics := []string{"kube_pod_info", "kube_node_info"} // Add the required metrics here
requiredMetrics := c.cfg.Prometheus.KubeMetrics // Use the required metrics from the configuration
for _, metric := range requiredMetrics {
if !strings.Contains(metrics, metric) {
c.logger.Errorf("Required metric %s not found on attempt %d", metric, attempt)
Expand Down
5 changes: 5 additions & 0 deletions pkg/diagnostic/kms/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func TestChecker_CheckOK(t *testing.T) {
cfg := &config.Settings{
Prometheus: config.Prometheus{
KubeStateMetricsServiceEndpoint: mockURL,
KubeMetrics: []string{"kube_pod_info", "kube_node_info"},
},
}
clientset := fake.NewSimpleClientset()
Expand Down Expand Up @@ -80,6 +81,7 @@ func TestChecker_CheckRetry(t *testing.T) {
cfg := &config.Settings{
Prometheus: config.Prometheus{
KubeStateMetricsServiceEndpoint: mockURL,
KubeMetrics: []string{"kube_pod_info", "kube_node_info"},
},
}
clientset := fake.NewSimpleClientset()
Expand Down Expand Up @@ -114,6 +116,7 @@ func TestChecker_CheckRetryFailure(t *testing.T) {
cfg := &config.Settings{
Prometheus: config.Prometheus{
KubeStateMetricsServiceEndpoint: mockURL,
KubeMetrics: []string{"kube_pod_info", "kube_node_info"},
},
}
clientset := fake.NewSimpleClientset()
Expand Down Expand Up @@ -147,6 +150,7 @@ func TestChecker_CheckMetricsValidation(t *testing.T) {
cfg := &config.Settings{
Prometheus: config.Prometheus{
KubeStateMetricsServiceEndpoint: mockURL,
KubeMetrics: []string{"kube_pod_info", "kube_node_info"},
},
}
clientset := fake.NewSimpleClientset()
Expand Down Expand Up @@ -174,6 +178,7 @@ func TestChecker_CheckHandles500Error(t *testing.T) {
cfg := &config.Settings{
Prometheus: config.Prometheus{
KubeStateMetricsServiceEndpoint: mockURL,
KubeMetrics: []string{"kube_pod_info", "kube_node_info"},
},
}
clientset := fake.NewSimpleClientset()
Expand Down

0 comments on commit e68ec94

Please sign in to comment.