graphite-clickhouse icon indicating copy to clipboard operation
graphite-clickhouse copied to clipboard

Add filter support to prometheus /api/v1/labels /api/v1/{label}/values

Open Hedius opened this issue 1 year ago • 1 comments

Not sure if my implementation is really ideal. Atm the querier.go of prometheus does not supprt filter support for metric and label searches. please review if what I do is really ok :)

This pull request implements the following changes:

  1. Ensure that the matchers are matched against the Tags Array/Column.
  2. For LabelNames() the matchers are performed against the Tags array column (by using index.TaggedTermWhereN)
  3. For LabelValues() the same is done + LIKE name=% is added as a where condition for Tag1.

If no matchers are provided graphite-clickhouse should work exactly like before.

If a matcher is provided it is matched against the Tags column.

In our case we use the stack with multi tenant support. So a proxy before graphite-clickhouse performs authentication and injects a label into all requests. {x=y}.

This change ensures that LabelNames() and LabelValues() only returns results which match {x=y}

@bzed

Hedius avatar Mar 12 '24 16:03 Hedius

EDIT: ignore this comment. (i reverted my last commit)... Having the __name__ label in results is actually good. ^

Hedius avatar Mar 15 '24 10:03 Hedius

closing this, creating a new one from a feature branch. master was a bad choice

Hedius avatar Apr 01 '24 21:04 Hedius