go-graphite / graphite-clickhouse

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

Add validation for brackets in plain metrics and regex error parsing for tagged metrics #284

Closed mchrome closed 4 days ago

mchrome commented 4 months ago

If an incorrect regex is sent to clickhouse, graphite-clickhouse will return 500: Storage error which is not very informative. This PR adds validation before that can happen to avoid making unnecessary requests to clickhouse and makes graphite-clickhouse return an error that explains the reason why.

For plain metrics: check if all brackets are closed correctly within each node of the path. Example: a.b.c{d,e}}.f would now return 400: query has unmatched brackets

For tagged metrics: parse regex error from clickhouse. Example: seriesByTag('name=myMetric', 'tag=*abc*') would now return 400: Incorrect regex syntax