《夏锐航-PromQL Got a Boost:用 Rust 重写 Prometheus 的查询引擎.pdf》由会员分享,可在线阅读,更多相关《夏锐航-PromQL Got a Boost:用 Rust 重写 Prometheus 的查询引擎.pdf(49页珍藏版)》请在三个皮匠报告上搜索。
1、PromQL Got a BOOST主讲人:Ruihang,GreptimePromQL Got a BOOST:用 Rust 重写 Prometheus 的查询引擎演讲嘉宾介绍Ruihang GreptimeGitHub:waynexiaLosing hair at GreptimeWanna sleep 10 hrs/dayLearn JS every yearHealing the HyruleCONTENT目录2023K+01Backgroundthe Parser the Engine0203Rust Gives04Outlook05Part 01Background About P
2、rometheus and PromQL Why rewrite?What are boosted?PROMETHEUS AND PROMQLThe de facto standard in cloud-native monitor scenarioHas its own query language called“PromQL”rate(api_request_durationhost=“foo”5m)More than a monitor:alert,visualize with many integrationsPROMETHEUS AND PROMQLrate(api_request_
3、durationhost=“foo”5m)OperatorDataFilterRangeSELECT rate(val)OVER(ORDER BY timestamp RANGE BETWEEN 5 minutes PRECEDING AND CURRENT ROW )AS rateFROM api_request_durationWHERE host=fooOURShttps:/ Database(cloud-native,hybrid-workload,distributed)SQL and table modelRead more about GreptimeCloud:https:/
4、REWRITETarget to be the most powerful drop-in replacementPromQL has a good UX for time-series dataAnd it can be better if combine with SQLRIIR,super cooooooool!WHAT ARE BOOSTEDWHAT ARE BOOSTEDPROMQL VIA SQL(1)prepare data using SQL(2)write your PromQL!Part 02the Parser Tech stack Out choiceOUR CHOIC
5、Elrpar-generator,yacc compatiblePromQL has replaced its hand-written parser with yaccBut there are still many slight differencesYACC FILEHOW TO CHOOSEBased on the scenario and pre-requirementE.g.:sqlparser-hand-written combinator nom81,000,000+combinatorpestcombinelalrpop37,500,000+21,700,000+5,500,
6、000+generatorcombinatorgeneratorDownloadsMethodCrateERROR HANDLINGTerminal v.s.textchumsky,nom,winnow?Still exploring Part 03the Engine Which way to rewrite?Apache Arrow&DataFusion Diff between modelsREWRITEAround 1/7 of Prometheus is PromQLA straightforward 3-layer structure Translate to Rust?Or re
7、build itDRAWBACK OF PROMETHEUSBad efficiency:calculates point by pointDirectly interpreters over ASTHard to scale and distributingHard to extendTRANSLATE OR REBUILDTranslate Pros.:Easy to write Compatibility Cons.:Hard to extend Same performanceRebuild Pros.:Controllable Best fit Cons.:A big workREB
8、UILDBased on the table-oriented modelWorks like an extensionPowered by REBUILDOptimize before executeThe same executor withexisting SQL partMultiple formatsfrom one resultBENEFITS OFPart 04Rust Gives Advantages from Rust Easy to extend Easy to distribute computationBY USING RUSTNo too much troubles/
9、burdensPowerful static check by RustFast feedback&debug with UTPrometheus:almost no unit testPOWERFUL ABSTRACTIONMACRO!Make use of arrow operatorFocus only on the logicMacro takes care of all other thingsDISTRIBUTE ITMake distributed PromQL in ONE DAYKNOW PROMQL BETTERTrack your query with TQL ANALY
10、ZEBY REWRITINGPROMETHEUS WORKBENCHNow available on GreptimeCloud.A fully managed GitOps dashboardLearn more about it:https:/ 05Outlook Rust has joined the game In cloud native areaJOIN THE GAMEJOIN THE GAMEOur parser has supported another project to hack with PromQLOur implementation is also easy to
11、 integrateCLOUD NATIVEGolang+.io?From CNCF landscape,the number of Rust projects has exceeded 1/10 of GolangsWith some key infrastructure like WebAssemblyWEBASSEMBLYwaynexia/datafusion-playgroundWRITE UDF IN PYTHONSeamlessly cooperation with SQLOptimized Grammar for Time-Series queryBuilt-in Continuous AggregationStandard InterfaceNative ClientsCommunity IntegrationsCommunity IntegrationsAvailable in the next releaseIMAGINE THE FUTUREMonitor data collected&transformed in Vector()Then store and analyze with GreptimeDB()Happy evolve your system()THANKS