Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pump custom metrics default value #124

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pumps/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,20 @@ func (pm *PrometheusMetric) GetLabelsValues(decoded analytics.AnalyticsRecord) [
for _, label := range pm.Labels {
if val, ok := mapping[label]; ok {
values = append(values, fmt.Sprint(val))
} else {
// log.Info(label)
val = "UNKNOWN"
for _, tag := range decoded.Tags {
prefixString := label + "-"
if strings.HasPrefix(tag, prefixString) {

val = tag[len(prefixString):]
break
}
}
if label != "type" {
values = append(values, fmt.Sprint(val))
}
}
}
return values
Expand Down
2 changes: 1 addition & 1 deletion pumps/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func TestPrometheusGetLabelsValues(t *testing.T) {
ResponseCode: 200,
APIKey: "apikey",
},
expectedLabels: []string{"testHost", "testMethod"},
expectedLabels: []string{"testHost", "testMethod", "UNKNOWN"},
},
{
testName: "situational labels names ",
Expand Down
Loading