Skip to content

Commit

Permalink
make configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
alextheimer committed Oct 16, 2023
1 parent 0ee6b82 commit 4766b50
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
3 changes: 3 additions & 0 deletions core/src/main/resources/filodb-defaults.conf
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ filodb {
# If true, an exception is thrown if any ExecPlan::execute result size is greater than result-byte-limit.
enforce-result-byte-limit = false

# If true, EqualsRegex filters with only the pipe special-character can have unbounded length.
relax-pipe-only-equals-regex-limit = true

# Minimum step required for a query
min-step = 5 seconds

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ object Vectors {
val PromMetricLabel = "__name__"
val TypeLabel = "_type_"
val BucketFilterLabel = "_bucket_"
val conf = GlobalConfig.systemConfig
val queryConfig = conf.getConfig("filodb.query")
}

object WindowConstants {
Expand Down Expand Up @@ -268,7 +270,9 @@ sealed trait Vector extends Expression {
ColumnFilter(labelMatch.label, query.Filter.NotEqualsRegex(labelValue))
case RegexMatch =>
// Relax the length limit only for matchers that contain at most the "|" special character.
if (!Utils.isPipeOnlyRegex(labelValue)) {
val shouldRelax = queryConfig.getBoolean("relax-pipe-only-equals-regex-limit") &&
Utils.isPipeOnlyRegex(labelValue)
if (!shouldRelax) {
require(labelValue.length <= Parser.REGEX_MAX_LEN,
s"Regular expression filters should be <= ${Parser.REGEX_MAX_LEN} characters " +
s"when non-`|` special characters are used.")
Expand Down
10 changes: 7 additions & 3 deletions prometheus/src/main/scala/filodb/prometheus/parse/Parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ object Parser extends StrictLogging {
case object Antlr extends Mode
case object Shadow extends Mode

private val conf = GlobalConfig.systemConfig
private val queryConf = conf.getConfig("filodb.query")

val mode: Mode = {
val conf = GlobalConfig.systemConfig
val queryConfig = QueryConfig(conf.getConfig("filodb.query"))
val queryConfig = QueryConfig(queryConf)
val parser = queryConfig.parser
logger.info(s"Query parser mode: $parser")
parser match {
Expand Down Expand Up @@ -141,7 +143,9 @@ object Parser extends StrictLogging {
ColumnFilter(l.label, Filter.NotEqualsRegex(l.value))
case RegexMatch =>
// Relax the length limit only for matchers that contain at most the "|" special character.
if (!Utils.isPipeOnlyRegex(l.value)) {
val shouldRelax = queryConf.getBoolean("relax-pipe-only-equals-regex-limit") &&
Utils.isPipeOnlyRegex(l.value)
if (!shouldRelax) {
require(l.value.length <= Parser.REGEX_MAX_LEN,
s"Regular expression filters should be <= ${Parser.REGEX_MAX_LEN} characters " +
s"when non-`|` special characters are used.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import filodb.query.exec.{ExecPlan, HistToPromSeriesMapper}

object PrometheusModel {
import com.softwaremill.quicklens._
val conf = GlobalConfig.defaultsFromUrl
val queryConfig = conf.getConfig("filodb.query")
private val conf = GlobalConfig.systemConfig
private val queryConfig = conf.getConfig("filodb.query")

/**
* If the result contains Histograms, automatically convert them to Prometheus vector-per-bucket output
Expand Down Expand Up @@ -44,7 +44,9 @@ object PrometheusModel {
case MatchType.NOT_EQUAL => Filter.NotEquals(m.getValue)
case MatchType.REGEX_MATCH =>
// Relax the length limit only for matchers that contain at most the "|" special character.
if (!Utils.isPipeOnlyRegex(m.getValue)) {
val shouldRelax = queryConfig.getBoolean("relax-pipe-only-equals-regex-limit") &&
Utils.isPipeOnlyRegex(m.getValue)
if (!shouldRelax) {
require(m.getValue.length <= REGEX_MAX_LEN,
s"Regular expression filters should be <= ${REGEX_MAX_LEN} characters " +
s"when non-`|` special characters are used.")
Expand Down

0 comments on commit 4766b50

Please sign in to comment.