Open TylerHelmuth opened 1 month ago
Pinging code owners for pkg/ottl: @TylerHelmuth @kentquirk @bogdandrutu @evan-bradley. See Adding Labels via Comments if you do not have permissions to add labels yourself.
Pinging code owners:
pkg/ottl: @TylerHelmuth @kentquirk @bogdandrutu @evan-bradley
See Adding Labels via Comments if you do not have permissions to add labels yourself.
This is not a problem that can be solved generally by regex, as the SQL language is both complex and recursively defined, so a tool like this would be helpful.
But we should recognize that MySql is not the only flavor of SQL, and name the function generically, and probably give the function a parameter that could specify a SQL variant (even if only one is supported initially).
Component(s)
pkg/ottl
Is your feature request related to a problem? Please describe.
I came across an issue recently that I could not easily solve using OTTL's existing
ExtractPatterns
andreplace_pattern
functions.I was experimenting with ingesting MySQL slow query logs and found that normalization of the query (replacing the parts of the slow query that are unique such as input parameters) was very hard to do with regex.
Consider a slow query log such as
Assuming this string is in the body of a log, it would be nice to extract:
Getting all these parts using the
ExtractPattern
converter is pretty straight forward (although it is a long regex). But normalizing the query was very hard. We were were able to come up with a regex that was close, but it isn't perfect and is quite complex.Describe the solution you'd like
Normalizing the query in an efficient, consistent, and guaranteed manner requires a parser that understands SQL.
With a converter that knows how to interpret these logs, we could simplify (and probably speed up) this process. Instead of the several complex regex statements above, we could do something like
and the
ParseMySQL
converter would return a map like:Describe alternatives you've considered
Regex, lots of regex.
Additional context
Honeycomb has a sql normalizer that we use today that we could use in OTTL to do the normalization: https://github.com/honeycombio/mysqltools/tree/main