Skip to content

docs: explain how to drop the client-controlled host label - #7

Open
brommell wants to merge 1 commit into
labstack:mainfrom
brommell:docs/host-label
Open

brommell wants to merge 1 commit into
labstack:mainfrom
brommell:docs/host-label

Conversation

@brommell

Copy link
Copy Markdown

Summary

Documentation only. Extends the LabelFuncs description with how to drop the default host label, and why one might
want to.

Why

The host label is taken from the request Host header, which the client sets freely. Behind a proxy that only
forwards known hosts this is harmless. When the server is reachable directly, every distinct Host value a client
sends creates a new set of series (41 per value with the default metrics), the same unbounded growth as raw paths in
the url label.

host is one of the four default labels and cannot be removed from the label set. It can, however, be blanked through
LabelFuncs, and Prometheus treats a label with an empty value as absent
(data model):

LabelFuncs: map[string]echoprometheus.LabelValueFunc{
	"host": func(c *echo.Context, err error) string { return "" },
},

This works today, but nothing points to it. Checked against the current code: the exported line becomes
echo_requests_total{code="200",host="",method="GET",url="/ok"} 1.

Not changed

The default stays: host is useful for servers that serve several hosts. If you'd prefer an explicit option to leave
the label out (for example DisableHostLabel), I can change this PR to add one instead.

Co-Authored-By: Claude Opus 5.5 [email protected]

The host label comes from the request Host header, so a server reachable
without a filtering proxy gets a new set of series for every Host value
a client sends. It is a default label and cannot be removed from the
label set, but a LabelFuncs entry returning an empty value drops it in
Prometheus. Document that next to LabelFuncs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant