go-graphite / graphite-clickhouse

Graphite cluster backend with ClickHouse support
MIT License
213 stars 52 forks source link

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

Open Hedius opened 5 months ago

Hedius commented 5 months ago

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}

msaf1980 commented 4 months ago

I can't have meny expririece with Prometheus, but looks good. Branch confilct against current muster need be resolved. And no integrations tests for prometheus (and other API at now, obly for graphite). It's bad, but I haven't free time for that. Do you have free time and desire for add prometheus integration tests ?

Hedius commented 4 months ago

Hi, will fix the conflict + will look into writing tests when I have time. maybe this or next week.

msaf1980 commented 4 months ago

Hi, will fix the conflict + will look into writing tests when I have time. maybe this or next week.

Hi, it's good news. Also merge with current muster for work test (one of clickhouse version is broken and integrations tests failed).

Hedius commented 3 months ago

So, but now. Will look into this in the coming 2 weeks.

Also will merge master into it again.

Hedius commented 3 months ago

Will have to check how the feature flags added in https://github.com/go-graphite/graphite-clickhouse/pull/266 interact with prometheus.