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

remove neccessity of pushgateway on ReqPushLog #20

Merged
merged 1 commit into from
Jul 10, 2023
Merged
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
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