outposts: make metrics compliant with Prometheus best-practices (#6398)
web/outpost: make metrics compliant with Prometheus best-practices Today, all NewHistogramVec store values in nanoseconds without changing the default histogram bucket, which are made for seconds, making them a bit useless. In addition, some metrics names are not self-explanatoryand and do not comply with Prometheus best practices. This commit tries to fix all of this "issues". NOTE: I kept old metrics in order to avoid breaking changes with existing dashboards and metrics. Signed-off-by: Alexandre NICOLAIE <xunleii@users.noreply.github.com>
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							5347dd7022
						
					
				
				
					commit
					a2714ab1f1
				
			@ -163,13 +163,19 @@ func NewApplication(p api.ProxyOutpostConfig, c *http.Client, server Server) (*A
 | 
			
		||||
			}
 | 
			
		||||
			before := time.Now()
 | 
			
		||||
			inner.ServeHTTP(rw, r)
 | 
			
		||||
			after := time.Since(before)
 | 
			
		||||
			elapsed := time.Since(before)
 | 
			
		||||
			metrics.Requests.With(prometheus.Labels{
 | 
			
		||||
				"outpost_name": a.outpostName,
 | 
			
		||||
				"type":         "app",
 | 
			
		||||
				"method":       r.Method,
 | 
			
		||||
				"host":         web.GetHost(r),
 | 
			
		||||
			}).Observe(float64(after))
 | 
			
		||||
			}).Observe(float64(elapsed) / float64(time.Second))
 | 
			
		||||
			metrics.RequestsLegacy.With(prometheus.Labels{
 | 
			
		||||
				"outpost_name": a.outpostName,
 | 
			
		||||
				"type":         "app",
 | 
			
		||||
				"method":       r.Method,
 | 
			
		||||
				"host":         web.GetHost(r),
 | 
			
		||||
			}).Observe(float64(elapsed))
 | 
			
		||||
		})
 | 
			
		||||
	})
 | 
			
		||||
	if server.API().GlobalConfig.ErrorReporting.Enabled {
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user