|
@@ -124,6 +124,8 @@ func QueryPrometheus(
|
|
|
num := fmt.Sprintf(`sum(rate(nginx_ingress_controller_requests{status=~"5.*",namespace="%s",ingress=~"%s"}[5m]) OR on() vector(0))`, opts.Namespace, selectionRegex)
|
|
num := fmt.Sprintf(`sum(rate(nginx_ingress_controller_requests{status=~"5.*",namespace="%s",ingress=~"%s"}[5m]) OR on() vector(0))`, opts.Namespace, selectionRegex)
|
|
|
denom := fmt.Sprintf(`sum(rate(nginx_ingress_controller_requests{namespace="%s",ingress=~"%s"}[5m]) > 0)`, opts.Namespace, selectionRegex)
|
|
denom := fmt.Sprintf(`sum(rate(nginx_ingress_controller_requests{namespace="%s",ingress=~"%s"}[5m]) > 0)`, opts.Namespace, selectionRegex)
|
|
|
query = fmt.Sprintf(`%s / %s * 100 OR on() vector(0)`, num, denom)
|
|
query = fmt.Sprintf(`%s / %s * 100 OR on() vector(0)`, num, denom)
|
|
|
|
|
+ } else if opts.Metric == "nginx:latency" {
|
|
|
|
|
+ query = fmt.Sprintf(`sum(rate(nginx_ingress_controller_request_duration_seconds_bucket{ingress!="",controller_pod=~".*",controller_class=~".*",controller_namespace=~".*",ingress=~".*"}[2m]))`)
|
|
|
} else if opts.Metric == "cpu_hpa_threshold" {
|
|
} else if opts.Metric == "cpu_hpa_threshold" {
|
|
|
// get the name of the kube hpa metric
|
|
// get the name of the kube hpa metric
|
|
|
metricName, hpaMetricName := getKubeHPAMetricName(clientset, service, opts, "spec_target_metric")
|
|
metricName, hpaMetricName := getKubeHPAMetricName(clientset, service, opts, "spec_target_metric")
|
|
@@ -208,6 +210,7 @@ type promParsedSingletonQueryResult struct {
|
|
|
Memory interface{} `json:"memory,omitempty"`
|
|
Memory interface{} `json:"memory,omitempty"`
|
|
|
Bytes interface{} `json:"bytes,omitempty"`
|
|
Bytes interface{} `json:"bytes,omitempty"`
|
|
|
ErrorPct interface{} `json:"error_pct,omitempty"`
|
|
ErrorPct interface{} `json:"error_pct,omitempty"`
|
|
|
|
|
+ Latency interface{} `json:"latency,omitempty"`
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
type promParsedSingletonQuery struct {
|
|
type promParsedSingletonQuery struct {
|
|
@@ -248,6 +251,8 @@ func parseQuery(rawQuery []byte, metric string) ([]byte, error) {
|
|
|
singletonResult.Memory = values[1]
|
|
singletonResult.Memory = values[1]
|
|
|
} else if metric == "hpa_replicas" {
|
|
} else if metric == "hpa_replicas" {
|
|
|
singletonResult.Replicas = values[1]
|
|
singletonResult.Replicas = values[1]
|
|
|
|
|
+ } else if metric == "nginx:latency" {
|
|
|
|
|
+ singletonResult.Latency = values[1]
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
singletonResults = append(singletonResults, *singletonResult)
|
|
singletonResults = append(singletonResults, *singletonResult)
|