add new summary metric: ingress_header_seconds (#8726)
This commit is contained in:
parent
7806159b38
commit
f85c3866d8
3 changed files with 33 additions and 4 deletions
|
@ -31,6 +31,7 @@ import (
|
||||||
|
|
||||||
type upstream struct {
|
type upstream struct {
|
||||||
Latency float64 `json:"upstreamLatency"`
|
Latency float64 `json:"upstreamLatency"`
|
||||||
|
HeaderTime float64 `json:"upstreamHeaderTime"`
|
||||||
ResponseLength float64 `json:"upstreamResponseLength"`
|
ResponseLength float64 `json:"upstreamResponseLength"`
|
||||||
ResponseTime float64 `json:"upstreamResponseTime"`
|
ResponseTime float64 `json:"upstreamResponseTime"`
|
||||||
//Status string `json:"upstreamStatus"`
|
//Status string `json:"upstreamStatus"`
|
||||||
|
@ -73,7 +74,8 @@ type SocketCollector struct {
|
||||||
responseTime *prometheus.HistogramVec
|
responseTime *prometheus.HistogramVec
|
||||||
responseLength *prometheus.HistogramVec
|
responseLength *prometheus.HistogramVec
|
||||||
|
|
||||||
upstreamLatency *prometheus.SummaryVec
|
upstreamHeaderTime *prometheus.SummaryVec
|
||||||
|
upstreamLatency *prometheus.SummaryVec
|
||||||
|
|
||||||
bytesSent *prometheus.HistogramVec
|
bytesSent *prometheus.HistogramVec
|
||||||
|
|
||||||
|
@ -206,6 +208,17 @@ func NewSocketCollector(pod, namespace, class string, metricsPerHost, reportStat
|
||||||
requestTags,
|
requestTags,
|
||||||
),
|
),
|
||||||
|
|
||||||
|
upstreamHeaderTime: prometheus.NewSummaryVec(
|
||||||
|
prometheus.SummaryOpts{
|
||||||
|
Name: "ingress_upstream_header_seconds",
|
||||||
|
Help: "The time spent on receiving first header from the upstream server",
|
||||||
|
Namespace: PrometheusNamespace,
|
||||||
|
ConstLabels: constLabels,
|
||||||
|
Objectives: defObjectives,
|
||||||
|
},
|
||||||
|
[]string{"ingress", "namespace", "service", "canary"},
|
||||||
|
),
|
||||||
|
|
||||||
upstreamLatency: prometheus.NewSummaryVec(
|
upstreamLatency: prometheus.NewSummaryVec(
|
||||||
prometheus.SummaryOpts{
|
prometheus.SummaryOpts{
|
||||||
Name: "ingress_upstream_latency_seconds",
|
Name: "ingress_upstream_latency_seconds",
|
||||||
|
@ -228,6 +241,7 @@ func NewSocketCollector(pod, namespace, class string, metricsPerHost, reportStat
|
||||||
|
|
||||||
prometheus.BuildFQName(PrometheusNamespace, "", "bytes_sent"): sc.bytesSent,
|
prometheus.BuildFQName(PrometheusNamespace, "", "bytes_sent"): sc.bytesSent,
|
||||||
|
|
||||||
|
prometheus.BuildFQName(PrometheusNamespace, "", "ingress_upstream_header_seconds"): sc.upstreamHeaderTime,
|
||||||
prometheus.BuildFQName(PrometheusNamespace, "", "ingress_upstream_latency_seconds"): sc.upstreamLatency,
|
prometheus.BuildFQName(PrometheusNamespace, "", "ingress_upstream_latency_seconds"): sc.upstreamLatency,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,6 +317,15 @@ func (sc *SocketCollector) handleMessage(msg []byte) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if stats.HeaderTime != -1 {
|
||||||
|
headerTimeMetric, err := sc.upstreamHeaderTime.GetMetricWith(latencyLabels)
|
||||||
|
if err != nil {
|
||||||
|
klog.ErrorS(err, "Error fetching header time metric")
|
||||||
|
} else {
|
||||||
|
headerTimeMetric.Observe(stats.HeaderTime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if stats.RequestTime != -1 {
|
if stats.RequestTime != -1 {
|
||||||
requestTimeMetric, err := sc.requestTime.GetMetricWith(requestLabels)
|
requestTimeMetric, err := sc.requestTime.GetMetricWith(requestLabels)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -443,6 +466,7 @@ func (sc SocketCollector) Describe(ch chan<- *prometheus.Desc) {
|
||||||
sc.requests.Describe(ch)
|
sc.requests.Describe(ch)
|
||||||
|
|
||||||
sc.upstreamLatency.Describe(ch)
|
sc.upstreamLatency.Describe(ch)
|
||||||
|
sc.upstreamHeaderTime.Describe(ch)
|
||||||
|
|
||||||
sc.responseTime.Describe(ch)
|
sc.responseTime.Describe(ch)
|
||||||
sc.responseLength.Describe(ch)
|
sc.responseLength.Describe(ch)
|
||||||
|
@ -458,6 +482,7 @@ func (sc SocketCollector) Collect(ch chan<- prometheus.Metric) {
|
||||||
sc.requests.Collect(ch)
|
sc.requests.Collect(ch)
|
||||||
|
|
||||||
sc.upstreamLatency.Collect(ch)
|
sc.upstreamLatency.Collect(ch)
|
||||||
|
sc.upstreamHeaderTime.Collect(ch)
|
||||||
|
|
||||||
sc.responseTime.Collect(ch)
|
sc.responseTime.Collect(ch)
|
||||||
sc.responseLength.Collect(ch)
|
sc.responseLength.Collect(ch)
|
||||||
|
|
|
@ -47,6 +47,7 @@ local function metrics()
|
||||||
responseLength = tonumber(ngx.var.bytes_sent) or -1,
|
responseLength = tonumber(ngx.var.bytes_sent) or -1,
|
||||||
|
|
||||||
upstreamLatency = tonumber(ngx.var.upstream_connect_time) or -1,
|
upstreamLatency = tonumber(ngx.var.upstream_connect_time) or -1,
|
||||||
|
upstreamHeaderTime = tonumber(ngx.var.upstream_header_time) or -1,
|
||||||
upstreamResponseTime = tonumber(ngx.var.upstream_response_time) or -1,
|
upstreamResponseTime = tonumber(ngx.var.upstream_response_time) or -1,
|
||||||
upstreamResponseLength = tonumber(ngx.var.upstream_response_length) or -1,
|
upstreamResponseLength = tonumber(ngx.var.upstream_response_length) or -1,
|
||||||
--upstreamStatus = ngx.var.upstream_status or "-",
|
--upstreamStatus = ngx.var.upstream_status or "-",
|
||||||
|
|
|
@ -93,7 +93,8 @@ describe("Monitor", function()
|
||||||
|
|
||||||
upstream_addr = "10.10.0.1",
|
upstream_addr = "10.10.0.1",
|
||||||
upstream_connect_time = "0.01",
|
upstream_connect_time = "0.01",
|
||||||
upstream_response_time = "0.02",
|
upstream_header_time = "0.02",
|
||||||
|
upstream_response_time = "0.03",
|
||||||
upstream_response_length = "456",
|
upstream_response_length = "456",
|
||||||
upstream_status = "200",
|
upstream_status = "200",
|
||||||
}
|
}
|
||||||
|
@ -125,7 +126,8 @@ describe("Monitor", function()
|
||||||
responseLength = 512,
|
responseLength = 512,
|
||||||
|
|
||||||
upstreamLatency = 0.01,
|
upstreamLatency = 0.01,
|
||||||
upstreamResponseTime = 0.02,
|
upstreamHeaderTime = 0.02,
|
||||||
|
upstreamResponseTime = 0.03,
|
||||||
upstreamResponseLength = 456,
|
upstreamResponseLength = 456,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -143,7 +145,8 @@ describe("Monitor", function()
|
||||||
responseLength = 512,
|
responseLength = 512,
|
||||||
|
|
||||||
upstreamLatency = 0.01,
|
upstreamLatency = 0.01,
|
||||||
upstreamResponseTime = 0.02,
|
upstreamHeaderTime = 0.02,
|
||||||
|
upstreamResponseTime = 0.03,
|
||||||
upstreamResponseLength = 456,
|
upstreamResponseLength = 456,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue