mirror of https://github.com/status-im/consul.git
Get partition label from upstream metrics
This commit is contained in:
parent
a38be58eaa
commit
68424b318a
|
@ -403,22 +403,26 @@ func resourceTagSpecifiers(omitDeprecatedTags bool) ([]string, error) {
|
|||
// Upstream listener metrics are prefixed by consul.upstream
|
||||
//
|
||||
// Listener metric name format:
|
||||
// <tcp|http>.upstream.<service>.<namespace>.<datacenter>
|
||||
// <tcp|http>.upstream.<service>.<namespace>.<partition>.<datacenter>
|
||||
//
|
||||
// Examples:
|
||||
// - tcp.upstream.db.dc1.downstream_cx_total: 0
|
||||
// - http.upstream.web.default.dc1.downstream_cx_total: 0
|
||||
// - http.upstream.web.frontend.west.dc1.downstream_cx_total: 0
|
||||
{"consul.upstream.service",
|
||||
fmt.Sprintf(`^(?:tcp|http)\.upstream\.((%s)(?:\.%s)?\.%s\.)`,
|
||||
reSegment, reSegment, reSegment)},
|
||||
fmt.Sprintf(`^(?:tcp|http)\.upstream\.((%s)(?:\.%s)?(?:\.%s)?\.%s\.)`,
|
||||
reSegment, reSegment, reSegment, reSegment)},
|
||||
|
||||
{"consul.upstream.datacenter",
|
||||
fmt.Sprintf(`^(?:tcp|http)\.upstream\.(%s(?:\.%s)?\.(%s)\.)`,
|
||||
reSegment, reSegment, reSegment)},
|
||||
fmt.Sprintf(`^(?:tcp|http)\.upstream\.(%s(?:\.%s)?(?:\.%s)?\.(%s)\.)`,
|
||||
reSegment, reSegment, reSegment, reSegment)},
|
||||
|
||||
{"consul.upstream.namespace",
|
||||
fmt.Sprintf(`^(?:tcp|http)\.upstream\.(%s(?:\.(%s))?\.%s\.)`,
|
||||
reSegment, reSegment, reSegment)},
|
||||
fmt.Sprintf(`^(?:tcp|http)\.upstream\.(%s(?:\.(%s))?(?:\.%s)?\.%s\.)`,
|
||||
reSegment, reSegment, reSegment, reSegment)},
|
||||
|
||||
{"consul.upstream.partition",
|
||||
fmt.Sprintf(`^(?:tcp|http)\.upstream\.(%s(?:\.%s)?(?:\.(%s))?\.%s\.)`,
|
||||
reSegment, reSegment, reSegment, reSegment)},
|
||||
}
|
||||
|
||||
// These tags were deprecated in Consul 1.9.0
|
||||
|
|
|
@ -1202,39 +1202,43 @@ func TestConsulTagSpecifiers(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "tcp listener no namespace",
|
||||
name: "tcp listener no namespace or partition (OSS)",
|
||||
stat: "tcp.upstream.db.dc1.downstream_cx_total",
|
||||
expect: map[string][]string{
|
||||
"consul.upstream.datacenter": {"db.dc1.", "dc1"},
|
||||
"consul.upstream.namespace": {"db.dc1.", ""},
|
||||
"consul.upstream.partition": {"db.dc1.", ""},
|
||||
"consul.upstream.service": {"db.dc1.", "db"},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "tcp listener with namespace",
|
||||
stat: "tcp.upstream.db.default.dc1.downstream_cx_total",
|
||||
name: "tcp listener with namespace and partition",
|
||||
stat: "tcp.upstream.db.frontend.west.dc1.downstream_cx_total",
|
||||
expect: map[string][]string{
|
||||
"consul.upstream.datacenter": {"db.default.dc1.", "dc1"},
|
||||
"consul.upstream.namespace": {"db.default.dc1.", "default"},
|
||||
"consul.upstream.service": {"db.default.dc1.", "db"},
|
||||
"consul.upstream.datacenter": {"db.frontend.west.dc1.", "dc1"},
|
||||
"consul.upstream.namespace": {"db.frontend.west.dc1.", "frontend"},
|
||||
"consul.upstream.partition": {"db.frontend.west.dc1.", "west"},
|
||||
"consul.upstream.service": {"db.frontend.west.dc1.", "db"},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "http listener no namespace",
|
||||
name: "http listener no namespace or partition (OSS)",
|
||||
stat: "http.upstream.web.dc1.downstream_cx_total",
|
||||
expect: map[string][]string{
|
||||
"consul.upstream.datacenter": {"web.dc1.", "dc1"},
|
||||
"consul.upstream.namespace": {"web.dc1.", ""},
|
||||
"consul.upstream.partition": {"web.dc1.", ""},
|
||||
"consul.upstream.service": {"web.dc1.", "web"},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "http listener with namespace",
|
||||
stat: "http.upstream.web.default.dc1.downstream_cx_total",
|
||||
name: "http listener with namespace and partition",
|
||||
stat: "http.upstream.web.frontend.west.dc1.downstream_cx_total",
|
||||
expect: map[string][]string{
|
||||
"consul.upstream.datacenter": {"web.default.dc1.", "dc1"},
|
||||
"consul.upstream.namespace": {"web.default.dc1.", "default"},
|
||||
"consul.upstream.service": {"web.default.dc1.", "web"},
|
||||
"consul.upstream.datacenter": {"web.frontend.west.dc1.", "dc1"},
|
||||
"consul.upstream.namespace": {"web.frontend.west.dc1.", "frontend"},
|
||||
"consul.upstream.partition": {"web.frontend.west.dc1.", "west"},
|
||||
"consul.upstream.service": {"web.frontend.west.dc1.", "web"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue