mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-07 22:25:03 +00:00
Add test for custom label
This commit is contained in:
parent
c040fd431e
commit
7a5a0595c4
1 changed files with 27 additions and 0 deletions
|
|
@ -116,6 +116,18 @@ func TestMetricNamerContainerSeries(t *testing.T) {
|
||||||
isContainer: true,
|
isContainer: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
input: prom.Series{
|
||||||
|
Name: "container_some_time_seconds_total{status=\"success\"}",
|
||||||
|
Labels: pmodel.LabelSet{"status": "success", "pod_name": "somepod", "namespace": "somens", "container_name": "somecont"},
|
||||||
|
},
|
||||||
|
outputMetricName: "some_time",
|
||||||
|
outputInfo: seriesInfo{
|
||||||
|
baseSeries: prom.Series{Name: "container_some_time_seconds_total"},
|
||||||
|
kind: SecondsCounterSeries,
|
||||||
|
isContainer: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
@ -207,6 +219,10 @@ func TestSeriesRegistry(t *testing.T) {
|
||||||
Name: "admin_reddit_seconds_total",
|
Name: "admin_reddit_seconds_total",
|
||||||
Labels: pmodel.LabelSet{"kube_admin": "some-admin"},
|
Labels: pmodel.LabelSet{"kube_admin": "some-admin"},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "service_proxy_packets{protocol=\"tcp\"}",
|
||||||
|
Labels: pmodel.LabelSet{"protocol": "tcp", "kube_service": "somesvc", "kube_namespace": "somens"},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// set up the registry
|
// set up the registry
|
||||||
|
|
@ -335,6 +351,15 @@ func TestSeriesRegistry(t *testing.T) {
|
||||||
expectedKind: SecondsCounterSeries,
|
expectedKind: SecondsCounterSeries,
|
||||||
expectedQuery: "node_fan_seconds_total{kube_node=\"somenode\"}",
|
expectedQuery: "node_fan_seconds_total{kube_node=\"somenode\"}",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: "namespaced metrics gauge",
|
||||||
|
info: provider.MetricInfo{schema.GroupResource{Resource: "service"}, true, "service_proxy_packets"},
|
||||||
|
namespace: "somens",
|
||||||
|
resourceNames: []string{"somesvc"},
|
||||||
|
|
||||||
|
expectedKind: GaugeSeries,
|
||||||
|
expectedQuery: "service_proxy_packets{kube_service=\"somesvc\",kube_namespace=\"somens\"}",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
|
|
@ -370,6 +395,8 @@ func TestSeriesRegistry(t *testing.T) {
|
||||||
{schema.GroupResource{Resource: "nodes"}, false, "node_gigawatts"},
|
{schema.GroupResource{Resource: "nodes"}, false, "node_gigawatts"},
|
||||||
{schema.GroupResource{Resource: "persistentvolumes"}, false, "volume_claims"},
|
{schema.GroupResource{Resource: "persistentvolumes"}, false, "volume_claims"},
|
||||||
{schema.GroupResource{Resource: "nodes"}, false, "node_fan"},
|
{schema.GroupResource{Resource: "nodes"}, false, "node_fan"},
|
||||||
|
{schema.GroupResource{Resource: "services"}, true, "service_proxy_packets{protocol=\"tcp\"}"},
|
||||||
|
{schema.GroupResource{Resource: "namespaces"}, false, "service_proxy_packets{protocol=\"tcp\"}"},
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort both for easy comparison
|
// sort both for easy comparison
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue