regel/loudml

[Error on create model] "invalid field features.0.measurement: not a valid value" (name limited by config "^[a-zA-Z0-9-_@]+$") ??

Opened this issue · 3 comments

Hello @regel , sorry for this new issue.

I'm trying to create a model with this definition.

{
   "bucket_interval":"1m",
   "default_bucket":"output-influx1",
   "features":[
      {
         "anomaly_type":"low_high",
         "default":0,
         "field":"value",
         "io":"io",
         "match_all":[
            {
               "tag":"metric_id",
               "value":"XXXXX"
            }
         ],
         "measurement":"traffic.rxt_et-1/0/0", <-------------------------------SEE HERE
         "metric":"mean",
         "name":"mean_value"
      }
   ],
   "grace_period":0,
   "interval":"60s",
   "max_evals":20,
   "max_threshold":70,
   "min_threshold":50,
   "name":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
   "offset":"10s",
   "seasonality":{
      "daytime":false,
      "weekday":false
   },
   "span":256,
   "type":"donut"
}

it seems like doesn't like traffic.rxt_et-1/0/0 as measurement maybe character validation?

Required('measurement'): All(schemas.key, Length(max=256)),

loudml/loudml/schemas.py

Lines 28 to 32 in 2d05a3e

key = All(
str,
Length(min=1),
Match("^[a-zA-Z0-9-_@]+$"),
)

@regel IMHO is really important add as many characters in the measurement name as posibles in the influxdb database

As explained in the following doc

"',;:-/\.[]{} are valid characters and should be only scaped "" if conflicting with regex to use them, also key length limit should be 64Kb length

Would you accept a PR to fix this error?

Thank you in advance

Hello again @regel

This regex would be nice ^[a-zA-Z0-9-_@\/\[\]{}:;,.|=%"\$]+$

https://regex101.com/r/w633je/2

it will match with

traffic.rxt_et-1/0/0
traffic.rxt_et-[1/0/0]
traffic.rxt_et-{1/0/0}
traffic.rxt_et-00:11:11
traffic.rxt_et-00,1,1
traffic.rxt_et=adfa
traffic.rxt_et=%20%a
traffic.rxt_et="foo"
traffic.rxt_et="${value}
regel commented

Hi Toni. Yes. Good idea! Yes you can open a PR on this. The unit tests can be updated too based on the examples given.

Ps: I’m on vacation in the beautiful Loire valley. Responses will be delayed.

Thank you very much for your fast answer

Ok , I will be out for 1 week also just from today, I will build a PR when I come back.