Skip to content

Commit

Permalink
Merge pull request kubernetes#2109 from tosi3k/fix-perfdash
Browse files Browse the repository at this point in the history
Fix perfdash for generic Prometheus measurements
  • Loading branch information
k8s-ci-robot committed Jul 29, 2022
2 parents b9874d7 + 87cb2a7 commit f00bd48
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ func (g *genericQueryGatherer) Gather(executor QueryExecutor, startTime, endTime

for _, sample := range samples {
k, labels := key(sample.Metric, g.Dimensions)
// In addition to "key" labels, we need to put MetricName for perfdash.
labels["MetricName"] = g.MetricName
dataItem := getOrCreate(dataItems, k, g.Unit, labels)

val := float64(sample.Value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ func TestGather(t *testing.T) {
},
wantDataItems: []measurementutil.DataItem{
{
Labels: map[string]string{"MetricName": "happy-path"},
Unit: "ms",
Unit: "ms",
Data: map[string]float64{
"below-threshold": 7.0,
"no-threshold": 120.0,
Expand Down Expand Up @@ -106,8 +105,7 @@ func TestGather(t *testing.T) {
// When too many samples, first value is returned and error is raised.
wantDataItems: []measurementutil.DataItem{
{
Labels: map[string]string{"MetricName": "many-samples"},
Unit: "ms",
Unit: "ms",
Data: map[string]float64{
"many-samples": 1.0,
},
Expand All @@ -134,8 +132,7 @@ func TestGather(t *testing.T) {
wantErr: "sample above threshold: want: less or equal than 60, got: 123",
wantDataItems: []measurementutil.DataItem{
{
Labels: map[string]string{"MetricName": "above-threshold"},
Unit: "ms",
Unit: "ms",
Data: map[string]float64{
"above-threshold": 123.0,
},
Expand Down Expand Up @@ -232,9 +229,8 @@ func TestGather(t *testing.T) {
wantDataItems: []measurementutil.DataItem{
{
Labels: map[string]string{
"MetricName": "dimensions",
"d1": "d1-val1",
"d2": "d2-val1",
"d1": "d1-val1",
"d2": "d2-val1",
},
Unit: "ms",
Data: map[string]float64{
Expand All @@ -244,9 +240,8 @@ func TestGather(t *testing.T) {
},
{
Labels: map[string]string{
"MetricName": "dimensions",
"d1": "d1-val1",
"d2": "d2-val2",
"d1": "d1-val1",
"d2": "d2-val2",
},
Unit: "ms",
Data: map[string]float64{
Expand All @@ -256,9 +251,8 @@ func TestGather(t *testing.T) {
},
{
Labels: map[string]string{
"MetricName": "dimensions",
"d1": "d1-val1",
"d2": "",
"d1": "d1-val1",
"d2": "",
},
Unit: "ms",
Data: map[string]float64{
Expand Down Expand Up @@ -307,9 +301,8 @@ func TestGather(t *testing.T) {
wantDataItems: []measurementutil.DataItem{
{
Labels: map[string]string{
"MetricName": "dimensions",
"d1": "d1-val1",
"d2": "d2-val1",
"d1": "d1-val1",
"d2": "d2-val1",
},
Unit: "ms",
Data: map[string]float64{
Expand Down
2 changes: 1 addition & 1 deletion perfdash/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
all: push

# See deployment.yaml for the version currently running-- bump this ahead before rebuilding!
TAG?=2.42
TAG?=2.43

REPO?=gcr.io/k8s-staging-perf-tests

Expand Down
14 changes: 7 additions & 7 deletions perfdash/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ import (

// TestDescription contains test name, output file prefix and parser function.
type TestDescription struct {
Name string
OutputFilePrefix string
Parser func(data []byte, buildNumber int, testResult *BuildData)
ForceConstantCategory bool
Name string
OutputFilePrefix string
Parser func(data []byte, buildNumber int, testResult *BuildData)
FetchMetricNameFromArtifact bool
}

// TestDescriptions is a map job->component->description.
Expand Down Expand Up @@ -468,9 +468,9 @@ var (
},
"GenericMeasurements": {
"GenericMeasurements": []TestDescription{{
OutputFilePrefix: GenericPrometheusQueryMeasurementName,
Parser: parsePerfData,
ForceConstantCategory: true,
OutputFilePrefix: GenericPrometheusQueryMeasurementName,
Parser: parsePerfData,
FetchMetricNameFromArtifact: true,
}},
},
}
Expand Down
2 changes: 1 addition & 1 deletion perfdash/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: perfdash
image: gcr.io/k8s-staging-perf-tests/perfdash:2.42
image: gcr.io/k8s-staging-perf-tests/perfdash:2.43
command:
- /perfdash
- --www=true
Expand Down
6 changes: 5 additions & 1 deletion perfdash/metrics-downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,17 @@ func (g *Downloader) getJobData(wg *sync.WaitGroup, result JobToCategoryData, re

for _, artifact := range artifacts {
metricsFileName := filepath.Base(artifact)
resultCategory := getResultCategory(metricsFileName, filePrefix, categoryLabel, artifacts, testDescription.ForceConstantCategory)
resultCategory := getResultCategory(metricsFileName, filePrefix, categoryLabel, artifacts, testDescription.FetchMetricNameFromArtifact)
fileName := g.artifactName(tests, metricsFileName)
testDataResponse, err := g.MetricsBkt.ReadFile(job, buildNumber, fileName)
if err != nil {
klog.Infof("Error when reading response Body for %q: %v", fileName, err)
continue
}
if testDescription.FetchMetricNameFromArtifact {
trimmed := strings.TrimPrefix(metricsFileName, filePrefix+" ")
testLabel = strings.Split(trimmed, "_")[0]
}
buildData := getBuildData(result, tests.Prefix, resultCategory, testLabel, job, resultLock)
testDescription.Parser(testDataResponse, buildNumber, buildData)
}
Expand Down

0 comments on commit f00bd48

Please sign in to comment.