forked from grafana/mimir
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix .metricsUsed in mimirtool analyze rule-file (grafana#6953)
* Fix .metricsUsed in mimirtool analyze rule-file This field wasn't populated. Fixes grafana#6952 Signed-off-by: Oleg Zaytsev <[email protected]> * Update CHANGELOG.md Signed-off-by: Oleg Zaytsev <[email protected]> * make license Signed-off-by: Oleg Zaytsev <[email protected]> --------- Signed-off-by: Oleg Zaytsev <[email protected]>
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
package commands | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/prometheus/common/model" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestAnalyzeRuleFiles(t *testing.T) { | ||
mir, err := AnalyzeRuleFiles([]string{"testdata/prometheus_rules.yaml"}) | ||
require.NoError(t, err) | ||
require.Equal(t, 24, len(mir.MetricsUsed)) | ||
expectedMetrics := model.LabelValues{ | ||
"apiserver_request_duration_seconds_bucket", | ||
"apiserver_request_duration_seconds_count", | ||
"apiserver_request_total", | ||
"container_memory_cache", | ||
"container_memory_rss", | ||
"container_memory_swap", | ||
"container_memory_working_set_bytes", | ||
"kube_pod_container_resource_limits", | ||
"kube_pod_container_resource_requests", | ||
"kube_pod_info", | ||
"kube_pod_owner", | ||
"kube_pod_status_phase", | ||
"kube_replicaset_owner", | ||
"kubelet_node_name", | ||
"kubelet_pleg_relist_duration_seconds_bucket", | ||
"node_cpu_seconds_total", | ||
"node_memory_Buffers_bytes", | ||
"node_memory_Cached_bytes", | ||
"node_memory_MemAvailable_bytes", | ||
"node_memory_MemFree_bytes", | ||
"node_memory_Slab_bytes", | ||
"scheduler_binding_duration_seconds_bucket", | ||
"scheduler_e2e_scheduling_duration_seconds_bucket", | ||
"scheduler_scheduling_algorithm_duration_seconds_bucket", | ||
} | ||
require.Equal(t, expectedMetrics, mir.MetricsUsed) | ||
} |