[{"data":1,"prerenderedAt":1796},["ShallowReactive",2],{"\u002Ffeatures\u002Fmetrics\u002Fpromql-compat-navigation":3,"\u002Ffeatures\u002Fmetrics\u002Fpromql-compat":116,"querying-metrics":561},[4,8,28,38,52,56,60,70,74,78,82,86,90,94,98],{"title":5,"path":6,"stem":7},"Get started","\u002Ffeatures","features\u002Findex",{"title":9,"closed":10,"path":11,"stem":12,"children":13,"page":-1},"Traces",true,"\u002Ffeatures\u002Ftraces","features\u002F01.traces\u002Findex",[14,16,20,24],{"title":15,"path":11,"stem":12},"Introduction",{"title":17,"path":18,"stem":19},"Grouping & systems","\u002Ffeatures\u002Ftraces\u002Fgrouping","features\u002F01.traces\u002Fgrouping",{"title":21,"path":22,"stem":23},"Querying spans","\u002Ffeatures\u002Ftraces\u002Fquerying-spans","features\u002F01.traces\u002Fquerying-spans",{"title":25,"path":26,"stem":27},"Querying traces","\u002Ffeatures\u002Ftraces\u002Fquerying-traces","features\u002F01.traces\u002Fquerying-traces",{"title":29,"closed":10,"path":30,"stem":31,"children":32,"page":-1},"Logs","\u002Ffeatures\u002Flogs","features\u002F02.logs\u002Findex",[33,34],{"title":15,"path":30,"stem":31},{"title":35,"path":36,"stem":37},"Grouping rules","\u002Ffeatures\u002Flogs\u002Fgrouping","features\u002F02.logs\u002Fgrouping",{"title":39,"closed":10,"path":40,"stem":41,"children":42,"page":-1},"Metrics","\u002Ffeatures\u002Fmetrics","features\u002F03.metrics\u002Findex",[43,44,48],{"title":15,"path":40,"stem":41},{"title":45,"path":46,"stem":47},"Querying","\u002Ffeatures\u002Fmetrics\u002Fquerying","features\u002F03.metrics\u002F02.querying",{"title":49,"path":50,"stem":51},"PromQL compat","\u002Ffeatures\u002Fmetrics\u002Fpromql-compat","features\u002F03.metrics\u002F03.promql-compat",{"title":53,"path":54,"stem":55},"Alerts and Notifications","\u002Ffeatures\u002Falerting","features\u002F04.alerting",{"title":57,"path":58,"stem":59},"Chart annotations","\u002Ffeatures\u002Fannotations","features\u002F05.annotations",{"title":61,"path":62,"stem":63,"children":64,"closed":10},"Dashboards","\u002Ffeatures\u002Fdashboards","features\u002F06.dashboards\u002F1.index",[65,66],{"title":61,"path":62,"stem":63},{"title":67,"path":68,"stem":69},"YAML Templates","\u002Ffeatures\u002Fdashboards\u002Fyaml","features\u002F06.dashboards\u002F2.yaml",{"title":71,"path":72,"stem":73},"Transformations","\u002Ffeatures\u002Ftransformations","features\u002F07.transformations",{"title":75,"path":76,"stem":77},"Service graph","\u002Ffeatures\u002Fservice-graph","features\u002F08.service-graph",{"title":79,"path":80,"stem":81},"Grafana integration","\u002Ffeatures\u002Fgrafana","features\u002F09.grafana",{"title":83,"path":84,"stem":85},"Data fixtures","\u002Ffeatures\u002Ffixtures","features\u002F10.fixtures",{"title":87,"path":88,"stem":89},"JavaScript Source Maps","\u002Ffeatures\u002Fsourcemaps","features\u002F11.sourcemaps",{"title":91,"path":92,"stem":93},"MCP Server","\u002Ffeatures\u002Fmcp","features\u002F12.mcp",{"title":95,"path":96,"stem":97},"Searching","\u002Ffeatures\u002Fsearching","features\u002F4.searching",{"title":99,"closed":10,"path":100,"stem":101,"children":102,"page":115},"SSO","\u002Ffeatures\u002Fsso","features\u002Fsso",[103,107,111],{"title":104,"path":105,"stem":106},"Google","\u002Ffeatures\u002Fsso\u002Fgoogle","features\u002Fsso\u002F1.google",{"title":108,"path":109,"stem":110},"Okta","\u002Ffeatures\u002Fsso\u002Fokta","features\u002Fsso\u002F2.okta",{"title":112,"path":113,"stem":114},"Keycloak","\u002Ffeatures\u002Fsso\u002Fkeycloak","features\u002Fsso\u002F3.keycloak",false,{"page":117,"surround":556},{"id":118,"title":119,"body":120,"description":544,"extension":545,"image":546,"meta":547,"navigation":553,"path":50,"seo":554,"stem":51,"surround_disabled":115,"__hash__":555},"features\u002Ffeatures\u002F03.metrics\u002F03.promql-compat.md","PromQL compatibility",{"type":121,"value":122,"toc":537},"minimark",[123,127,131,180,189,193,196,236,239,273,276,287,294,326,330,333,427,431,435,442,476,494,498,501,533],[124,125,15],"h2",{"id":126},"introduction",[128,129,130],"p",{},"Uptrace aims to be compatible with the Prometheus query language while extending it in a meaningful way. Most Prometheus queries can be used in Uptrace with minimal modifications, for example, the following Prometheus queries are also valid in Uptrace:",[132,133,134,141,150,158,163,168,173],"ul",{},[135,136,137],"li",{},[138,139,140],"code",{},"$metric_name{foo=\"xxx\",bar~\"yyy\"}",[135,142,143,146,147],{},[138,144,145],{},"increase($metric_name)"," and ",[138,148,149],{},"delta($metric_name)",[135,151,152,146,155],{},[138,153,154],{},"rate($metric_name[5m])",[138,156,157],{},"irate($metric_name[5m])",[135,159,160],{},[138,161,162],{},"avg_over_time($go_goroutines[5m])",[135,164,165],{},[138,166,167],{},"avg by (foo)(sum by(foo, bar)($metric_name))",[135,169,170],{},[138,171,172],{},"$metric_name offset 1w",[135,174,175,176,179],{},"Math between series with automatic many-to-one\u002Fone-to-many vector matching, for example, ",[138,177,178],{},"sum($mem by (type)) \u002F sum($mem) as mem",".",[128,181,182,183,188],{},"But there are also some differences between the systems that don't allow you to just copy and paste queries from Prometheus. To ease the migration, you can use Uptrace as a ",[184,185,187],"a",{"href":186},"\u002Ffeatures\u002Fgrafana#prometheus-metrics","Prometheus data source in Grafana",", which is 100% compatible with the original Prometheus and allows you to use existing Grafana dashboards.",[124,190,192],{"id":191},"aliases","Aliases",[128,194,195],{},"Because metric names can be quite long, Uptrace requires you to provide a short metric alias that starts with the dollar sign:",[197,198,203],"pre",{"className":199,"code":200,"language":201,"meta":202,"style":202},"language-yaml shiki shiki-themes github-light","metrics:\n  - node_memory_MemFree_bytes as $mem_free\n  - node_memory_Cached_bytes as $cached\n","yaml","",[138,204,205,218,228],{"__ignoreMap":202},[206,207,210,214],"span",{"class":208,"line":209},"line",1,[206,211,213],{"class":212},"shJU0","metrics",[206,215,217],{"class":216},"sgsFI",":\n",[206,219,221,224],{"class":208,"line":220},2,[206,222,223],{"class":216},"  - ",[206,225,227],{"class":226},"sYBdl","node_memory_MemFree_bytes as $mem_free\n",[206,229,231,233],{"class":208,"line":230},3,[206,232,223],{"class":216},[206,234,235],{"class":226},"node_memory_Cached_bytes as $cached\n",[128,237,238],{},"Such aliases will be used as the resulting timeseries names when querying metrics:",[197,240,242],{"className":199,"code":241,"language":201,"meta":202,"style":202},"query:\n  - $mem_free\n  - $cached\n  - $mem_free + $cached\n",[138,243,244,251,258,265],{"__ignoreMap":202},[206,245,246,249],{"class":208,"line":209},[206,247,248],{"class":212},"query",[206,250,217],{"class":216},[206,252,253,255],{"class":208,"line":220},[206,254,223],{"class":216},[206,256,257],{"class":226},"$mem_free\n",[206,259,260,262],{"class":208,"line":230},[206,261,223],{"class":216},[206,263,264],{"class":226},"$cached\n",[206,266,268,270],{"class":208,"line":267},4,[206,269,223],{"class":216},[206,271,272],{"class":226},"$mem_free + $cached\n",[128,274,275],{},"Uptrace also allows to explicitly specify aliases for expressions:",[197,277,281],{"className":278,"code":279,"language":280,"meta":202,"style":202},"language-shell shiki shiki-themes github-light","$mem_free + $cached as total_mem\n","shell",[138,282,283],{"__ignoreMap":202},[206,284,285],{"class":208,"line":209},[206,286,279],{"class":216},[128,288,289,290,293],{},"Because Uptrace queries can contain multiple expressions separated with the ",[138,291,292],{},"|",", you can reference other expressions using their aliases:",[197,295,297],{"className":278,"code":296,"language":280,"meta":202,"style":202},"$mem_free + $cached as total_mem | 1 - ($mem_free \u002F total_mem) as mem_utilization\n",[138,298,299],{"__ignoreMap":202},[206,300,301,304,307,311,314,317,320,323],{"class":208,"line":209},[206,302,303],{"class":216},"$mem_free + $cached as total_mem ",[206,305,292],{"class":306},"sD7c4",[206,308,310],{"class":309},"s7eDp"," 1",[206,312,313],{"class":226}," -",[206,315,316],{"class":216}," ($mem_free ",[206,318,319],{"class":226},"\u002F",[206,321,322],{"class":226}," total_mem",[206,324,325],{"class":216},") as mem_utilization\n",[124,327,329],{"id":328},"grouping","Grouping",[128,331,332],{},"Just like Prometheus, Uptrace allows to customize grouping, for example, the following queries return the same result in Uptrace and Prometheus:",[197,334,336],{"className":278,"code":335,"language":280,"meta":202,"style":202},"sum by (cpu, mode)(node_cpu_seconds_total)\nsum(node_cpu_seconds_total) by (cpu, mode)\n\navg by (cpu)(sum by (cpu, mode)(node_cpu_seconds_total))\navg(sum(node_cpu_seconds_total) by (cpu, mode)) by (cpu)\n",[138,337,338,361,377,382,407],{"__ignoreMap":202},[206,339,340,343,346,349,352,355,358],{"class":208,"line":209},[206,341,342],{"class":309},"sum",[206,344,345],{"class":226}," by",[206,347,348],{"class":216}," (cpu, ",[206,350,351],{"class":226},"mode",[206,353,354],{"class":216},")(",[206,356,357],{"class":309},"node_cpu_seconds_total",[206,359,360],{"class":216},")\n",[206,362,363,366,369,372,375],{"class":208,"line":220},[206,364,365],{"class":309},"sum(node_cpu_seconds_total",[206,367,368],{"class":216},") by (",[206,370,371],{"class":309},"cpu,",[206,373,374],{"class":226}," mode",[206,376,360],{"class":216},[206,378,379],{"class":208,"line":230},[206,380,381],{"emptyLinePlaceholder":10},"\n",[206,383,384,387,389,392,394,396,398,400,402,404],{"class":208,"line":267},[206,385,386],{"class":309},"avg",[206,388,345],{"class":226},[206,390,391],{"class":216}," (cpu)(",[206,393,342],{"class":309},[206,395,345],{"class":226},[206,397,348],{"class":216},[206,399,351],{"class":226},[206,401,354],{"class":216},[206,403,357],{"class":309},[206,405,406],{"class":216},"))\n",[206,408,410,413,415,417,419,422,425],{"class":208,"line":409},5,[206,411,412],{"class":309},"avg(sum(node_cpu_seconds_total",[206,414,368],{"class":216},[206,416,371],{"class":309},[206,418,374],{"class":226},[206,420,421],{"class":216},")) by (",[206,423,424],{"class":309},"cpu",[206,426,360],{"class":216},[428,429],"partial",{"path":430},"querying-metrics",[124,432,434],{"id":433},"rate-interval","Rate interval",[128,436,437,438,441],{},"Uptrace automatically picks and applies a suitable ",[138,439,440],{},"$__rate_interval"," just like Grafana does:",[197,443,445],{"className":278,"code":444,"language":280,"meta":202,"style":202},"# Grafana and Prometheus\nirate(node_cpu_seconds_total[$__rate_interval])\n\n# Uptrace\nirate(node_cpu_seconds_total)\n",[138,446,447,453,460,464,469],{"__ignoreMap":202},[206,448,449],{"class":208,"line":209},[206,450,452],{"class":451},"sAwPA","# Grafana and Prometheus\n",[206,454,455,458],{"class":208,"line":220},[206,456,457],{"class":309},"irate(node_cpu_seconds_total[$__rate_interval]",[206,459,360],{"class":216},[206,461,462],{"class":208,"line":230},[206,463,381],{"emptyLinePlaceholder":10},[206,465,466],{"class":208,"line":267},[206,467,468],{"class":451},"# Uptrace\n",[206,470,471,474],{"class":208,"line":409},[206,472,473],{"class":309},"irate(node_cpu_seconds_total",[206,475,360],{"class":216},[128,477,478,479,482,483,486,487,490,491,179],{},"You can specify the lookbehind window in square brackets, e.g. ",[138,480,481],{},"irate($metric[5i])"," where ",[138,484,485],{},"i"," is equal to the current ",[488,489,485],"strong",{},"nterval. When omitted, the default lookbehind window is ",[138,492,493],{},"10i",[124,495,497],{"id":496},"range-vs-instant-vectors","Range vs instant vectors",[128,499,500],{},"Because Uptrace does not distinguish between range and instant vectors, you should omit the lookbehind window and let Uptrace pick a default for you:",[197,502,504],{"className":278,"code":503,"language":280,"meta":202,"style":202},"# Omit the window by default.\nirate(node_cpu_seconds_total)\n\n# Only specify it when needed.\nmax_over_time(process_resident_memory_bytes[1d])\n",[138,505,506,511,517,521,526],{"__ignoreMap":202},[206,507,508],{"class":208,"line":209},[206,509,510],{"class":451},"# Omit the window by default.\n",[206,512,513,515],{"class":208,"line":220},[206,514,473],{"class":309},[206,516,360],{"class":216},[206,518,519],{"class":208,"line":230},[206,520,381],{"emptyLinePlaceholder":10},[206,522,523],{"class":208,"line":267},[206,524,525],{"class":451},"# Only specify it when needed.\n",[206,527,528,531],{"class":208,"line":409},[206,529,530],{"class":309},"max_over_time(process_resident_memory_bytes[1d]",[206,532,360],{"class":216},[534,535,536],"style",{},"html pre.shiki code .shJU0, html code.shiki .shJU0{--shiki-default:#22863A}html pre.shiki code .sgsFI, html code.shiki .sgsFI{--shiki-default:#24292E}html pre.shiki code .sYBdl, html code.shiki .sYBdl{--shiki-default:#032F62}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sD7c4, html code.shiki .sD7c4{--shiki-default:#D73A49}html pre.shiki code .s7eDp, html code.shiki .s7eDp{--shiki-default:#6F42C1}html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}",{"title":202,"searchDepth":267,"depth":220,"links":538},[539,540,541,542,543],{"id":126,"depth":220,"text":15},{"id":191,"depth":220,"text":192},{"id":328,"depth":220,"text":329},{"id":433,"depth":220,"text":434},{"id":496,"depth":220,"text":497},"See how Uptrace extends PromQL, which functions are supported, and how to adapt Prometheus queries or Grafana dashboards.","md",null,{"readingTime":548},{"text":549,"minutes":550,"time":551,"words":552},"2 min read",1.57,94200,314,{"title":49},{"title":119,"description":544},"nIDQJzKxy5pd7AymR2gacxQKgqQcJiCJmEej9-jQT3M",[557,559],{"title":45,"path":46,"stem":47,"description":558,"children":-1},"Write PromQL inspired metric queries with aliases, joins, and expressions that feed dashboards built in the UI or YAML.",{"title":53,"path":54,"stem":55,"description":560,"children":-1},"Configure metric and error monitors, define YAML thresholds, and connect Uptrace notifications to email, Slack, PagerDuty, or webhooks.",{"id":562,"title":563,"body":564,"description":568,"extension":545,"meta":1786,"navigation":10,"path":1792,"seo":1793,"stem":1794,"__hash__":1795},"partials\u002Fpartials\u002F_querying-metrics.md","Querying Metrics",{"type":121,"value":565,"toc":1773},[566,569,619,622,702,706,709,762,772,870,879,922,925,957,961,964,1008,1011,1099,1102,1161,1165,1168,1204,1207,1258,1261,1288,1292,1295,1327,1337,1341,1344,1385,1395,1398,1401,1436,1447,1450,1453,1575,1579,1582,1662,1665,1691,1699,1705,1711,1727,1733,1737,1742,1749,1758,1761,1770],[128,567,568],{},"You can also specify grouping for the whole expression:",[197,570,572],{"className":278,"code":571,"language":280,"meta":202,"style":202},"sum($metric1) by (type) \u002F sum($metric2) group by host_name\n\n# The same.\nsum($metric1) by (type, host_name) \u002F sum($metric2) by (host_name)\n",[138,573,574,588,592,597],{"__ignoreMap":202},[206,575,576,579,581,585],{"class":208,"line":209},[206,577,578],{"class":309},"sum($metric1",[206,580,368],{"class":216},[206,582,584],{"class":583},"sYu0t","type",[206,586,587],{"class":216},") \u002F sum($metric2) group by host_name\n",[206,589,590],{"class":208,"line":220},[206,591,381],{"emptyLinePlaceholder":10},[206,593,594],{"class":208,"line":230},[206,595,596],{"class":451},"# The same.\n",[206,598,599,601,603,605,608,611,614,617],{"class":208,"line":267},[206,600,578],{"class":309},[206,602,368],{"class":216},[206,604,584],{"class":583},[206,606,607],{"class":226},",",[206,609,610],{"class":226}," host_name",[206,612,613],{"class":216},") \u002F sum($metric2) by (",[206,615,616],{"class":309},"host_name",[206,618,360],{"class":216},[128,620,621],{},"And for the whole query affecting all expressions:",[197,623,625],{"className":278,"code":624,"language":280,"meta":202,"style":202},"$metric1 | metric2 | group by host_name\n\n# The same using expression-wide grouping.\n$metric1 group by host_name | $metric2 group by host_name\n# Or custom grouping.\nsum($metric1) by (host_name) | sum($metric2) by (host_name)\n",[138,626,627,648,652,657,674,679],{"__ignoreMap":202},[206,628,629,632,634,637,640,643,645],{"class":208,"line":209},[206,630,631],{"class":216},"$metric1 ",[206,633,292],{"class":306},[206,635,636],{"class":309}," metric2",[206,638,639],{"class":306}," |",[206,641,642],{"class":309}," group",[206,644,345],{"class":226},[206,646,647],{"class":226}," host_name\n",[206,649,650],{"class":208,"line":220},[206,651,381],{"emptyLinePlaceholder":10},[206,653,654],{"class":208,"line":230},[206,655,656],{"class":451},"# The same using expression-wide grouping.\n",[206,658,659,662,664,667,670,672],{"class":208,"line":267},[206,660,661],{"class":216},"$metric1 group by host_name ",[206,663,292],{"class":306},[206,665,666],{"class":216}," $metric2 ",[206,668,669],{"class":226},"group",[206,671,345],{"class":226},[206,673,647],{"class":226},[206,675,676],{"class":208,"line":409},[206,677,678],{"class":451},"# Or custom grouping.\n",[206,680,682,684,686,688,691,693,696,698,700],{"class":208,"line":681},6,[206,683,578],{"class":309},[206,685,368],{"class":216},[206,687,616],{"class":309},[206,689,690],{"class":216},") ",[206,692,292],{"class":306},[206,694,695],{"class":309}," sum($metric2",[206,697,368],{"class":216},[206,699,616],{"class":309},[206,701,360],{"class":216},[124,703,705],{"id":704},"manipulating-attributes","Manipulating attributes",[128,707,708],{},"You can rename attributes like this:",[197,710,712],{"className":278,"code":711,"language":280,"meta":202,"style":202},"$metric1 by (deployment_environment as env, service_name as service)\n$metric1 | group by deployment_environment as env, service_name as service\n",[138,713,714,738],{"__ignoreMap":202},[206,715,716,719,722,725,728,731,733,736],{"class":208,"line":209},[206,717,718],{"class":216},"$metric1 by (",[206,720,721],{"class":309},"deployment_environment",[206,723,724],{"class":226}," as",[206,726,727],{"class":226}," env,",[206,729,730],{"class":226}," service_name",[206,732,724],{"class":226},[206,734,735],{"class":226}," service",[206,737,360],{"class":216},[206,739,740,742,744,746,748,751,753,755,757,759],{"class":208,"line":220},[206,741,631],{"class":216},[206,743,292],{"class":306},[206,745,642],{"class":309},[206,747,345],{"class":226},[206,749,750],{"class":226}," deployment_environment",[206,752,724],{"class":226},[206,754,727],{"class":226},[206,756,730],{"class":226},[206,758,724],{"class":226},[206,760,761],{"class":226}," service\n",[128,763,764,765,146,768,771],{},"To manipulate attribute values, you can use ",[138,766,767],{},"replace",[138,769,770],{},"replaceRegexp"," functions:",[197,773,775],{"className":278,"code":774,"language":280,"meta":202,"style":202},"group by replace(host_name, 'uptrace-prod-', '') as host\ngroup by replaceRegexp(host, `^`, 'prefix ') as host\ngroup by replaceRegexp(host, `$`, ' suffix') as host\n",[138,776,777,806,840],{"__ignoreMap":202},[206,778,779,781,783,786,789,792,795,798,800,803],{"class":208,"line":209},[206,780,669],{"class":309},[206,782,345],{"class":226},[206,784,785],{"class":226}," replace",[206,787,788],{"class":216},"(",[206,790,791],{"class":309},"host_name,",[206,793,794],{"class":226}," 'uptrace-prod-',",[206,796,797],{"class":226}," ''",[206,799,690],{"class":216},[206,801,802],{"class":226},"as",[206,804,805],{"class":226}," host\n",[206,807,808,810,812,815,817,820,823,826,829,831,834,836,838],{"class":208,"line":220},[206,809,669],{"class":309},[206,811,345],{"class":226},[206,813,814],{"class":226}," replaceRegexp",[206,816,788],{"class":216},[206,818,819],{"class":309},"host,",[206,821,822],{"class":226}," `",[206,824,825],{"class":309},"^",[206,827,828],{"class":226},"`",[206,830,607],{"class":309},[206,832,833],{"class":226}," 'prefix '",[206,835,690],{"class":216},[206,837,802],{"class":226},[206,839,805],{"class":226},[206,841,842,844,846,848,850,852,854,857,859,861,864,866,868],{"class":208,"line":230},[206,843,669],{"class":309},[206,845,345],{"class":226},[206,847,814],{"class":226},[206,849,788],{"class":216},[206,851,819],{"class":309},[206,853,822],{"class":226},[206,855,856],{"class":309},"$",[206,858,828],{"class":226},[206,860,607],{"class":309},[206,862,863],{"class":226}," ' suffix'",[206,865,690],{"class":216},[206,867,802],{"class":226},[206,869,805],{"class":226},[128,871,872,873,146,876,771],{},"To change strings case, use ",[138,874,875],{},"upper",[138,877,878],{},"lower",[197,880,882],{"className":278,"code":881,"language":280,"meta":202,"style":202},"group by lower(host_name) as host\ngroup by upper(host_name) as host\n",[138,883,884,903],{"__ignoreMap":202},[206,885,886,888,890,893,895,897,899,901],{"class":208,"line":209},[206,887,669],{"class":309},[206,889,345],{"class":226},[206,891,892],{"class":226}," lower",[206,894,788],{"class":216},[206,896,616],{"class":309},[206,898,690],{"class":216},[206,900,802],{"class":226},[206,902,805],{"class":226},[206,904,905,907,909,912,914,916,918,920],{"class":208,"line":220},[206,906,669],{"class":309},[206,908,345],{"class":226},[206,910,911],{"class":226}," upper",[206,913,788],{"class":216},[206,915,616],{"class":309},[206,917,690],{"class":216},[206,919,802],{"class":226},[206,921,805],{"class":226},[128,923,924],{},"You can also use a regexp to extract a substring from the attribute value:",[197,926,928],{"className":278,"code":927,"language":280,"meta":202,"style":202},"group by extract(host_name, `^uptrace-prod-(\\w+)$`) as host\n",[138,929,930],{"__ignoreMap":202},[206,931,932,934,936,939,941,943,945,948,951,953,955],{"class":208,"line":209},[206,933,669],{"class":309},[206,935,345],{"class":226},[206,937,938],{"class":226}," extract",[206,940,788],{"class":216},[206,942,791],{"class":309},[206,944,822],{"class":226},[206,946,947],{"class":309},"^uptrace-prod-(\\w+",[206,949,950],{"class":226},")$`",[206,952,690],{"class":216},[206,954,802],{"class":226},[206,956,805],{"class":226},[124,958,960],{"id":959},"filtering","Filtering",[128,962,963],{},"Uptrace supports all the same filters just like PromQL:",[197,965,967],{"className":278,"code":966,"language":280,"meta":202,"style":202},"node_cpu_seconds_total{cpu=\"0\",mode=\"idle\"}\nnode_cpu_seconds_total{cpu!=\"0\",mode~\"user|system\"}\n",[138,968,969,991],{"__ignoreMap":202},[206,970,971,973,976,979,982,985,988],{"class":208,"line":209},[206,972,357],{"class":309},[206,974,975],{"class":226},"{cpu=",[206,977,978],{"class":309},"\"0\"",[206,980,981],{"class":309},",mode",[206,983,984],{"class":226},"=",[206,986,987],{"class":309},"\"idle\"",[206,989,990],{"class":309},"}\n",[206,992,993,995,998,1000,1003,1006],{"class":208,"line":220},[206,994,357],{"class":309},[206,996,997],{"class":226},"{cpu!=",[206,999,978],{"class":309},[206,1001,1002],{"class":309},",mode~",[206,1004,1005],{"class":309},"\"user|system\"",[206,1007,990],{"class":309},[128,1009,1010],{},"In addition, you can also add global filters that affect all expressions:",[197,1012,1014],{"className":278,"code":1013,"language":280,"meta":202,"style":202},"$metric1 | $metric2 | where host = \"myhost\" | where service = \"myservice\"\n\n# The same using inline filters.\n$metric1{host=\"myhost\",service=\"myservice\"} | $metric2{host=\"myhost\",service=\"myservice\"}\n",[138,1015,1016,1049,1053,1058],{"__ignoreMap":202},[206,1017,1018,1020,1022,1024,1026,1029,1032,1035,1038,1040,1042,1044,1046],{"class":208,"line":209},[206,1019,631],{"class":216},[206,1021,292],{"class":306},[206,1023,666],{"class":216},[206,1025,292],{"class":306},[206,1027,1028],{"class":309}," where",[206,1030,1031],{"class":226}," host",[206,1033,1034],{"class":226}," =",[206,1036,1037],{"class":226}," \"myhost\"",[206,1039,639],{"class":306},[206,1041,1028],{"class":309},[206,1043,735],{"class":226},[206,1045,1034],{"class":226},[206,1047,1048],{"class":226}," \"myservice\"\n",[206,1050,1051],{"class":208,"line":220},[206,1052,381],{"emptyLinePlaceholder":10},[206,1054,1055],{"class":208,"line":230},[206,1056,1057],{"class":451},"# The same using inline filters.\n",[206,1059,1060,1063,1065,1068,1071,1073,1076,1079,1081,1084,1087,1090,1093,1095,1097],{"class":208,"line":267},[206,1061,1062],{"class":216},"$metric1{host",[206,1064,984],{"class":306},[206,1066,1067],{"class":226},"\"myhost\",",[206,1069,1070],{"class":216},"service",[206,1072,984],{"class":306},[206,1074,1075],{"class":226},"\"myservice\"",[206,1077,1078],{"class":216},"} ",[206,1080,292],{"class":306},[206,1082,1083],{"class":216}," $metric2",[206,1085,1086],{"class":226},"{host=",[206,1088,1089],{"class":309},"\"myhost\"",[206,1091,1092],{"class":309},",service",[206,1094,984],{"class":226},[206,1096,1075],{"class":309},[206,1098,990],{"class":309},[128,1100,1101],{},"Global filters support the following operators:",[132,1103,1104,1128,1139,1150],{},[135,1105,1106,1108,1109,1108,1112,1108,1115,1108,1118,1108,1121,1124,1125,179],{},[138,1107,984],{},", ",[138,1110,1111],{},"!=",[138,1113,1114],{},"\u003C",[138,1116,1117],{},"\u003C=",[138,1119,1120],{},">",[138,1122,1123],{},">=",", for example, ",[138,1126,1127],{},"where host_name = \"myhost\"",[135,1129,1130,1108,1133,1124,1136,179],{},[138,1131,1132],{},"~",[138,1134,1135],{},"!~",[138,1137,1138],{},"where host_name ~ \"^prod-[a-z]+-[0-9]+$\"",[135,1140,1141,1108,1144,1124,1147,179],{},[138,1142,1143],{},"like",[138,1145,1146],{},"not like",[138,1148,1149],{},"where host_name like \"prod-%\"",[135,1151,1152,1108,1155,1124,1158,179],{},[138,1153,1154],{},"in",[138,1156,1157],{},"not in",[138,1159,1160],{},"where host_name in (\"host1\", \"host2\")",[124,1162,1164],{"id":1163},"joining","Joining",[128,1166,1167],{},"Uptrace supports math between series, for example, to add all equally-labelled series from both sides:",[197,1169,1171],{"className":278,"code":1170,"language":280,"meta":202,"style":202},"$mem_free + $mem_cached group by host_name, service_name\n\n# The same.\n$mem_free by (host_name, service_name) + $mem_cached by (host_name, service_name)\n",[138,1172,1173,1178,1182,1186],{"__ignoreMap":202},[206,1174,1175],{"class":208,"line":209},[206,1176,1177],{"class":216},"$mem_free + $mem_cached group by host_name, service_name\n",[206,1179,1180],{"class":208,"line":220},[206,1181,381],{"emptyLinePlaceholder":10},[206,1183,1184],{"class":208,"line":230},[206,1185,596],{"class":451},[206,1187,1188,1191,1193,1195,1198,1200,1202],{"class":208,"line":267},[206,1189,1190],{"class":216},"$mem_free by (",[206,1192,791],{"class":309},[206,1194,730],{"class":226},[206,1196,1197],{"class":216},") + $mem_cached by (",[206,1199,791],{"class":309},[206,1201,730],{"class":226},[206,1203,360],{"class":216},[128,1205,1206],{},"Uptrace also automatically supports one-to-many\u002Fmany-to-one joins:",[197,1208,1210],{"className":278,"code":1209,"language":280,"meta":202,"style":202},"# One-to-many\n$metric by (type) \u002F $metric by (service_name, type)\n\n# Many-to-one\n$metric by (service_name, type) \u002F $metric by (type)\n",[138,1211,1212,1217,1235,1239,1244],{"__ignoreMap":202},[206,1213,1214],{"class":208,"line":209},[206,1215,1216],{"class":451},"# One-to-many\n",[206,1218,1219,1222,1224,1227,1230,1233],{"class":208,"line":220},[206,1220,1221],{"class":216},"$metric by (",[206,1223,584],{"class":583},[206,1225,1226],{"class":216},") \u002F $metric by (",[206,1228,1229],{"class":309},"service_name,",[206,1231,1232],{"class":226}," type",[206,1234,360],{"class":216},[206,1236,1237],{"class":208,"line":230},[206,1238,381],{"emptyLinePlaceholder":10},[206,1240,1241],{"class":208,"line":267},[206,1242,1243],{"class":451},"# Many-to-one\n",[206,1245,1246,1248,1250,1252,1254,1256],{"class":208,"line":409},[206,1247,1221],{"class":216},[206,1249,1229],{"class":309},[206,1251,1232],{"class":226},[206,1253,1226],{"class":216},[206,1255,584],{"class":583},[206,1257,360],{"class":216},[128,1259,1260],{},"If attribute names don't match, you can rename them like this:",[197,1262,1264],{"className":278,"code":1263,"language":280,"meta":202,"style":202},"$metric by (hostname as host) + $metric by (host_name as host)\n",[138,1265,1266],{"__ignoreMap":202},[206,1267,1268,1270,1273,1275,1277,1280,1282,1284,1286],{"class":208,"line":209},[206,1269,1221],{"class":216},[206,1271,1272],{"class":309},"hostname",[206,1274,724],{"class":226},[206,1276,1031],{"class":226},[206,1278,1279],{"class":216},") + $metric by (",[206,1281,616],{"class":309},[206,1283,724],{"class":226},[206,1285,1031],{"class":226},[206,1287,360],{"class":216},[124,1289,1291],{"id":1290},"supported-functions","Supported functions",[128,1293,1294],{},"Uptrace supports the following types of functions:",[132,1296,1297,1303,1309,1315,1321],{},[135,1298,1299],{},[184,1300,1302],{"href":1301},"#aggregate","aggregate",[135,1304,1305],{},[184,1306,1308],{"href":1307},"#rollup","rollup",[135,1310,1311],{},[184,1312,1314],{"href":1313},"#transform","transform",[135,1316,1317],{},[184,1318,1320],{"href":1319},"#attribute-manipulation","attribute manipulation",[135,1322,1323],{},[184,1324,1326],{"href":1325},"#if","if",[128,1328,1329,1330,1336],{},"If Uptrace does not support the function you need, please ",[184,1331,1335],{"href":1332,"rel":1333},"https:\u002F\u002Fgithub.com\u002Fuptrace\u002Fuptrace\u002Fissues",[1334],"nofollow","open an issue"," on GitHub.",[1338,1339,1340],"h3",{"id":1302},"Aggregate",[128,1342,1343],{},"Aggregate functions combine multiple timeseries using the specified function and grouping attributes. When possible, aggregation is pushed down to ClickHouse for maximum efficiency.",[132,1345,1346,1351,1356,1360,1364],{},[135,1347,1348],{},[138,1349,1350],{},"min",[135,1352,1353],{},[138,1354,1355],{},"max",[135,1357,1358],{},[138,1359,342],{},[135,1361,1362],{},[138,1363,386],{},[135,1365,1366,1108,1369,1108,1372,1108,1375,1108,1378,1108,1381,1384],{},[138,1367,1368],{},"median",[138,1370,1371],{},"p50",[138,1373,1374],{},"p75",[138,1376,1377],{},"p90",[138,1379,1380],{},"p99",[138,1382,1383],{},"count",". Only histograms.",[128,1386,1387,1388,1390,1391,1394],{},"The ",[138,1389,1383],{}," function returns the number of observed values in a histogram. To count the number of timeseries, use ",[138,1392,1393],{},"uniq($metric, attr1, attr2)",", which efficiently counts the number of timeseries in the database without selecting all timeseries.",[1338,1396,1397],{"id":1308},"Rollup",[128,1399,1400],{},"Rollup (or range\u002Fwindow) functions calculate rollups over data points in the specified lookbehind window. The number of timeseries and the number of datapoints remain the same.",[132,1402,1403,1420,1428],{},[135,1404,1405,1108,1408,1108,1411,1108,1414,1108,1417],{},[138,1406,1407],{},"min_over_time",[138,1409,1410],{},"max_over_time",[138,1412,1413],{},"sum_over_time",[138,1415,1416],{},"avg_over_time",[138,1418,1419],{},"median_over_time",[135,1421,1422,146,1425],{},[138,1423,1424],{},"rate",[138,1426,1427],{},"irate",[135,1429,1430,146,1433],{},[138,1431,1432],{},"increase",[138,1434,1435],{},"delta",[128,1437,478,1438,482,1441,486,1443,490,1445,179],{},[138,1439,1440],{},"rate($metric[5i])",[138,1442,485],{},[488,1444,485],{},[138,1446,493],{},[1338,1448,1449],{"id":1314},"Transform",[128,1451,1452],{},"Transform functions operate on each point of each timeseries. The number of timeseries and the number of datapoints remain the same.",[132,1454,1455,1460,1471,1485,1499,1513,1521,1535,1544,1553,1565],{},[135,1456,1457],{},[138,1458,1459],{},"abs",[135,1461,1462,1108,1465,1108,1468],{},[138,1463,1464],{},"ceil",[138,1466,1467],{},"floor",[138,1469,1470],{},"trunc",[135,1472,1473,1108,1476,1108,1479,1108,1482],{},[138,1474,1475],{},"cos",[138,1477,1478],{},"cosh",[138,1480,1481],{},"acos",[138,1483,1484],{},"acosh",[135,1486,1487,1108,1490,1108,1493,1108,1496],{},[138,1488,1489],{},"sin",[138,1491,1492],{},"sinh",[138,1494,1495],{},"asin",[138,1497,1498],{},"asinh",[135,1500,1501,1108,1504,1108,1507,1108,1510],{},[138,1502,1503],{},"tan",[138,1505,1506],{},"tanh",[138,1508,1509],{},"atan",[138,1511,1512],{},"atanh",[135,1514,1515,1108,1518],{},[138,1516,1517],{},"exp",[138,1519,1520],{},"exp2",[135,1522,1523,1108,1526,1108,1529,1108,1532],{},[138,1524,1525],{},"ln",[138,1527,1528],{},"log",[138,1530,1531],{},"log2",[138,1533,1534],{},"log10",[135,1536,1537,1540,1541,179],{},[138,1538,1539],{},"perSec"," divides each point by the number of seconds in the grouping interval. You can achieve the same with ",[138,1542,1543],{},"$metric \u002F _seconds",[135,1545,1546,1549,1550,179],{},[138,1547,1548],{},"perMin"," divides each point by the number of minutes in the grouping interval. You can achieve the same with ",[138,1551,1552],{},"$metric \u002F _minutes",[135,1554,1555,1558,1559,1562,1563,179],{},[138,1556,1557],{},"clamp_min(ts timeseries, min scalar)"," clamps ",[138,1560,1561],{},"ts"," values to have a lower limit of ",[138,1564,1350],{},[135,1566,1567,1558,1570,1572,1573,179],{},[138,1568,1569],{},"clamp_max(ts timeseries, max scalar)",[138,1571,1561],{}," values to have an upper limit of ",[138,1574,1355],{},[1338,1576,1578],{"id":1577},"attribute-manipulation","Attribute manipulation",[128,1580,1581],{},"Additionally, these functions manipulate attributes and can only be used in grouping expressions:",[132,1583,1584,1594,1602,1612,1621,1634,1650],{},[135,1585,1586,1589,1590,1593],{},[138,1587,1588],{},"lower(attr)"," lowers the case of the ",[138,1591,1592],{},"attr"," value.",[135,1595,1596,1599,1600,1593],{},[138,1597,1598],{},"upper(attr)"," uppers the case of the ",[138,1601,1592],{},[135,1603,1604,1607,1608,1611],{},[138,1605,1606],{},"trimPrefix(attr, \"prefix\")"," removes the provided leading ",[138,1609,1610],{},"prefix"," string.",[135,1613,1614,1617,1618,1611],{},[138,1615,1616],{},"trimSuffix(attr, \"suffix\")"," removes the provided trailing ",[138,1619,1620],{},"suffix",[135,1622,1623,1626,1627,1630,1631,179],{},[138,1624,1625],{},"extract(haystack, pattern)"," extracts a fragment of the ",[138,1628,1629],{},"haystack"," string using the regular expression ",[138,1632,1633],{},"pattern",[135,1635,1636,1639,1640,1643,1644,1646,1647,1611],{},[138,1637,1638],{},"replace(haystack, substring, replacement)"," replaces all occurrences of the ",[138,1641,1642],{},"substring"," in ",[138,1645,1629],{}," by the ",[138,1648,1649],{},"replacement",[135,1651,1652,1655,1656,1643,1658,1646,1660,1611],{},[138,1653,1654],{},"replaceRegexp(haystack, pattern, replacement)"," replaces all occurrences of the substring matching the regular expression ",[138,1657,1633],{},[138,1659,1629],{},[138,1661,1649],{},[1338,1663,1664],{"id":1326},"If",[128,1666,1667,1668,1670,1671,1674,1675,1678,1679,1682,1683,1686,1687,1690],{},"The special ",[138,1669,1326],{}," function enables conditional branching. If the condition ",[138,1672,1673],{},"cond"," evaluates to a value other than zero, the function returns the result of the ",[138,1676,1677],{},"then"," expression. If cond evaluates to ",[138,1680,1681],{},"0"," or ",[138,1684,1685],{},"NaN",", then the result of the ",[138,1688,1689],{},"else"," expression is returned.",[197,1692,1697],{"className":1693,"code":1695,"language":1696},[1694],"language-text","if(cond, then)\nif(cond, then, else)\n","text",[138,1698,1695],{"__ignoreMap":202},[128,1700,1701,1702,1704],{},"For example, you can use ",[138,1703,1326],{}," to calculate the hit rate only if the number of hits and misses exceeds a certain threshold:",[197,1706,1709],{"className":1707,"code":1708,"language":1696},[1694],"if(\n  sum($hits) + sum($misses) >= 100,\n  sum($misses) \u002F (sum($hits) + sum($misses))\n) as hit_rate\n",[138,1710,1708],{"__ignoreMap":202},[128,1712,1713,1714,1716,1717,1720,1721,1723,1724,1726],{},"When you omit the ",[138,1715,1689],{}," expression, Uptrace uses the ",[138,1718,1719],{},"null"," value. If all timeseries values are ",[138,1722,1719],{},", Uptrace removes such timeseries from the result. If you want to keep all timeseries, you can specify the ",[138,1725,1689],{}," expression:",[197,1728,1731],{"className":1729,"code":1730,"language":1696},[1694],"if(cond, else, 1)\nif(cond, else, NaN)\n",[138,1732,1730],{"__ignoreMap":202},[124,1734,1736],{"id":1735},"offset","Offset",[128,1738,1387,1739,1741],{},[138,1740,1735],{}," modifier allows to set time offset for the query.",[128,1743,1744,1745,1748],{},"For example, this query retrieves the value of ",[138,1746,1747],{},"http_requests_total"," from 5 minutes ago, relative to the query evaluation time:",[197,1750,1752],{"className":278,"code":1751,"language":280,"meta":202,"style":202},"$http_requests_total offset 5m\n",[138,1753,1754],{"__ignoreMap":202},[206,1755,1756],{"class":208,"line":209},[206,1757,1751],{"class":216},[128,1759,1760],{},"A negative offset allows to look ahead of the query evaluation time:",[197,1762,1764],{"className":278,"code":1763,"language":280,"meta":202,"style":202},"$http_requests_total offset -5m\n",[138,1765,1766],{"__ignoreMap":202},[206,1767,1768],{"class":208,"line":209},[206,1769,1763],{"class":216},[534,1771,1772],{},"html pre.shiki code .s7eDp, html code.shiki .s7eDp{--shiki-default:#6F42C1}html pre.shiki code .sgsFI, html code.shiki .sgsFI{--shiki-default:#24292E}html pre.shiki code .sYu0t, html code.shiki .sYu0t{--shiki-default:#005CC5}html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}html pre.shiki code .sYBdl, html code.shiki .sYBdl{--shiki-default:#032F62}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sD7c4, html code.shiki .sD7c4{--shiki-default:#D73A49}",{"title":202,"searchDepth":267,"depth":220,"links":1774},[1775,1776,1777,1778,1785],{"id":704,"depth":220,"text":705},{"id":959,"depth":220,"text":960},{"id":1163,"depth":220,"text":1164},{"id":1290,"depth":220,"text":1291,"children":1779},[1780,1781,1782,1783,1784],{"id":1302,"depth":230,"text":1340},{"id":1308,"depth":230,"text":1397},{"id":1314,"depth":230,"text":1449},{"id":1577,"depth":230,"text":1578},{"id":1326,"depth":230,"text":1664},{"id":1735,"depth":220,"text":1736},{"readingTime":1787},{"text":1788,"minutes":1789,"time":1790,"words":1791},"4 min read",3.725,223500,745,"\u002Fpartials\u002F_querying-metrics",{"description":568},"partials\u002F_querying-metrics","QLI3_6o-NpIQaDjktuI--sabRLoD3BcDaHEgQXgBJBQ",1778588617902]