Merge pull request #2701 from aledbf/remove-labels
Remove prometheus labels with high cardinality
This commit is contained in:
commit
c196761afa
3 changed files with 8 additions and 27 deletions
|
@ -30,15 +30,10 @@ type socketData struct {
|
||||||
Host string `json:"host"` // Label
|
Host string `json:"host"` // Label
|
||||||
Status string `json:"status"` // Label
|
Status string `json:"status"` // Label
|
||||||
|
|
||||||
RealIPAddress string `json:"realIpAddr"` // Label
|
|
||||||
RemoteAddress string `json:"remoteAddr"` // Label
|
|
||||||
RemoteUser string `json:"remoteUser"` // Label
|
|
||||||
|
|
||||||
BytesSent float64 `json:"bytesSent"` // Metric
|
BytesSent float64 `json:"bytesSent"` // Metric
|
||||||
|
|
||||||
Protocol string `json:"protocol"` // Label
|
Protocol string `json:"protocol"` // Label
|
||||||
Method string `json:"method"` // Label
|
Method string `json:"method"` // Label
|
||||||
URI string `json:"uri"` // Label
|
|
||||||
|
|
||||||
RequestLength float64 `json:"requestLength"` // Metric
|
RequestLength float64 `json:"requestLength"` // Metric
|
||||||
RequestTime float64 `json:"requestTime"` // Metric
|
RequestTime float64 `json:"requestTime"` // Metric
|
||||||
|
@ -51,6 +46,7 @@ type socketData struct {
|
||||||
Namespace string `json:"namespace"` // Label
|
Namespace string `json:"namespace"` // Label
|
||||||
Ingress string `json:"ingress"` // Label
|
Ingress string `json:"ingress"` // Label
|
||||||
Service string `json:"service"` // Label
|
Service string `json:"service"` // Label
|
||||||
|
Path string `json:"path"` // Label
|
||||||
}
|
}
|
||||||
|
|
||||||
// SocketCollector stores prometheus metrics and ingress meta-data
|
// SocketCollector stores prometheus metrics and ingress meta-data
|
||||||
|
@ -82,7 +78,7 @@ func NewInstance(ns string, class string) error {
|
||||||
sc.ns = ns
|
sc.ns = ns
|
||||||
sc.ingressClass = class
|
sc.ingressClass = class
|
||||||
|
|
||||||
requestTags := []string{"host", "status", "remote_address", "real_ip_address", "remote_user", "protocol", "method", "uri", "upstream_name", "upstream_ip", "upstream_status", "namespace", "ingress", "service"}
|
requestTags := []string{"host", "status", "protocol", "method", "path", "upstream_name", "upstream_ip", "upstream_status", "namespace", "ingress", "service"}
|
||||||
collectorTags := []string{"namespace", "ingress_class"}
|
collectorTags := []string{"namespace", "ingress_class"}
|
||||||
|
|
||||||
sc.upstreamResponseTime = prometheus.NewHistogramVec(
|
sc.upstreamResponseTime = prometheus.NewHistogramVec(
|
||||||
|
@ -181,12 +177,9 @@ func (sc *SocketCollector) handleMessage(msg []byte) {
|
||||||
requestLabels := prometheus.Labels{
|
requestLabels := prometheus.Labels{
|
||||||
"host": stats.Host,
|
"host": stats.Host,
|
||||||
"status": stats.Status,
|
"status": stats.Status,
|
||||||
"remote_address": stats.RemoteAddress,
|
|
||||||
"real_ip_address": stats.RealIPAddress,
|
|
||||||
"remote_user": stats.RemoteUser,
|
|
||||||
"protocol": stats.Protocol,
|
"protocol": stats.Protocol,
|
||||||
"method": stats.Method,
|
"method": stats.Method,
|
||||||
"uri": stats.URI,
|
"path": stats.Path,
|
||||||
"upstream_name": stats.UpstreamName,
|
"upstream_name": stats.UpstreamName,
|
||||||
"upstream_ip": stats.UpstreamIP,
|
"upstream_ip": stats.UpstreamIP,
|
||||||
"upstream_status": stats.UpstreamStatus,
|
"upstream_status": stats.UpstreamStatus,
|
||||||
|
|
|
@ -16,13 +16,10 @@ function _M.encode_nginx_stats()
|
||||||
return cjson.encode({
|
return cjson.encode({
|
||||||
host = ngx.var.host or "-",
|
host = ngx.var.host or "-",
|
||||||
status = ngx.var.status or "-",
|
status = ngx.var.status or "-",
|
||||||
remoteAddr = ngx.var.remote_addr or "-",
|
|
||||||
realIpAddr = ngx.var.realip_remote_addr or "-",
|
|
||||||
remoteUser = ngx.var.remote_user or "-",
|
|
||||||
bytesSent = tonumber(ngx.var.bytes_sent) or -1,
|
bytesSent = tonumber(ngx.var.bytes_sent) or -1,
|
||||||
protocol = ngx.var.server_protocol or "-",
|
protocol = ngx.var.server_protocol or "-",
|
||||||
method = ngx.var.request_method or "-",
|
method = ngx.var.request_method or "-",
|
||||||
uri = ngx.var.uri or "-",
|
path = ngx.var.location_path or "-",
|
||||||
requestLength = tonumber(ngx.var.request_length) or -1,
|
requestLength = tonumber(ngx.var.request_length) or -1,
|
||||||
requestTime = tonumber(ngx.var.request_time) or -1,
|
requestTime = tonumber(ngx.var.request_time) or -1,
|
||||||
upstreamName = ngx.var.proxy_upstream_name or "-",
|
upstreamName = ngx.var.proxy_upstream_name or "-",
|
||||||
|
|
|
@ -28,13 +28,10 @@ describe("Monitor", function()
|
||||||
local nginx_environment = {
|
local nginx_environment = {
|
||||||
host = "testshop.com",
|
host = "testshop.com",
|
||||||
status = "200",
|
status = "200",
|
||||||
remote_addr = "10.10.10.10",
|
|
||||||
realip_remote_addr = "5.5.5.5",
|
|
||||||
remote_user = "admin",
|
|
||||||
bytes_sent = "150",
|
bytes_sent = "150",
|
||||||
server_protocol = "HTTP",
|
server_protocol = "HTTP",
|
||||||
request_method = "GET",
|
request_method = "GET",
|
||||||
uri = "/admin",
|
location_path = "/admin",
|
||||||
request_length = "300",
|
request_length = "300",
|
||||||
request_time = "60",
|
request_time = "60",
|
||||||
proxy_upstream_name = "test-upstream",
|
proxy_upstream_name = "test-upstream",
|
||||||
|
@ -54,13 +51,10 @@ describe("Monitor", function()
|
||||||
local expected_json_stats = {
|
local expected_json_stats = {
|
||||||
host = "testshop.com",
|
host = "testshop.com",
|
||||||
status = "200",
|
status = "200",
|
||||||
remoteAddr = "10.10.10.10",
|
|
||||||
realIpAddr = "5.5.5.5",
|
|
||||||
remoteUser = "admin",
|
|
||||||
bytesSent = 150.0,
|
bytesSent = 150.0,
|
||||||
protocol = "HTTP",
|
protocol = "HTTP",
|
||||||
method = "GET",
|
method = "GET",
|
||||||
uri = "/admin",
|
path = "/admin",
|
||||||
requestLength = 300.0,
|
requestLength = 300.0,
|
||||||
requestTime = 60.0,
|
requestTime = 60.0,
|
||||||
upstreamName = "test-upstream",
|
upstreamName = "test-upstream",
|
||||||
|
@ -82,7 +76,7 @@ describe("Monitor", function()
|
||||||
remote_user = "francisco",
|
remote_user = "francisco",
|
||||||
server_protocol = "HTTP",
|
server_protocol = "HTTP",
|
||||||
request_method = "GET",
|
request_method = "GET",
|
||||||
uri = "/admin",
|
location_path = "/admin",
|
||||||
request_time = "60",
|
request_time = "60",
|
||||||
proxy_upstream_name = "test-upstream",
|
proxy_upstream_name = "test-upstream",
|
||||||
upstream_addr = "2.2.2.2",
|
upstream_addr = "2.2.2.2",
|
||||||
|
@ -99,13 +93,10 @@ describe("Monitor", function()
|
||||||
local expected_json_stats = {
|
local expected_json_stats = {
|
||||||
host = "-",
|
host = "-",
|
||||||
status = "-",
|
status = "-",
|
||||||
remoteAddr = "10.10.10.10",
|
|
||||||
realIpAddr = "5.5.5.5",
|
|
||||||
remoteUser = "francisco",
|
|
||||||
bytesSent = -1,
|
bytesSent = -1,
|
||||||
protocol = "HTTP",
|
protocol = "HTTP",
|
||||||
method = "GET",
|
method = "GET",
|
||||||
uri = "/admin",
|
path = "/admin",
|
||||||
requestLength = -1,
|
requestLength = -1,
|
||||||
requestTime = 60.0,
|
requestTime = 60.0,
|
||||||
upstreamName = "test-upstream",
|
upstreamName = "test-upstream",
|
||||||
|
|
Loading…
Reference in a new issue