mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-06 01:38:10 +00:00
Merge pull request #386 from aackerman/aackerman/fix-metric-labels
Fix documented metrics labels to work for k8s 1.16+
This commit is contained in:
commit
c41a99a529
7 changed files with 51 additions and 51 deletions
|
|
@ -12,50 +12,50 @@ import (
|
||||||
// DefaultConfig returns a configuration equivalent to the former
|
// DefaultConfig returns a configuration equivalent to the former
|
||||||
// pre-advanced-config settings. This means that "normal" series labels
|
// pre-advanced-config settings. This means that "normal" series labels
|
||||||
// will be of the form `<prefix><<.Resource>>`, cadvisor series will be
|
// will be of the form `<prefix><<.Resource>>`, cadvisor series will be
|
||||||
// of the form `container_`, and have the label `pod_name`. Any series ending
|
// of the form `container_`, and have the label `pod`. Any series ending
|
||||||
// in total will be treated as a rate metric.
|
// in total will be treated as a rate metric.
|
||||||
func DefaultConfig(rateInterval time.Duration, labelPrefix string) *MetricsDiscoveryConfig {
|
func DefaultConfig(rateInterval time.Duration, labelPrefix string) *MetricsDiscoveryConfig {
|
||||||
return &MetricsDiscoveryConfig{
|
return &MetricsDiscoveryConfig{
|
||||||
Rules: []DiscoveryRule{
|
Rules: []DiscoveryRule{
|
||||||
// container seconds rate metrics
|
// container seconds rate metrics
|
||||||
{
|
{
|
||||||
SeriesQuery: string(prom.MatchSeries("", prom.NameMatches("^container_.*"), prom.LabelNeq("container_name", "POD"), prom.LabelNeq("namespace", ""), prom.LabelNeq("pod_name", ""))),
|
SeriesQuery: string(prom.MatchSeries("", prom.NameMatches("^container_.*"), prom.LabelNeq("container", "POD"), prom.LabelNeq("namespace", ""), prom.LabelNeq("pod", ""))),
|
||||||
Resources: ResourceMapping{
|
Resources: ResourceMapping{
|
||||||
Overrides: map[string]GroupResource{
|
Overrides: map[string]GroupResource{
|
||||||
"namespace": {Resource: "namespace"},
|
"namespace": {Resource: "namespace"},
|
||||||
"pod_name": {Resource: "pod"},
|
"pod": {Resource: "pod"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Name: NameMapping{Matches: "^container_(.*)_seconds_total$"},
|
Name: NameMapping{Matches: "^container_(.*)_seconds_total$"},
|
||||||
MetricsQuery: fmt.Sprintf(`sum(rate(<<.Series>>{<<.LabelMatchers>>,container_name!="POD"}[%s])) by (<<.GroupBy>>)`, pmodel.Duration(rateInterval).String()),
|
MetricsQuery: fmt.Sprintf(`sum(rate(<<.Series>>{<<.LabelMatchers>>,container!="POD"}[%s])) by (<<.GroupBy>>)`, pmodel.Duration(rateInterval).String()),
|
||||||
},
|
},
|
||||||
|
|
||||||
// container rate metrics
|
// container rate metrics
|
||||||
{
|
{
|
||||||
SeriesQuery: string(prom.MatchSeries("", prom.NameMatches("^container_.*"), prom.LabelNeq("container_name", "POD"), prom.LabelNeq("namespace", ""), prom.LabelNeq("pod_name", ""))),
|
SeriesQuery: string(prom.MatchSeries("", prom.NameMatches("^container_.*"), prom.LabelNeq("container", "POD"), prom.LabelNeq("namespace", ""), prom.LabelNeq("pod", ""))),
|
||||||
SeriesFilters: []RegexFilter{{IsNot: "^container_.*_seconds_total$"}},
|
SeriesFilters: []RegexFilter{{IsNot: "^container_.*_seconds_total$"}},
|
||||||
Resources: ResourceMapping{
|
Resources: ResourceMapping{
|
||||||
Overrides: map[string]GroupResource{
|
Overrides: map[string]GroupResource{
|
||||||
"namespace": {Resource: "namespace"},
|
"namespace": {Resource: "namespace"},
|
||||||
"pod_name": {Resource: "pod"},
|
"pod": {Resource: "pod"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Name: NameMapping{Matches: "^container_(.*)_total$"},
|
Name: NameMapping{Matches: "^container_(.*)_total$"},
|
||||||
MetricsQuery: fmt.Sprintf(`sum(rate(<<.Series>>{<<.LabelMatchers>>,container_name!="POD"}[%s])) by (<<.GroupBy>>)`, pmodel.Duration(rateInterval).String()),
|
MetricsQuery: fmt.Sprintf(`sum(rate(<<.Series>>{<<.LabelMatchers>>,container!="POD"}[%s])) by (<<.GroupBy>>)`, pmodel.Duration(rateInterval).String()),
|
||||||
},
|
},
|
||||||
|
|
||||||
// container non-cumulative metrics
|
// container non-cumulative metrics
|
||||||
{
|
{
|
||||||
SeriesQuery: string(prom.MatchSeries("", prom.NameMatches("^container_.*"), prom.LabelNeq("container_name", "POD"), prom.LabelNeq("namespace", ""), prom.LabelNeq("pod_name", ""))),
|
SeriesQuery: string(prom.MatchSeries("", prom.NameMatches("^container_.*"), prom.LabelNeq("container", "POD"), prom.LabelNeq("namespace", ""), prom.LabelNeq("pod", ""))),
|
||||||
SeriesFilters: []RegexFilter{{IsNot: "^container_.*_total$"}},
|
SeriesFilters: []RegexFilter{{IsNot: "^container_.*_total$"}},
|
||||||
Resources: ResourceMapping{
|
Resources: ResourceMapping{
|
||||||
Overrides: map[string]GroupResource{
|
Overrides: map[string]GroupResource{
|
||||||
"namespace": {Resource: "namespace"},
|
"namespace": {Resource: "namespace"},
|
||||||
"pod_name": {Resource: "pod"},
|
"pod": {Resource: "pod"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Name: NameMapping{Matches: "^container_(.*)$"},
|
Name: NameMapping{Matches: "^container_(.*)$"},
|
||||||
MetricsQuery: `sum(<<.Series>>{<<.LabelMatchers>>,container_name!="POD"}) by (<<.GroupBy>>)`,
|
MetricsQuery: `sum(<<.Series>>{<<.LabelMatchers>>,container!="POD"}) by (<<.GroupBy>>)`,
|
||||||
},
|
},
|
||||||
|
|
||||||
// normal non-cumulative metrics
|
// normal non-cumulative metrics
|
||||||
|
|
@ -97,11 +97,11 @@ func DefaultConfig(rateInterval time.Duration, labelPrefix string) *MetricsDisco
|
||||||
Resources: ResourceMapping{
|
Resources: ResourceMapping{
|
||||||
Overrides: map[string]GroupResource{
|
Overrides: map[string]GroupResource{
|
||||||
"namespace": {Resource: "namespace"},
|
"namespace": {Resource: "namespace"},
|
||||||
"pod_name": {Resource: "pod"},
|
"pod": {Resource: "pod"},
|
||||||
"instance": {Resource: "node"},
|
"instance": {Resource: "node"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ContainerLabel: fmt.Sprintf("%scontainer_name", labelPrefix),
|
ContainerLabel: fmt.Sprintf("%scontainer", labelPrefix),
|
||||||
},
|
},
|
||||||
Memory: ResourceRule{
|
Memory: ResourceRule{
|
||||||
ContainerQuery: "sum(container_memory_working_set_bytes{<<.LabelMatchers>>}) by (<<.GroupBy>>)",
|
ContainerQuery: "sum(container_memory_working_set_bytes{<<.LabelMatchers>>}) by (<<.GroupBy>>)",
|
||||||
|
|
@ -109,11 +109,11 @@ func DefaultConfig(rateInterval time.Duration, labelPrefix string) *MetricsDisco
|
||||||
Resources: ResourceMapping{
|
Resources: ResourceMapping{
|
||||||
Overrides: map[string]GroupResource{
|
Overrides: map[string]GroupResource{
|
||||||
"namespace": {Resource: "namespace"},
|
"namespace": {Resource: "namespace"},
|
||||||
"pod_name": {Resource: "pod"},
|
"pod": {Resource: "pod"},
|
||||||
"instance": {Resource: "node"},
|
"instance": {Resource: "node"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ContainerLabel: fmt.Sprintf("%scontainer_name", labelPrefix),
|
ContainerLabel: fmt.Sprintf("%scontainer", labelPrefix),
|
||||||
},
|
},
|
||||||
Window: pmodel.Duration(rateInterval),
|
Window: pmodel.Duration(rateInterval),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -6,44 +6,44 @@ metadata:
|
||||||
data:
|
data:
|
||||||
config.yaml: |
|
config.yaml: |
|
||||||
rules:
|
rules:
|
||||||
- seriesQuery: '{__name__=~"^container_.*",container_name!="POD",namespace!="",pod_name!=""}'
|
- seriesQuery: '{__name__=~"^container_.*",container!="POD",namespace!="",pod!=""}'
|
||||||
seriesFilters: []
|
seriesFilters: []
|
||||||
resources:
|
resources:
|
||||||
overrides:
|
overrides:
|
||||||
namespace:
|
namespace:
|
||||||
resource: namespace
|
resource: namespace
|
||||||
pod_name:
|
pod:
|
||||||
resource: pod
|
resource: pod
|
||||||
name:
|
name:
|
||||||
matches: ^container_(.*)_seconds_total$
|
matches: ^container_(.*)_seconds_total$
|
||||||
as: ""
|
as: ""
|
||||||
metricsQuery: sum(rate(<<.Series>>{<<.LabelMatchers>>,container_name!="POD"}[1m])) by (<<.GroupBy>>)
|
metricsQuery: sum(rate(<<.Series>>{<<.LabelMatchers>>,container!="POD"}[1m])) by (<<.GroupBy>>)
|
||||||
- seriesQuery: '{__name__=~"^container_.*",container_name!="POD",namespace!="",pod_name!=""}'
|
- seriesQuery: '{__name__=~"^container_.*",container!="POD",namespace!="",pod!=""}'
|
||||||
seriesFilters:
|
seriesFilters:
|
||||||
- isNot: ^container_.*_seconds_total$
|
- isNot: ^container_.*_seconds_total$
|
||||||
resources:
|
resources:
|
||||||
overrides:
|
overrides:
|
||||||
namespace:
|
namespace:
|
||||||
resource: namespace
|
resource: namespace
|
||||||
pod_name:
|
pod:
|
||||||
resource: pod
|
resource: pod
|
||||||
name:
|
name:
|
||||||
matches: ^container_(.*)_total$
|
matches: ^container_(.*)_total$
|
||||||
as: ""
|
as: ""
|
||||||
metricsQuery: sum(rate(<<.Series>>{<<.LabelMatchers>>,container_name!="POD"}[1m])) by (<<.GroupBy>>)
|
metricsQuery: sum(rate(<<.Series>>{<<.LabelMatchers>>,container!="POD"}[1m])) by (<<.GroupBy>>)
|
||||||
- seriesQuery: '{__name__=~"^container_.*",container_name!="POD",namespace!="",pod_name!=""}'
|
- seriesQuery: '{__name__=~"^container_.*",container!="POD",namespace!="",pod!=""}'
|
||||||
seriesFilters:
|
seriesFilters:
|
||||||
- isNot: ^container_.*_total$
|
- isNot: ^container_.*_total$
|
||||||
resources:
|
resources:
|
||||||
overrides:
|
overrides:
|
||||||
namespace:
|
namespace:
|
||||||
resource: namespace
|
resource: namespace
|
||||||
pod_name:
|
pod:
|
||||||
resource: pod
|
resource: pod
|
||||||
name:
|
name:
|
||||||
matches: ^container_(.*)$
|
matches: ^container_(.*)$
|
||||||
as: ""
|
as: ""
|
||||||
metricsQuery: sum(<<.Series>>{<<.LabelMatchers>>,container_name!="POD"}) by (<<.GroupBy>>)
|
metricsQuery: sum(<<.Series>>{<<.LabelMatchers>>,container!="POD"}) by (<<.GroupBy>>)
|
||||||
- seriesQuery: '{namespace!="",__name__!~"^container_.*"}'
|
- seriesQuery: '{namespace!="",__name__!~"^container_.*"}'
|
||||||
seriesFilters:
|
seriesFilters:
|
||||||
- isNot: .*_total$
|
- isNot: .*_total$
|
||||||
|
|
@ -80,9 +80,9 @@ data:
|
||||||
resource: node
|
resource: node
|
||||||
namespace:
|
namespace:
|
||||||
resource: namespace
|
resource: namespace
|
||||||
pod_name:
|
pod:
|
||||||
resource: pod
|
resource: pod
|
||||||
containerLabel: container_name
|
containerLabel: container
|
||||||
memory:
|
memory:
|
||||||
containerQuery: sum(container_memory_working_set_bytes{<<.LabelMatchers>>}) by (<<.GroupBy>>)
|
containerQuery: sum(container_memory_working_set_bytes{<<.LabelMatchers>>}) by (<<.GroupBy>>)
|
||||||
nodeQuery: sum(container_memory_working_set_bytes{<<.LabelMatchers>>,id='/'}) by (<<.GroupBy>>)
|
nodeQuery: sum(container_memory_working_set_bytes{<<.LabelMatchers>>,id='/'}) by (<<.GroupBy>>)
|
||||||
|
|
@ -92,9 +92,9 @@ data:
|
||||||
resource: node
|
resource: node
|
||||||
namespace:
|
namespace:
|
||||||
resource: namespace
|
resource: namespace
|
||||||
pod_name:
|
pod:
|
||||||
resource: pod
|
resource: pod
|
||||||
containerLabel: container_name
|
containerLabel: container
|
||||||
window: 1m
|
window: 1m
|
||||||
externalRules:
|
externalRules:
|
||||||
- seriesQuery: '{__name__=~"^.*_queue_(length|size)$",namespace!=""}'
|
- seriesQuery: '{__name__=~"^.*_queue_(length|size)$",namespace!=""}'
|
||||||
|
|
|
||||||
|
|
@ -31,13 +31,13 @@ might look like:
|
||||||
```yaml
|
```yaml
|
||||||
rules:
|
rules:
|
||||||
# this rule matches cumulative cAdvisor metrics measured in seconds
|
# this rule matches cumulative cAdvisor metrics measured in seconds
|
||||||
- seriesQuery: '{__name__=~"^container_.*",container_name!="POD",namespace!="",pod_name!=""}'
|
- seriesQuery: '{__name__=~"^container_.*",container!="POD",namespace!="",pod!=""}'
|
||||||
resources:
|
resources:
|
||||||
# skip specifying generic resource<->label mappings, and just
|
# skip specifying generic resource<->label mappings, and just
|
||||||
# attach only pod and namespace resources by mapping label names to group-resources
|
# attach only pod and namespace resources by mapping label names to group-resources
|
||||||
overrides:
|
overrides:
|
||||||
namespace: {resource: "namespace"},
|
namespace: {resource: "namespace"},
|
||||||
pod_name: {resource: "pod"},
|
pod: {resource: "pod"},
|
||||||
# specify that the `container_` and `_seconds_total` suffixes should be removed.
|
# specify that the `container_` and `_seconds_total` suffixes should be removed.
|
||||||
# this also introduces an implicit filter on metric family names
|
# this also introduces an implicit filter on metric family names
|
||||||
name:
|
name:
|
||||||
|
|
@ -48,7 +48,7 @@ rules:
|
||||||
# This is a Go template where the `.Series` and `.LabelMatchers` string values
|
# This is a Go template where the `.Series` and `.LabelMatchers` string values
|
||||||
# are available, and the delimiters are `<<` and `>>` to avoid conflicts with
|
# are available, and the delimiters are `<<` and `>>` to avoid conflicts with
|
||||||
# the prometheus query language
|
# the prometheus query language
|
||||||
metricsQuery: "sum(rate(<<.Series>>{<<.LabelMatchers>>,container_name!="POD"}[2m])) by (<<.GroupBy>>)"
|
metricsQuery: "sum(rate(<<.Series>>{<<.LabelMatchers>>,container!="POD"}[2m])) by (<<.GroupBy>>)"
|
||||||
```
|
```
|
||||||
|
|
||||||
Discovery
|
Discovery
|
||||||
|
|
@ -83,7 +83,7 @@ For example:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# match all cAdvisor metrics that aren't measured in seconds
|
# match all cAdvisor metrics that aren't measured in seconds
|
||||||
seriesQuery: '{__name__=~"^container_.*_total",container_name!="POD",namespace!="",pod_name!=""}'
|
seriesQuery: '{__name__=~"^container_.*_total",container!="POD",namespace!="",pod!=""}'
|
||||||
seriesFilters:
|
seriesFilters:
|
||||||
- isNot: "^container_.*_seconds_total"
|
- isNot: "^container_.*_seconds_total"
|
||||||
```
|
```
|
||||||
|
|
@ -211,5 +211,5 @@ For example:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# convert cumulative cAdvisor metrics into rates calculated over 2 minutes
|
# convert cumulative cAdvisor metrics into rates calculated over 2 minutes
|
||||||
metricsQuery: "sum(rate(<<.Series>>{<<.LabelMatchers>>,container_name!="POD"}[2m])) by (<<.GroupBy>>)"
|
metricsQuery: "sum(rate(<<.Series>>{<<.LabelMatchers>>,container!="POD"}[2m])) by (<<.GroupBy>>)"
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -10,16 +10,16 @@ rules:
|
||||||
# can be found in pkg/config/default.go
|
# can be found in pkg/config/default.go
|
||||||
|
|
||||||
# this rule matches cumulative cAdvisor metrics measured in seconds
|
# this rule matches cumulative cAdvisor metrics measured in seconds
|
||||||
- seriesQuery: '{__name__=~"^container_.*",container_name!="POD",namespace!="",pod_name!=""}'
|
- seriesQuery: '{__name__=~"^container_.*",container!="POD",namespace!="",pod!=""}'
|
||||||
resources:
|
resources:
|
||||||
# skip specifying generic resource<->label mappings, and just
|
# skip specifying generic resource<->label mappings, and just
|
||||||
# attach only pod and namespace resources by mapping label names to group-resources
|
# attach only pod and namespace resources by mapping label names to group-resources
|
||||||
overrides:
|
overrides:
|
||||||
namespace: {resource: "namespace"},
|
namespace: {resource: "namespace"},
|
||||||
pod_name: {resource: "pod"},
|
pod: {resource: "pod"},
|
||||||
# specify that the `container_` and `_seconds_total` suffixes should be removed.
|
# specify that the `container_` and `_seconds_total` suffixes should be removed.
|
||||||
# this also introduces an implicit filter on metric family names
|
# this also introduces an implicit filter on metric family names
|
||||||
name:
|
name:
|
||||||
# we use the value of the capture group implicitly as the API name
|
# we use the value of the capture group implicitly as the API name
|
||||||
# we could also explicitly write `as: "$1"`
|
# we could also explicitly write `as: "$1"`
|
||||||
matches: "^container_(.*)_seconds_total$"
|
matches: "^container_(.*)_seconds_total$"
|
||||||
|
|
@ -27,19 +27,19 @@ rules:
|
||||||
# This is a Go template where the `.Series` and `.LabelMatchers` string values
|
# This is a Go template where the `.Series` and `.LabelMatchers` string values
|
||||||
# are available, and the delimiters are `<<` and `>>` to avoid conflicts with
|
# are available, and the delimiters are `<<` and `>>` to avoid conflicts with
|
||||||
# the prometheus query language
|
# the prometheus query language
|
||||||
metricsQuery: "sum(rate(<<.Series>>{<<.LabelMatchers>>,container_name!="POD"}[2m])) by (<<.GroupBy>>)"
|
metricsQuery: "sum(rate(<<.Series>>{<<.LabelMatchers>>,container!="POD"}[2m])) by (<<.GroupBy>>)"
|
||||||
|
|
||||||
# this rule matches cumulative cAdvisor metrics not measured in seconds
|
# this rule matches cumulative cAdvisor metrics not measured in seconds
|
||||||
- seriesQuery: '{__name__=~"^container_.*_total",container_name!="POD",namespace!="",pod_name!=""}'
|
- seriesQuery: '{__name__=~"^container_.*_total",container!="POD",namespace!="",pod!=""}'
|
||||||
resources:
|
resources:
|
||||||
overrides:
|
overrides:
|
||||||
namespace: {resource: "namespace"},
|
namespace: {resource: "namespace"},
|
||||||
pod_name: {resource: "pod"},
|
pod: {resource: "pod"},
|
||||||
seriesFilters:
|
seriesFilters:
|
||||||
# since this is a superset of the query above, we introduce an additional filter here
|
# since this is a superset of the query above, we introduce an additional filter here
|
||||||
- isNot: "^container_.*_seconds_total$"
|
- isNot: "^container_.*_seconds_total$"
|
||||||
name: {matches: "^container_(.*)_total$"}
|
name: {matches: "^container_(.*)_total$"}
|
||||||
metricsQuery: "sum(rate(<<.Series>>{<<.LabelMatchers>>,container_name!="POD"}[2m])) by (<<.GroupBy>>)"
|
metricsQuery: "sum(rate(<<.Series>>{<<.LabelMatchers>>,container!="POD"}[2m])) by (<<.GroupBy>>)"
|
||||||
|
|
||||||
# this rule matches cumulative non-cAdvisor metrics
|
# this rule matches cumulative non-cAdvisor metrics
|
||||||
- seriesQuery: '{namespace!="",__name__!="^container_.*"}'
|
- seriesQuery: '{namespace!="",__name__!="^container_.*"}'
|
||||||
|
|
@ -52,7 +52,7 @@ rules:
|
||||||
# Group will be converted to a form acceptible for use as a label automatically.
|
# Group will be converted to a form acceptible for use as a label automatically.
|
||||||
template: "<<.Resource>>"
|
template: "<<.Resource>>"
|
||||||
# if we wanted to, we could also specify overrides here
|
# if we wanted to, we could also specify overrides here
|
||||||
metricsQuery: "sum(rate(<<.Series>>{<<.LabelMatchers>>,container_name!="POD"}[2m])) by (<<.GroupBy>>)"
|
metricsQuery: "sum(rate(<<.Series>>{<<.LabelMatchers>>,container!="POD"}[2m])) by (<<.GroupBy>>)"
|
||||||
|
|
||||||
# this rule matches only a single metric, explicitly naming it something else
|
# this rule matches only a single metric, explicitly naming it something else
|
||||||
# It's series query *must* return only a single metric family
|
# It's series query *must* return only a single metric family
|
||||||
|
|
|
||||||
|
|
@ -45,13 +45,13 @@ func setupPrometheusProvider() (provider.CustomMetricsProvider, *fakeprom.FakePr
|
||||||
|
|
||||||
prov, _ := NewPrometheusProvider(restMapper(), fakeKubeClient, fakeProm, namers, fakeProviderUpdateInterval, fakeProviderStartDuration)
|
prov, _ := NewPrometheusProvider(restMapper(), fakeKubeClient, fakeProm, namers, fakeProviderUpdateInterval, fakeProviderStartDuration)
|
||||||
|
|
||||||
containerSel := prom.MatchSeries("", prom.NameMatches("^container_.*"), prom.LabelNeq("container_name", "POD"), prom.LabelNeq("namespace", ""), prom.LabelNeq("pod_name", ""))
|
containerSel := prom.MatchSeries("", prom.NameMatches("^container_.*"), prom.LabelNeq("container", "POD"), prom.LabelNeq("namespace", ""), prom.LabelNeq("pod", ""))
|
||||||
namespacedSel := prom.MatchSeries("", prom.LabelNeq("namespace", ""), prom.NameNotMatches("^container_.*"))
|
namespacedSel := prom.MatchSeries("", prom.LabelNeq("namespace", ""), prom.NameNotMatches("^container_.*"))
|
||||||
fakeProm.SeriesResults = map[prom.Selector][]prom.Series{
|
fakeProm.SeriesResults = map[prom.Selector][]prom.Series{
|
||||||
containerSel: {
|
containerSel: {
|
||||||
{
|
{
|
||||||
Name: "container_some_usage",
|
Name: "container_some_usage",
|
||||||
Labels: pmodel.LabelSet{"pod_name": "somepod", "namespace": "somens", "container_name": "somecont"},
|
Labels: pmodel.LabelSet{"pod": "somepod", "namespace": "somens", "container": "somecont"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
namespacedSel: {
|
namespacedSel: {
|
||||||
|
|
|
||||||
|
|
@ -65,19 +65,19 @@ var seriesRegistryTestSeries = [][]prom.Series{
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Name: "container_some_time_seconds_total",
|
Name: "container_some_time_seconds_total",
|
||||||
Labels: pmodel.LabelSet{"pod_name": "somepod", "namespace": "somens", "container_name": "somecont"},
|
Labels: pmodel.LabelSet{"pod": "somepod", "namespace": "somens", "container": "somecont"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Name: "container_some_count_total",
|
Name: "container_some_count_total",
|
||||||
Labels: pmodel.LabelSet{"pod_name": "somepod", "namespace": "somens", "container_name": "somecont"},
|
Labels: pmodel.LabelSet{"pod": "somepod", "namespace": "somens", "container": "somecont"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Name: "container_some_usage",
|
Name: "container_some_usage",
|
||||||
Labels: pmodel.LabelSet{"pod_name": "somepod", "namespace": "somens", "container_name": "somecont"},
|
Labels: pmodel.LabelSet{"pod": "somepod", "namespace": "somens", "container": "somecont"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -161,7 +161,7 @@ var _ = Describe("Series Registry", func() {
|
||||||
resourceNames: []string{"somepod1", "somepod2"},
|
resourceNames: []string{"somepod1", "somepod2"},
|
||||||
metricSelector: labels.Everything(),
|
metricSelector: labels.Everything(),
|
||||||
|
|
||||||
expectedQuery: "sum(container_some_usage{namespace=\"somens\",pod_name=~\"somepod1|somepod2\",container_name!=\"POD\"}) by (pod_name)",
|
expectedQuery: "sum(container_some_usage{namespace=\"somens\",pod=~\"somepod1|somepod2\",container!=\"POD\"}) by (pod)",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "container metrics counter",
|
title: "container metrics counter",
|
||||||
|
|
@ -170,7 +170,7 @@ var _ = Describe("Series Registry", func() {
|
||||||
resourceNames: []string{"somepod1", "somepod2"},
|
resourceNames: []string{"somepod1", "somepod2"},
|
||||||
metricSelector: labels.Everything(),
|
metricSelector: labels.Everything(),
|
||||||
|
|
||||||
expectedQuery: "sum(rate(container_some_count_total{namespace=\"somens\",pod_name=~\"somepod1|somepod2\",container_name!=\"POD\"}[1m])) by (pod_name)",
|
expectedQuery: "sum(rate(container_some_count_total{namespace=\"somens\",pod=~\"somepod1|somepod2\",container!=\"POD\"}[1m])) by (pod)",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "container metrics seconds counter",
|
title: "container metrics seconds counter",
|
||||||
|
|
@ -179,7 +179,7 @@ var _ = Describe("Series Registry", func() {
|
||||||
resourceNames: []string{"somepod1", "somepod2"},
|
resourceNames: []string{"somepod1", "somepod2"},
|
||||||
metricSelector: labels.Everything(),
|
metricSelector: labels.Everything(),
|
||||||
|
|
||||||
expectedQuery: "sum(rate(container_some_time_seconds_total{namespace=\"somens\",pod_name=~\"somepod1|somepod2\",container_name!=\"POD\"}[1m])) by (pod_name)",
|
expectedQuery: "sum(rate(container_some_time_seconds_total{namespace=\"somens\",pod=~\"somepod1|somepod2\",container!=\"POD\"}[1m])) by (pod)",
|
||||||
},
|
},
|
||||||
// namespaced metrics
|
// namespaced metrics
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -49,9 +49,9 @@ func restMapper() apimeta.RESTMapper {
|
||||||
func buildPodSample(namespace, pod, container string, val float64, ts int64) *pmodel.Sample {
|
func buildPodSample(namespace, pod, container string, val float64, ts int64) *pmodel.Sample {
|
||||||
return &pmodel.Sample{
|
return &pmodel.Sample{
|
||||||
Metric: pmodel.Metric{
|
Metric: pmodel.Metric{
|
||||||
"namespace": pmodel.LabelValue(namespace),
|
"namespace": pmodel.LabelValue(namespace),
|
||||||
"pod_name": pmodel.LabelValue(pod),
|
"pod": pmodel.LabelValue(pod),
|
||||||
"container_name": pmodel.LabelValue(container),
|
"container": pmodel.LabelValue(container),
|
||||||
},
|
},
|
||||||
Value: pmodel.SampleValue(val),
|
Value: pmodel.SampleValue(val),
|
||||||
Timestamp: pmodel.Time(ts),
|
Timestamp: pmodel.Time(ts),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue