Skip to content

Commit

Permalink
Merge pull request #20 from sunya-ch/v1.0.0
Browse files Browse the repository at this point in the history
remove neccessity of pushgateway on ReqPushLog
  • Loading branch information
sunya-ch authored Jul 10, 2023
2 parents 6747b72 + dc8e832 commit a8cf985
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
20 changes: 9 additions & 11 deletions cpe-parser/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,16 @@ func ReqPushLog(w http.ResponseWriter, r *http.Request) {
status = "ERROR"
msg = fmt.Sprintf("%v", err)
} else {
err := common.PushValues(logSpec.Parser, logSpec.ClusterID, logSpec.Instance, logSpec.BenchmarkName, logSpec.JobName, logSpec.PodName, logSpec.ConstLabels, values)
if err != nil {
status = "ERROR"
msg = fmt.Sprintf("%v", err)
pkey = ppkey
pval = ppval
} else {
status = "OK"
msg = fmt.Sprintf("%v", logSpec.ConstLabels)
pkey = ppkey
pval = ppval
if common.PushgatewayURL != "" {
err := common.PushValues(logSpec.Parser, logSpec.ClusterID, logSpec.Instance, logSpec.BenchmarkName, logSpec.JobName, logSpec.PodName, logSpec.ConstLabels, values)
if err != nil {
fmt.Println("cannot push values to push gateway: ", err)
}
}
status = "OK"
msg = fmt.Sprintf("%v", logSpec.ConstLabels)
pkey = ppkey
pval = ppval
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions cpe-parser/common/pusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/prometheus/client_golang/prometheus/push"
)

var pushgatewayURL string = os.Getenv("PUSHGATEWAY_URL")
var PushgatewayURL string = os.Getenv("PUSHGATEWAY_URL")

func relabelKey(key string) string {
key = strings.ToLower(key)
Expand Down Expand Up @@ -124,7 +124,7 @@ func GetGauges(parserKey string, instance string, podName string, values map[str
}

func PushValues(parserKey string, clusterID string, instance string, benchmarkName string, jobName string, podName string, const_labels map[string]string, values map[string]interface{}) error {
if pushgatewayURL == "" {
if PushgatewayURL == "" {
return fmt.Errorf("No PUSHGATEWAY_URL set")
}

Expand All @@ -135,7 +135,7 @@ func PushValues(parserKey string, clusterID string, instance string, benchmarkNa
})
completionTime.SetToCurrentTime()

pusher := push.New(pushgatewayURL, jobName)
pusher := push.New(PushgatewayURL, jobName)
for _, gauge := range gauges {
pusher.Collector(gauge)
}
Expand Down

0 comments on commit a8cf985

Please sign in to comment.