mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
stackdriver: remove metric.category alias pattern
After discussions with the Stackdriver team, they did not think this was needed.
This commit is contained in:
parent
a25389332c
commit
399e83f91b
@ -29,10 +29,9 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
slog log.Logger
|
||||
legendKeyFormat *regexp.Regexp
|
||||
longMetricNameFormat *regexp.Regexp
|
||||
shortMetricNameFormat *regexp.Regexp
|
||||
slog log.Logger
|
||||
legendKeyFormat *regexp.Regexp
|
||||
metricNameFormat *regexp.Regexp
|
||||
)
|
||||
|
||||
// StackdriverExecutor executes queries for the Stackdriver datasource
|
||||
@ -58,8 +57,7 @@ func init() {
|
||||
slog = log.New("tsdb.stackdriver")
|
||||
tsdb.RegisterTsdbQueryEndpoint("stackdriver", NewStackdriverExecutor)
|
||||
legendKeyFormat = regexp.MustCompile(`\{\{\s*(.+?)\s*\}\}`)
|
||||
longMetricNameFormat = regexp.MustCompile(`([\w\d_]+)\.googleapis\.com/([\w\d_]+)/(.+)`)
|
||||
shortMetricNameFormat = regexp.MustCompile(`([\w\d_]+)\.googleapis\.com/(.+)`)
|
||||
metricNameFormat = regexp.MustCompile(`([\w\d_]+)\.googleapis\.com/(.+)`)
|
||||
}
|
||||
|
||||
// Query takes in the frontend queries, parses them into the Stackdriver query format
|
||||
@ -410,27 +408,16 @@ func formatLegendKeys(metricType string, defaultMetricName string, metricLabels
|
||||
|
||||
func replaceWithMetricPart(metaPartName string, metricType string) []byte {
|
||||
// https://cloud.google.com/monitoring/api/v3/metrics-details#label_names
|
||||
longMatches := longMetricNameFormat.FindStringSubmatch(metricType)
|
||||
shortMatches := shortMetricNameFormat.FindStringSubmatch(metricType)
|
||||
shortMatches := metricNameFormat.FindStringSubmatch(metricType)
|
||||
|
||||
if metaPartName == "metric.name" {
|
||||
if len(longMatches) > 0 {
|
||||
return []byte(longMatches[3])
|
||||
} else if len(shortMatches) > 0 {
|
||||
if len(shortMatches) > 0 {
|
||||
return []byte(shortMatches[2])
|
||||
}
|
||||
}
|
||||
|
||||
if metaPartName == "metric.category" {
|
||||
if len(longMatches) > 0 {
|
||||
return []byte(longMatches[2])
|
||||
}
|
||||
}
|
||||
|
||||
if metaPartName == "metric.service" {
|
||||
if len(longMatches) > 0 {
|
||||
return []byte(longMatches[1])
|
||||
} else if len(shortMatches) > 0 {
|
||||
if len(shortMatches) > 0 {
|
||||
return []byte(shortMatches[1])
|
||||
}
|
||||
}
|
||||
|
@ -329,15 +329,15 @@ func TestStackdriver(t *testing.T) {
|
||||
|
||||
Convey("and the alias pattern is for metric name", func() {
|
||||
|
||||
query := &StackdriverQuery{AliasBy: "metric {{metric.name}} service {{metric.service}} category {{metric.category}}", GroupBys: []string{"metric.label.instance_name", "resource.label.zone"}}
|
||||
query := &StackdriverQuery{AliasBy: "metric {{metric.name}} service {{metric.service}}", GroupBys: []string{"metric.label.instance_name", "resource.label.zone"}}
|
||||
err = executor.parseResponse(res, data, query)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
Convey("Should use alias by formatting and only show instance name", func() {
|
||||
So(len(res.Series), ShouldEqual, 3)
|
||||
So(res.Series[0].Name, ShouldEqual, "metric cpu/usage_time service compute category instance")
|
||||
So(res.Series[1].Name, ShouldEqual, "metric cpu/usage_time service compute category instance")
|
||||
So(res.Series[2].Name, ShouldEqual, "metric cpu/usage_time service compute category instance")
|
||||
So(res.Series[0].Name, ShouldEqual, "metric instance/cpu/usage_time service compute")
|
||||
So(res.Series[1].Name, ShouldEqual, "metric instance/cpu/usage_time service compute")
|
||||
So(res.Series[2].Name, ShouldEqual, "metric instance/cpu/usage_time service compute")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -49,8 +49,7 @@
|
||||
|
||||
Patterns:
|
||||
<code ng-non-bindable>{{metric.type}}</code> = metric type e.g. compute.googleapis.com/instance/cpu/usage_time
|
||||
<code ng-non-bindable>{{metric.name}}</code> = name part of metric e.g. cpu/usage_time
|
||||
<code ng-non-bindable>{{metric.category}}</code> = category part of metric e.g. instance
|
||||
<code ng-non-bindable>{{metric.name}}</code> = name part of metric e.g. instance/cpu/usage_time
|
||||
<code ng-non-bindable>{{metric.service}}</code> = service part of metric e.g. compute
|
||||
|
||||
<code ng-non-bindable>{{metric.label.label_name}}</code> = Metric label metadata e.g. metric.label.instance_name
|
||||
|
Loading…
Reference in New Issue
Block a user