hornet icon indicating copy to clipboard operation
hornet copied to clipboard

Inconsistencies in host name for Prometheus metrics

Open centercirclesolutions opened this issue 1 year ago • 1 comments

Describe the bug This affects several Hornet components so I am putting this issue here. inx-indexer and hornet sometimes report the host differently which could cause issues in aggregation.

To Reproduce image

Expected behavior a consistent host name

Environment information:

  • HORNET version: 2.0.1 latest

centercirclesolutions avatar Nov 01 '23 07:11 centercirclesolutions

This function here can be used to overwrite the "host mapping":

		RequestCounterHostLabelMappingFunc: func(c echo.Context) string {
			return c.Request().Host
		},

So for example in inx-indexer in components/prometheus/component.go you have to modify this part:

		p := echoprometheus.NewPrometheus("iota_restapi", nil)
+		p.RequestCounterHostLabelMappingFunc = func(c echo.Context) string {
+			// add you own mapping logic here
+			return c.Request().Host
+		}
		for _, m := range p.MetricsList {
			registry.MustRegister(m.MetricCollector)
		}
		deps.Echo.Use(p.HandlerFunc)

If you find something generic that makes sense in this context, we can have a look if we change that everywhere.

muXxer avatar Nov 01 '23 09:11 muXxer