[{"data":1,"prerenderedAt":2829},["ShallowReactive",2],{"\u002Ffeatures\u002Fmetrics\u002Freference-navigation":3,"\u002Ffeatures\u002Fmetrics\u002Freference":146},[4,8,32,42,59,77,81,85,95,104,108,112,116,120,124,128],{"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,28],{"title":15,"path":11,"stem":12},"Introduction",{"title":17,"path":18,"stem":19},"Grouping & systems","\u002Ffeatures\u002Ftraces\u002Fgrouping","features\u002F01.traces\u002F02.grouping",{"title":21,"path":22,"stem":23},"Querying spans","\u002Ffeatures\u002Ftraces\u002Fquerying-spans","features\u002F01.traces\u002F03.querying-spans",{"title":25,"path":26,"stem":27},"Querying traces","\u002Ffeatures\u002Ftraces\u002Fquerying-traces","features\u002F01.traces\u002F04.querying-traces",{"title":29,"path":30,"stem":31},"Reference","\u002Ffeatures\u002Ftraces\u002Freference","features\u002F01.traces\u002F05.reference",{"title":33,"closed":10,"path":34,"stem":35,"children":36,"page":-1},"Logs","\u002Ffeatures\u002Flogs","features\u002F02.logs\u002Findex",[37,38],{"title":15,"path":34,"stem":35},{"title":39,"path":40,"stem":41},"Grouping rules","\u002Ffeatures\u002Flogs\u002Fgrouping","features\u002F02.logs\u002Fgrouping",{"title":43,"closed":10,"path":44,"stem":45,"children":46,"page":-1},"Metrics","\u002Ffeatures\u002Fmetrics","features\u002F03.metrics\u002Findex",[47,48,52,56],{"title":15,"path":44,"stem":45},{"title":49,"path":50,"stem":51},"Querying","\u002Ffeatures\u002Fmetrics\u002Fquerying","features\u002F03.metrics\u002F02.querying",{"title":53,"path":54,"stem":55},"PromQL compat","\u002Ffeatures\u002Fmetrics\u002Fpromql-compat","features\u002F03.metrics\u002F03.promql-compat",{"title":29,"path":57,"stem":58},"\u002Ffeatures\u002Fmetrics\u002Freference","features\u002F03.metrics\u002F04.reference",{"title":60,"closed":10,"path":61,"stem":62,"children":63,"page":-1},"Alerting","\u002Ffeatures\u002Falerting","features\u002F04.alerting\u002Findex",[64,65,69,73],{"title":15,"path":61,"stem":62},{"title":66,"path":67,"stem":68},"Error monitors","\u002Ffeatures\u002Falerting\u002Ferror-monitors","features\u002F04.alerting\u002Ferror-monitors",{"title":70,"path":71,"stem":72},"Metric monitors","\u002Ffeatures\u002Falerting\u002Fmetric-monitors","features\u002F04.alerting\u002Fmetric-monitors",{"title":74,"path":75,"stem":76},"Notifications","\u002Ffeatures\u002Falerting\u002Fnotifications","features\u002F04.alerting\u002Fnotifications",{"title":78,"path":79,"stem":80},"Searching","\u002Ffeatures\u002Fsearching","features\u002F04.searching",{"title":82,"path":83,"stem":84},"Chart Annotations","\u002Ffeatures\u002Fannotations","features\u002F05.annotations",{"title":86,"path":87,"stem":88,"children":89,"closed":10},"Dashboards","\u002Ffeatures\u002Fdashboards","features\u002F06.dashboards\u002F01.index",[90,91],{"title":86,"path":87,"stem":88},{"title":92,"path":93,"stem":94},"YAML Templates","\u002Ffeatures\u002Fdashboards\u002Fyaml","features\u002F06.dashboards\u002F02.yaml",{"title":96,"path":97,"stem":98,"children":99,"closed":10},"Transformations","\u002Ffeatures\u002Ftransformations","features\u002F07.transformations\u002F01.index",[100,101],{"title":15,"path":97,"stem":98},{"title":29,"path":102,"stem":103},"\u002Ffeatures\u002Ftransformations\u002Freference","features\u002F07.transformations\u002F02.reference",{"title":105,"path":106,"stem":107},"Service Graph","\u002Ffeatures\u002Fservice-graph","features\u002F08.service-graph",{"title":109,"path":110,"stem":111},"Grafana integration","\u002Ffeatures\u002Fgrafana","features\u002F09.grafana",{"title":113,"path":114,"stem":115},"Data fixtures","\u002Ffeatures\u002Ffixtures","features\u002F10.fixtures",{"title":117,"path":118,"stem":119},"JavaScript Source Maps","\u002Ffeatures\u002Fsourcemaps","features\u002F11.sourcemaps",{"title":121,"path":122,"stem":123},"MCP Server","\u002Ffeatures\u002Fmcp","features\u002F12.mcp",{"title":125,"path":126,"stem":127},"Observability as Code","\u002Ffeatures\u002Fobservability-as-code","features\u002F13.observability-as-code",{"title":129,"closed":10,"path":130,"stem":131,"children":132,"page":145},"SSO","\u002Ffeatures\u002Fsso","features\u002Fsso",[133,137,141],{"title":134,"path":135,"stem":136},"Google","\u002Ffeatures\u002Fsso\u002Fgoogle","features\u002Fsso\u002F01.google",{"title":138,"path":139,"stem":140},"Okta","\u002Ffeatures\u002Fsso\u002Fokta","features\u002Fsso\u002F02.okta",{"title":142,"path":143,"stem":144},"Keycloak","\u002Ffeatures\u002Fsso\u002Fkeycloak","features\u002Fsso\u002F03.keycloak",false,{"page":147,"surround":2824},{"id":148,"title":149,"author":150,"body":151,"date":150,"description":2813,"extension":2814,"image":150,"meta":2815,"navigation":2821,"path":57,"seo":2822,"stem":58,"surround_disabled":145,"__hash__":2823},"features\u002Ffeatures\u002F03.metrics\u002F04.reference.md","Metrics query language reference",null,{"type":152,"value":153,"toc":2778},"minimark",[154,167,179,184,192,240,245,248,331,372,406,410,417,444,448,462,483,487,492,507,511,518,537,551,555,561,752,816,824,828,831,868,872,881,900,940,944,954,958,965,1155,1162,1166,1171,1234,1238,1241,1462,1470,1489,1493,1496,1500,1532,1545,1549,1664,1668,1758,1762,1809,1813,1816,1947,1984,1988,1992,2040,2043,2100,2121,2129,2133,2184,2187,2204,2224,2228,2231,2330,2333,2375,2378,2409,2413,2416,2498,2581,2585,2591,2636,2639,2702,2705,2749,2753,2774],[155,156,157,158,162,163,166],"p",{},"This page lists every function, operator, and selector the Uptrace metrics query language accepts. To learn how to write queries, start with ",[159,160,161],"a",{"href":50},"Querying metrics","; to adapt existing Prometheus queries, see ",[159,164,165],{"href":54},"PromQL compatibility",".",[168,169,171],"alert",{"type":170},"info",[155,172,173,174,178],{},"Not every function works with every metric. Which aggregation a metric accepts depends on its ",[159,175,177],{"href":176},"#instruments","instrument",", so read that section before the function tables.",[180,181,183],"h2",{"id":182},"selectors","Selectors",[155,185,186,187,191],{},"A query references a metric through an alias that starts with ",[188,189,190],"code",{},"$",":",[193,194,199],"pre",{"className":195,"code":196,"language":197,"meta":198,"style":198},"language-yaml shiki shiki-themes github-light","metrics:\n  - system_filesystem_usage as $fs_usage\nquery:\n  - sum($fs_usage)\n","yaml","",[188,200,201,214,224,232],{"__ignoreMap":198},[202,203,206,210],"span",{"class":204,"line":205},"line",1,[202,207,209],{"class":208},"shJU0","metrics",[202,211,213],{"class":212},"sgsFI",":\n",[202,215,217,220],{"class":204,"line":216},2,[202,218,219],{"class":212},"  - ",[202,221,223],{"class":222},"sYBdl","system_filesystem_usage as $fs_usage\n",[202,225,227,230],{"class":204,"line":226},3,[202,228,229],{"class":208},"query",[202,231,213],{"class":212},[202,233,235,237],{"class":204,"line":234},4,[202,236,219],{"class":212},[202,238,239],{"class":222},"sum($fs_usage)\n",[241,242,244],"h3",{"id":243},"attribute-filters","Attribute filters",[155,246,247],{},"Filter a selector by attributes inside curly braces:",[249,250,251,267],"table",{},[252,253,254],"thead",{},[255,256,257,261,264],"tr",{},[258,259,260],"th",{},"Operator",[258,262,263],{},"Example",[258,265,266],{},"Description",[268,269,270,286,301,316],"tbody",{},[255,271,272,278,283],{},[273,274,275],"td",{},[188,276,277],{},"=",[273,279,280],{},[188,281,282],{},"$fs_usage{state=\"used\"}",[273,284,285],{},"Attribute equals the value",[255,287,288,293,298],{},[273,289,290],{},[188,291,292],{},"!=",[273,294,295],{},[188,296,297],{},"$fs_usage{state!=\"free\"}",[273,299,300],{},"Attribute does not equal",[255,302,303,308,313],{},[273,304,305],{},[188,306,307],{},"~",[273,309,310],{},[188,311,312],{},"$fs_usage{host_name~\"^prod-\"}",[273,314,315],{},"Attribute matches the regexp",[255,317,318,323,328],{},[273,319,320],{},[188,321,322],{},"!~",[273,324,325],{},[188,326,327],{},"$fs_usage{host_name!~\"^test-\"}",[273,329,330],{},"Attribute does not match",[155,332,333,334,337,338,340,341,340,343,340,346,340,349,340,352,340,355,340,357,340,359,340,362,340,365,368,369,191],{},"You can also filter every expression in a query at once with ",[188,335,336],{},"where",", which supports ",[188,339,277],{},", ",[188,342,292],{},[188,344,345],{},"\u003C",[188,347,348],{},"\u003C=",[188,350,351],{},">",[188,353,354],{},">=",[188,356,307],{},[188,358,322],{},[188,360,361],{},"like",[188,363,364],{},"not like",[188,366,367],{},"in",", and ",[188,370,371],{},"not in",[193,373,377],{"className":374,"code":375,"language":376,"meta":198,"style":198},"language-shell shiki shiki-themes github-light","$hits | $misses | where host_name = 'localhost'\n","shell",[188,378,379],{"__ignoreMap":198},[202,380,381,384,388,391,393,397,400,403],{"class":204,"line":205},[202,382,383],{"class":212},"$hits ",[202,385,387],{"class":386},"sD7c4","|",[202,389,390],{"class":212}," $misses ",[202,392,387],{"class":386},[202,394,396],{"class":395},"s7eDp"," where",[202,398,399],{"class":222}," host_name",[202,401,402],{"class":222}," =",[202,404,405],{"class":222}," 'localhost'\n",[241,407,409],{"id":408},"value-filter","Value filter",[155,411,412,413,416],{},"The ",[188,414,415],{},"_value"," pseudo-attribute filters timeseries by the datapoint value, not by an attribute. Use it to count series in a given state:",[193,418,420],{"className":374,"code":419,"language":376,"meta":198,"style":198},"uniq($status{_value=1}) as num_up | uniq($status{_value=0}) as num_down\n",[188,421,422],{"__ignoreMap":198},[202,423,424,427,430,433,435,438,441],{"class":204,"line":205},[202,425,426],{"class":395},"uniq($status",[202,428,429],{"class":222},"{_value=1}",[202,431,432],{"class":212},") as num_up ",[202,434,387],{"class":386},[202,436,437],{"class":395}," uniq($status",[202,439,440],{"class":222},"{_value=0}",[202,442,443],{"class":212},") as num_down\n",[241,445,447],{"id":446},"time-qualifier","Time qualifier",[155,449,450,453,454,457,458,461],{},[188,451,452],{},"$metric._time"," reads the datapoint timestamp instead of the value. It accepts only ",[188,455,456],{},"min"," and ",[188,459,460],{},"max",", which return the first and the last time the metric reported:",[193,463,465],{"className":374,"code":464,"language":376,"meta":198,"style":198},"min($cache._time) | max($cache._time)\n",[188,466,467],{"__ignoreMap":198},[202,468,469,472,475,477,480],{"class":204,"line":205},[202,470,471],{"class":395},"min($cache._time",[202,473,474],{"class":212},") ",[202,476,387],{"class":386},[202,478,479],{"class":395}," max($cache._time",[202,481,482],{"class":212},")\n",[241,484,486],{"id":485},"offset","Offset",[155,488,489,491],{},[188,490,485],{}," shifts the query window. A negative offset looks ahead of the evaluation time:",[193,493,495],{"className":374,"code":494,"language":376,"meta":198,"style":198},"$http_requests_total offset 5m\n$http_requests_total offset -5m\n",[188,496,497,502],{"__ignoreMap":198},[202,498,499],{"class":204,"line":205},[202,500,501],{"class":212},"$http_requests_total offset 5m\n",[202,503,504],{"class":204,"line":216},[202,505,506],{"class":212},"$http_requests_total offset -5m\n",[241,508,510],{"id":509},"lookbehind-window","Lookbehind window",[155,512,513,514,517],{},"Rollup functions read a lookbehind window you can set in square brackets, where ",[188,515,516],{},"i"," is the current grouping interval:",[193,519,521],{"className":374,"code":520,"language":376,"meta":198,"style":198},"rate($metric[5i])\nmax_over_time($metric[1d])\n",[188,522,523,530],{"__ignoreMap":198},[202,524,525,528],{"class":204,"line":205},[202,526,527],{"class":395},"rate($metric[5i]",[202,529,482],{"class":212},[202,531,532,535],{"class":204,"line":216},[202,533,534],{"class":395},"max_over_time($metric[1d]",[202,536,482],{"class":212},[155,538,539,540,457,543,546,547,550],{},"When you omit the window, a rollup reads only the current interval. ",[188,541,542],{},"rate",[188,544,545],{},"irate"," are the exception: they look back ",[188,548,549],{},"max(5 × interval, 5m)",", so the first buckets of a fine grid still have an earlier sample to rate against.",[180,552,554],{"id":553},"instruments","Instruments",[155,556,557,558,166],{},"A metric's instrument decides which aggregations it accepts. An aggregation the instrument cannot compute fails the query with ",[188,559,560],{},"\u003Cinstrument> instrument does not support \"\u003Cfunc>\"",[249,562,563,589],{},[252,564,565],{},[255,566,567,570,574,577,580,583,586],{},[258,568,569],{},"Aggregation",[258,571,573],{"align":572},"center","Counter",[258,575,576],{"align":572},"Gauge",[258,578,579],{"align":572},"PromCounter",[258,581,582],{"align":572},"Additive",[258,584,585],{"align":572},"Summary",[258,587,588],{"align":572},"Histogram",[268,590,591,611,630,650,669,691,710,733],{},[255,592,593,598,601,603,605,607,609],{},[273,594,595],{},[188,596,597],{},"sum",[273,599,600],{"align":572},"✓",[273,602,600],{"align":572},[273,604,600],{"align":572},[273,606,600],{"align":572},[273,608,600],{"align":572},[273,610,600],{"align":572},[255,612,613,618,620,622,624,626,628],{},[273,614,615],{},[188,616,617],{},"avg",[273,619],{"align":572},[273,621,600],{"align":572},[273,623,600],{"align":572},[273,625,600],{"align":572},[273,627,600],{"align":572},[273,629,600],{"align":572},[255,631,632,638,640,642,644,646,648],{},[273,633,634,340,636],{},[188,635,456],{},[188,637,460],{},[273,639],{"align":572},[273,641,600],{"align":572},[273,643,600],{"align":572},[273,645,600],{"align":572},[273,647,600],{"align":572},[273,649,600],{"align":572},[255,651,652,657,659,661,663,665,667],{},[273,653,654],{},[188,655,656],{},"median",[273,658],{"align":572},[273,660,600],{"align":572},[273,662,600],{"align":572},[273,664,600],{"align":572},[273,666],{"align":572},[273,668],{"align":572},[255,670,671,679,681,683,685,687,689],{},[273,672,673,340,676],{},[188,674,675],{},"stddev",[188,677,678],{},"stdvar",[273,680,600],{"align":572},[273,682,600],{"align":572},[273,684],{"align":572},[273,686],{"align":572},[273,688],{"align":572},[273,690],{"align":572},[255,692,693,698,700,702,704,706,708],{},[273,694,695],{},[188,696,697],{},"histogram_count",[273,699],{"align":572},[273,701],{"align":572},[273,703],{"align":572},[273,705],{"align":572},[273,707,600],{"align":572},[273,709,600],{"align":572},[255,711,712,721,723,725,727,729,731],{},[273,713,714,717,718],{},[188,715,716],{},"p50","…",[188,719,720],{},"p99",[273,722],{"align":572},[273,724],{"align":572},[273,726],{"align":572},[273,728],{"align":572},[273,730],{"align":572},[273,732,600],{"align":572},[255,734,735,740,742,744,746,748,750],{},[273,736,737],{},[188,738,739],{},"histogram_quantile",[273,741],{"align":572},[273,743],{"align":572},[273,745],{"align":572},[273,747],{"align":572},[273,749],{"align":572},[273,751,600],{"align":572},[753,754,755,769,777,789,794,809],"ul",{},[756,757,758,761,762,340,764,368,766,768],"li",{},[759,760,573],"strong",{}," measures a value that only grows, such as the number of processed requests. ",[188,763,456],{},[188,765,460],{},[188,767,617],{}," of a growing total carry no meaning, so the instrument rejects them.",[756,770,771,773,774,776],{},[759,772,576],{}," measures a value that goes up and down, such as memory utilization. ",[188,775,597],{}," exists for Prometheus and AWS compatibility, and it double-counts a gauge that reports more than once per interval.",[756,778,779,781,782,784,785,788],{},[759,780,579],{}," is a cumulative counter from Prometheus remote write or the Prometheus receiver. It keeps its running total, so wrap it in ",[188,783,542],{}," or ",[188,786,787],{},"increase"," to read a rate.",[756,790,791,793],{},[759,792,582],{}," measures a value that grows and shrinks and stays meaningful when summed across attributes, such as open connections.",[756,795,796,798,799,340,801,340,803,368,805,808],{},[759,797,585],{}," stores the ",[188,800,456],{},[188,802,460],{},[188,804,597],{},[188,806,807],{},"count"," of observed values. It keeps no buckets, so it has no percentiles.",[756,810,811,813,814,166],{},[759,812,588],{}," stores buckets, so it answers percentiles and ",[188,815,739],{},[155,817,818,457,821,823],{},[188,819,820],{},"uniq",[188,822,807],{}," work with every instrument, because they count timeseries rather than values.",[241,825,827],{"id":826},"bare-selector","Bare selector",[155,829,830],{},"A selector with no aggregation gets a default one, which depends on the instrument:",[249,832,833,846],{},[252,834,835],{},[255,836,837,840],{},[258,838,839],{},"Instrument",[258,841,842,845],{},[188,843,844],{},"$metric"," is the same as",[268,847,848,858],{},[255,849,850,853],{},[273,851,852],{},"Counter, Additive",[273,854,855],{},[188,856,857],{},"sum($metric)",[255,859,860,863],{},[273,861,862],{},"Gauge, PromCounter",[273,864,865],{},[188,866,867],{},"avg($metric)",[241,869,871],{"id":870},"where-an-aggregation-runs","Where an aggregation runs",[155,873,874,875,877,878,166],{},"Uptrace pushes an aggregation into ClickHouse when you apply it directly to a selector, which is why ",[188,876,857],{}," scans less data than ",[188,879,880],{},"sum($metric + 0)",[155,882,883,340,885,340,887,340,889,717,891,368,893,896,897,191],{},[188,884,807],{},[188,886,697],{},[188,888,739],{},[188,890,716],{},[188,892,720],{},[188,894,895],{},"apdex"," are pushdown-only: they have no in-process form. Applied anywhere but directly to a metric, they fail with ",[188,898,899],{},"\u003Cfunc>() must be applied to a metric",[193,901,903],{"className":374,"code":902,"language":376,"meta":198,"style":198},"# Valid.\np95($srv_duration)\n\n# Invalid — the argument is an expression, not a metric.\np95($a + $b)\n",[188,904,905,911,918,923,928],{"__ignoreMap":198},[202,906,907],{"class":204,"line":205},[202,908,910],{"class":909},"sAwPA","# Valid.\n",[202,912,913,916],{"class":204,"line":216},[202,914,915],{"class":395},"p95($srv_duration",[202,917,482],{"class":212},[202,919,920],{"class":204,"line":226},[202,921,922],{"emptyLinePlaceholder":10},"\n",[202,924,925],{"class":204,"line":234},[202,926,927],{"class":909},"# Invalid — the argument is an expression, not a metric.\n",[202,929,931,934,937],{"class":204,"line":930},5,[202,932,933],{"class":395},"p95($a",[202,935,936],{"class":222}," +",[202,938,939],{"class":212}," $b)\n",[241,941,943],{"id":942},"empty-buckets","Empty buckets",[155,945,946,947,949,950,953],{},"A time bucket with no datapoints reads as absent, and a chart draws a gap. ",[188,948,807],{}," is the exception: it reads as ",[188,951,952],{},"0",", which makes it suitable for \"how many series are reporting\" queries.",[180,955,957],{"id":956},"aggregate-functions","Aggregate functions",[155,959,960,961,166],{},"Aggregate functions combine timeseries at each timestamp. Grouping decides which series combine — see ",[159,962,964],{"href":963},"#grouping","Grouping",[249,966,967,976],{},[252,968,969],{},[255,970,971,974],{},[258,972,973],{},"Function",[258,975,266],{},[268,977,978,987,999,1009,1019,1029,1039,1049,1059,1072,1082,1092,1110,1131],{},[255,979,980,984],{},[273,981,982],{},[188,983,857],{},[273,985,986],{},"Sum of the timeseries.",[255,988,989,993],{},[273,990,991],{},[188,992,867],{},[273,994,995,996,166],{},"Average of the timeseries. For a histogram, the same as ",[188,997,998],{},"sum($metric) \u002F histogram_count($metric)",[255,1000,1001,1006],{},[273,1002,1003],{},[188,1004,1005],{},"min($metric)",[273,1007,1008],{},"Smallest value. For a histogram or a summary, the smallest observed value.",[255,1010,1011,1016],{},[273,1012,1013],{},[188,1014,1015],{},"max($metric)",[273,1017,1018],{},"Largest value. For a histogram or a summary, the largest observed value.",[255,1020,1021,1026],{},[273,1022,1023],{},[188,1024,1025],{},"median($metric)",[273,1027,1028],{},"Median of the timeseries.",[255,1030,1031,1036],{},[273,1032,1033],{},[188,1034,1035],{},"stddev($metric)",[273,1037,1038],{},"Population standard deviation across the timeseries. Counter and Gauge only.",[255,1040,1041,1046],{},[273,1042,1043],{},[188,1044,1045],{},"stdvar($metric)",[273,1047,1048],{},"Population variance across the timeseries. Counter and Gauge only.",[255,1050,1051,1056],{},[273,1052,1053],{},[188,1054,1055],{},"mad($metric)",[273,1057,1058],{},"Median absolute deviation. Runs in process, so it is not pushed into ClickHouse.",[255,1060,1061,1066],{},[273,1062,1063],{},[188,1064,1065],{},"count($metric)",[273,1067,1068,1069,1071],{},"Number of timeseries that reported. Takes no attributes, and reads ",[188,1070,952],{}," for an empty bucket.",[255,1073,1074,1079],{},[273,1075,1076],{},[188,1077,1078],{},"uniq($metric[, attr…])",[273,1080,1081],{},"Number of distinct values of the listed attributes. With no attributes, the number of timeseries.",[255,1083,1084,1089],{},[273,1085,1086],{},[188,1087,1088],{},"histogram_count($metric)",[273,1090,1091],{},"Number of observations. Summary and Histogram only.",[255,1093,1094,1099],{},[273,1095,1096],{},[188,1097,1098],{},"histogram_quantile(q, $metric)",[273,1100,1101,1102,1105,1106,1109],{},"Quantile ",[188,1103,1104],{},"q"," in the range ",[188,1107,1108],{},"[0..1]",". Histogram only.",[255,1111,1112,1117],{},[273,1113,1114],{},[188,1115,1116],{},"p50($metric)",[273,1118,1119,1120,340,1123,340,1126,340,1129,166],{},"50th percentile. Histogram only. Also ",[188,1121,1122],{},"p75",[188,1124,1125],{},"p90",[188,1127,1128],{},"p95",[188,1130,720],{},[255,1132,1133,1138],{},[273,1134,1135],{},[188,1136,1137],{},"apdex($metric, t1, t2)",[273,1139,1140,1146,1147,1150,1151,1154],{},[159,1141,1145],{"href":1142,"rel":1143},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FApdex",[1144],"nofollow","Apdex"," score with a satisfied threshold ",[188,1148,1149],{},"t1"," and a tolerating threshold ",[188,1152,1153],{},"t2",". Works with the built-in tracing metrics, which score span duration.",[155,1156,1157,457,1159,1161],{},[188,1158,675],{},[188,1160,678],{}," measure how far the timeseries spread apart. On a Counter they measure the spread of per-interval deltas, and on a Gauge the spread of the latest readings. The other instruments reject them: a PromCounter keeps a growing total, an Additive holds complementary parts of one whole, and a Summary or a Histogram no longer holds the individual observations.",[241,1163,1165],{"id":1164},"counting-timeseries","Counting timeseries",[155,1167,1168,1170],{},[188,1169,820],{}," counts distinct values, and it accepts grouping and a value filter:",[193,1172,1174],{"className":374,"code":1173,"language":376,"meta":198,"style":198},"# Number of timeseries.\nuniq($status) as num_checks\n\n# Distinct combinations of two attributes.\nuniq($hits, host_name, service_name) as num_timeseries\n\n# Distinct host_name for each service_name.\nuniq($hits by (service_name), host_name) as num_timeseries\n",[188,1175,1176,1181,1188,1192,1197,1211,1216,1222],{"__ignoreMap":198},[202,1177,1178],{"class":204,"line":205},[202,1179,1180],{"class":909},"# Number of timeseries.\n",[202,1182,1183,1185],{"class":204,"line":216},[202,1184,426],{"class":395},[202,1186,1187],{"class":212},") as num_checks\n",[202,1189,1190],{"class":204,"line":226},[202,1191,922],{"emptyLinePlaceholder":10},[202,1193,1194],{"class":204,"line":234},[202,1195,1196],{"class":909},"# Distinct combinations of two attributes.\n",[202,1198,1199,1202,1205,1208],{"class":204,"line":930},[202,1200,1201],{"class":395},"uniq($hits,",[202,1203,1204],{"class":222}," host_name,",[202,1206,1207],{"class":222}," service_name",[202,1209,1210],{"class":212},") as num_timeseries\n",[202,1212,1214],{"class":204,"line":1213},6,[202,1215,922],{"emptyLinePlaceholder":10},[202,1217,1219],{"class":204,"line":1218},7,[202,1220,1221],{"class":909},"# Distinct host_name for each service_name.\n",[202,1223,1225,1228,1231],{"class":204,"line":1224},8,[202,1226,1227],{"class":395},"uniq($hits",[202,1229,1230],{"class":222}," by",[202,1232,1233],{"class":212}," (service_name), host_name) as num_timeseries\n",[180,1235,1237],{"id":1236},"rollup-functions","Rollup functions",[155,1239,1240],{},"Rollup functions read the datapoints of one timeseries inside the lookbehind window. The number of timeseries stays the same.",[249,1242,1243,1251],{},[252,1244,1245],{},[255,1246,1247,1249],{},[258,1248,973],{},[258,1250,266],{},[268,1252,1253,1263,1276,1286,1297,1307,1317,1327,1337,1347,1357,1367,1377,1387,1397,1407,1417,1427,1440,1452],{},[255,1254,1255,1260],{},[273,1256,1257],{},[188,1258,1259],{},"rate($metric)",[273,1261,1262],{},"Per-second rate of increase. Sizes its window from the grouping interval.",[255,1264,1265,1270],{},[273,1266,1267],{},[188,1268,1269],{},"irate($metric)",[273,1271,1272,1273,1275],{},"Same as ",[188,1274,542],{}," in the current release.",[255,1277,1278,1283],{},[273,1279,1280],{},[188,1281,1282],{},"increase($metric)",[273,1284,1285],{},"Increase over the window.",[255,1287,1288,1293],{},[273,1289,1290],{},[188,1291,1292],{},"delta($metric)",[273,1294,1272,1295,166],{},[188,1296,787],{},[255,1298,1299,1304],{},[273,1300,1301],{},[188,1302,1303],{},"deriv($metric)",[273,1305,1306],{},"Per-second derivative of the values.",[255,1308,1309,1314],{},[273,1310,1311],{},[188,1312,1313],{},"changes($metric)",[273,1315,1316],{},"Number of times the value changed.",[255,1318,1319,1324],{},[273,1320,1321],{},[188,1322,1323],{},"resets($metric)",[273,1325,1326],{},"Number of counter resets.",[255,1328,1329,1334],{},[273,1330,1331],{},[188,1332,1333],{},"min_over_time($metric)",[273,1335,1336],{},"Smallest value in the window.",[255,1338,1339,1344],{},[273,1340,1341],{},[188,1342,1343],{},"max_over_time($metric)",[273,1345,1346],{},"Largest value in the window.",[255,1348,1349,1354],{},[273,1350,1351],{},[188,1352,1353],{},"sum_over_time($metric)",[273,1355,1356],{},"Sum of the values in the window.",[255,1358,1359,1364],{},[273,1360,1361],{},[188,1362,1363],{},"avg_over_time($metric)",[273,1365,1366],{},"Average of the values in the window.",[255,1368,1369,1374],{},[273,1370,1371],{},[188,1372,1373],{},"median_over_time($metric)",[273,1375,1376],{},"Median of the values in the window.",[255,1378,1379,1384],{},[273,1380,1381],{},[188,1382,1383],{},"mad_over_time($metric)",[273,1385,1386],{},"Median absolute deviation in the window.",[255,1388,1389,1394],{},[273,1390,1391],{},[188,1392,1393],{},"stddev_over_time($metric)",[273,1395,1396],{},"Population standard deviation in the window.",[255,1398,1399,1404],{},[273,1400,1401],{},[188,1402,1403],{},"stdvar_over_time($metric)",[273,1405,1406],{},"Population variance in the window.",[255,1408,1409,1414],{},[273,1410,1411],{},[188,1412,1413],{},"first_over_time($metric)",[273,1415,1416],{},"First value in the window.",[255,1418,1419,1424],{},[273,1420,1421],{},[188,1422,1423],{},"last_over_time($metric)",[273,1425,1426],{},"Last value in the window.",[255,1428,1429,1434],{},[273,1430,1431],{},[188,1432,1433],{},"present_over_time($metric)",[273,1435,1436,1439],{},[188,1437,1438],{},"1"," when the window holds a datapoint.",[255,1441,1442,1447],{},[273,1443,1444],{},[188,1445,1446],{},"absent_over_time($metric)",[273,1448,1449,1451],{},[188,1450,1438],{}," when the window holds no datapoint.",[255,1453,1454,1459],{},[273,1455,1456],{},[188,1457,1458],{},"default_rollup($metric)",[273,1460,1461],{},"The fill Uptrace applies when a query names no rollup. You rarely write it.",[155,1463,1464,1465,784,1467,1469],{},"Use ",[188,1466,542],{},[188,1468,787],{}," to read a PromCounter, which stores a cumulative total:",[193,1471,1473],{"className":374,"code":1472,"language":376,"meta":198,"style":198},"rate($http_requests_total)\nincrease($http_requests_total[1h])\n",[188,1474,1475,1482],{"__ignoreMap":198},[202,1476,1477,1480],{"class":204,"line":205},[202,1478,1479],{"class":395},"rate($http_requests_total",[202,1481,482],{"class":212},[202,1483,1484,1487],{"class":204,"line":216},[202,1485,1486],{"class":395},"increase($http_requests_total[1h]",[202,1488,482],{"class":212},[180,1490,1492],{"id":1491},"transform-functions","Transform functions",[155,1494,1495],{},"Transform functions run on each datapoint of each timeseries. The number of timeseries and the number of datapoints stay the same.",[241,1497,1499],{"id":1498},"rate-units","Rate units",[249,1501,1502,1510],{},[252,1503,1504],{},[255,1505,1506,1508],{},[258,1507,973],{},[258,1509,266],{},[268,1511,1512,1522],{},[255,1513,1514,1519],{},[273,1515,1516],{},[188,1517,1518],{},"perMin($metric)",[273,1520,1521],{},"Divides each value by the number of minutes in the grouping interval.",[255,1523,1524,1529],{},[273,1525,1526],{},[188,1527,1528],{},"perSec($metric)",[273,1530,1531],{},"Divides each value by the number of seconds in the grouping interval.",[155,1533,1534,457,1537,1540,1541,166],{},[188,1535,1536],{},"perMin(sum($cache))",[188,1538,1539],{},"sum($cache) \u002F _minutes"," give the same result — see ",[159,1542,1544],{"href":1543},"#scalars","Scalars",[241,1546,1548],{"id":1547},"rounding-and-sign","Rounding and sign",[249,1550,1551,1559],{},[252,1552,1553],{},[255,1554,1555,1557],{},[258,1556,973],{},[258,1558,266],{},[268,1560,1561,1571,1589,1599,1609,1619,1635,1650],{},[255,1562,1563,1568],{},[273,1564,1565],{},[188,1566,1567],{},"abs($metric)",[273,1569,1570],{},"Absolute value.",[255,1572,1573,1578],{},[273,1574,1575],{},[188,1576,1577],{},"sgn($metric)",[273,1579,1580,340,1583,1585,1586,1588],{},[188,1581,1582],{},"-1",[188,1584,952],{},", or ",[188,1587,1438],{}," for the sign of the value.",[255,1590,1591,1596],{},[273,1592,1593],{},[188,1594,1595],{},"ceil($metric)",[273,1597,1598],{},"Rounds up to an integer.",[255,1600,1601,1606],{},[273,1602,1603],{},[188,1604,1605],{},"floor($metric)",[273,1607,1608],{},"Rounds down to an integer.",[255,1610,1611,1616],{},[273,1612,1613],{},[188,1614,1615],{},"trunc($metric)",[273,1617,1618],{},"Drops the fractional part.",[255,1620,1621,1626],{},[273,1622,1623],{},[188,1624,1625],{},"round($metric[, nearest])",[273,1627,1628,1629,1632,1633,166],{},"Rounds to the nearest multiple of ",[188,1630,1631],{},"nearest",", which defaults to ",[188,1634,1438],{},[255,1636,1637,1642],{},[273,1638,1639],{},[188,1640,1641],{},"clamp_min($metric, min)",[273,1643,1644,1645,1647,1648,166],{},"Raises every value below ",[188,1646,456],{}," to ",[188,1649,456],{},[255,1651,1652,1657],{},[273,1653,1654],{},[188,1655,1656],{},"clamp_max($metric, max)",[273,1658,1659,1660,1647,1662,166],{},"Lowers every value above ",[188,1661,460],{},[188,1663,460],{},[241,1665,1667],{"id":1666},"exponents-and-logarithms","Exponents and logarithms",[249,1669,1670,1678],{},[252,1671,1672],{},[255,1673,1674,1676],{},[258,1675,973],{},[258,1677,266],{},[268,1679,1680,1693,1705,1715,1725,1738,1748],{},[255,1681,1682,1687],{},[273,1683,1684],{},[188,1685,1686],{},"exp($metric)",[273,1688,1689,1692],{},[188,1690,1691],{},"e"," raised to the value.",[255,1694,1695,1700],{},[273,1696,1697],{},[188,1698,1699],{},"exp2($metric)",[273,1701,1702,1692],{},[188,1703,1704],{},"2",[255,1706,1707,1712],{},[273,1708,1709],{},[188,1710,1711],{},"sqrt($metric)",[273,1713,1714],{},"Square root.",[255,1716,1717,1722],{},[273,1718,1719],{},[188,1720,1721],{},"ln($metric)",[273,1723,1724],{},"Natural logarithm.",[255,1726,1727,1732],{},[273,1728,1729],{},[188,1730,1731],{},"log($metric)",[273,1733,1734,1735,166],{},"Natural logarithm, the same as ",[188,1736,1737],{},"ln",[255,1739,1740,1745],{},[273,1741,1742],{},[188,1743,1744],{},"log2($metric)",[273,1746,1747],{},"Base-2 logarithm.",[255,1749,1750,1755],{},[273,1751,1752],{},[188,1753,1754],{},"log10($metric)",[273,1756,1757],{},"Base-10 logarithm.",[241,1759,1761],{"id":1760},"trigonometry","Trigonometry",[155,1763,1764,340,1767,340,1770,340,1773,340,1776,340,1779,340,1782,340,1785,340,1788,340,1791,340,1794,368,1797,1800,1801,1804,1805,1808],{},[188,1765,1766],{},"sin",[188,1768,1769],{},"cos",[188,1771,1772],{},"tan",[188,1774,1775],{},"asin",[188,1777,1778],{},"acos",[188,1780,1781],{},"atan",[188,1783,1784],{},"sinh",[188,1786,1787],{},"cosh",[188,1789,1790],{},"tanh",[188,1792,1793],{},"asinh",[188,1795,1796],{},"acosh",[188,1798,1799],{},"atanh"," each take one argument and return the named function of every value. ",[188,1802,1803],{},"deg"," converts radians to degrees, and ",[188,1806,1807],{},"rad"," converts degrees to radians.",[180,1810,1812],{"id":1811},"timeseries-functions","Timeseries functions",[155,1814,1815],{},"Timeseries functions rewrite the set of series or fill their gaps. They change how many series a query returns, or which datapoints those series hold.",[249,1817,1818,1826],{},[252,1819,1820],{},[255,1821,1822,1824],{},[258,1823,973],{},[258,1825,266],{},[268,1827,1828,1842,1854,1864,1874,1884,1897,1907,1917,1927,1937],{},[255,1829,1830,1835],{},[273,1831,1832],{},[188,1833,1834],{},"topk($metric, n)",[273,1836,1837,1838,1841],{},"Keeps the ",[188,1839,1840],{},"n"," series with the largest values.",[255,1843,1844,1849],{},[273,1845,1846],{},[188,1847,1848],{},"bottomk($metric, n)",[273,1850,1837,1851,1853],{},[188,1852,1840],{}," series with the smallest values.",[255,1855,1856,1861],{},[273,1857,1858],{},[188,1859,1860],{},"sort($metric)",[273,1862,1863],{},"Orders the series by value, smallest first.",[255,1865,1866,1871],{},[273,1867,1868],{},[188,1869,1870],{},"sort_desc($metric)",[273,1872,1873],{},"Orders the series by value, largest first.",[255,1875,1876,1881],{},[273,1877,1878],{},[188,1879,1880],{},"drop_empty_series($metric)",[273,1882,1883],{},"Removes series that hold no datapoints.",[255,1885,1886,1891],{},[273,1887,1888],{},[188,1889,1890],{},"absent($metric)",[273,1892,1893,1894,1896],{},"Returns ",[188,1895,1438],{}," for each timestamp the series holds no datapoint.",[255,1898,1899,1904],{},[273,1900,1901],{},[188,1902,1903],{},"timestamp($metric)",[273,1905,1906],{},"Replaces each value with the timestamp of its datapoint.",[255,1908,1909,1914],{},[273,1910,1911],{},[188,1912,1913],{},"clamp($metric, min, max)",[273,1915,1916],{},"Holds every value inside the range.",[255,1918,1919,1924],{},[273,1920,1921],{},[188,1922,1923],{},"interpolate($metric)",[273,1925,1926],{},"Fills a gap by interpolating between the neighbouring datapoints.",[255,1928,1929,1934],{},[273,1930,1931],{},[188,1932,1933],{},"keep_last_value($metric)",[273,1935,1936],{},"Fills a gap with the last known value.",[255,1938,1939,1944],{},[273,1940,1941],{},[188,1942,1943],{},"keep_next_value($metric)",[273,1945,1946],{},"Fills a gap with the next known value.",[193,1948,1950],{"className":374,"code":1949,"language":376,"meta":198,"style":198},"# The five busiest hosts.\ntopk(sum($requests by (host_name)), 5)\n\n# Fill short gaps instead of drawing them.\nkeep_last_value(avg($temperature))\n",[188,1951,1952,1957,1967,1971,1976],{"__ignoreMap":198},[202,1953,1954],{"class":204,"line":205},[202,1955,1956],{"class":909},"# The five busiest hosts.\n",[202,1958,1959,1962,1964],{"class":204,"line":216},[202,1960,1961],{"class":395},"topk(sum($requests",[202,1963,1230],{"class":222},[202,1965,1966],{"class":212}," (host_name)), 5)\n",[202,1968,1969],{"class":204,"line":226},[202,1970,922],{"emptyLinePlaceholder":10},[202,1972,1973],{"class":204,"line":234},[202,1974,1975],{"class":909},"# Fill short gaps instead of drawing them.\n",[202,1977,1978,1981],{"class":204,"line":930},[202,1979,1980],{"class":395},"keep_last_value(avg($temperature",[202,1982,1983],{"class":212},"))\n",[180,1985,1987],{"id":1986},"operators","Operators",[241,1989,1991],{"id":1990},"arithmetic-and-comparison","Arithmetic and comparison",[155,1993,1994,1995,340,1998,340,2001,340,2004,340,2007,340,2010,2013,2014,340,2017,340,2019,340,2021,340,2023,340,2025,2027,2028,340,2031,340,2034,368,2037,166],{},"Uptrace supports ",[188,1996,1997],{},"+",[188,1999,2000],{},"-",[188,2002,2003],{},"*",[188,2005,2006],{},"\u002F",[188,2008,2009],{},"%",[188,2011,2012],{},"^",", the comparisons ",[188,2015,2016],{},"==",[188,2018,292],{},[188,2020,345],{},[188,2022,348],{},[188,2024,351],{},[188,2026,354],{},", and the set operators ",[188,2029,2030],{},"and",[188,2032,2033],{},"unless",[188,2035,2036],{},"or",[188,2038,2039],{},"union",[155,2041,2042],{},"Precedence runs from highest to lowest:",[753,2044,2045,2049,2057,2063,2077,2083,2089],{},[756,2046,2047],{},[188,2048,2012],{},[756,2050,2051,340,2053,340,2055],{},[188,2052,2003],{},[188,2054,2006],{},[188,2056,2009],{},[756,2058,2059,340,2061],{},[188,2060,1997],{},[188,2062,2000],{},[756,2064,2065,340,2067,340,2069,340,2071,340,2073,340,2075],{},[188,2066,2016],{},[188,2068,292],{},[188,2070,348],{},[188,2072,345],{},[188,2074,354],{},[188,2076,351],{},[756,2078,2079,340,2081],{},[188,2080,2030],{},[188,2082,2033],{},[756,2084,2085,340,2087],{},[188,2086,2036],{},[188,2088,2039],{},[756,2090,2091,340,2094,340,2097],{},[188,2092,2093],{},"if",[188,2095,2096],{},"ifnot",[188,2098,2099],{},"default",[155,2101,2102,2103,2106,2107,2110,2111,2113,2114,2117,2118,166],{},"Operators on one level are left-associative, so ",[188,2104,2105],{},"2 * 3 % 2"," is the same as ",[188,2108,2109],{},"(2 * 3) % 2",". The exception is ",[188,2112,2012],{},", which is right-associative: ",[188,2115,2116],{},"2 ^ 3 ^ 2"," is ",[188,2119,2120],{},"2 ^ (3 ^ 2)",[155,2122,2123,2125,2126,2128],{},[188,2124,2036],{}," keeps a right-side series only where the left side has none with the same attributes. ",[188,2127,2039],{}," concatenates both sides without matching attributes at all.",[241,2130,2132],{"id":2131},"conditional-operators","Conditional operators",[249,2134,2135,2143],{},[252,2136,2137],{},[255,2138,2139,2141],{},[258,2140,260],{},[258,2142,266],{},[268,2144,2145,2159,2171],{},[255,2146,2147,2152],{},[273,2148,2149],{},[188,2150,2151],{},"expr if cond",[273,2153,2154,2155,2158],{},"Keeps a value only where ",[188,2156,2157],{},"cond"," has a value.",[255,2160,2161,2166],{},[273,2162,2163],{},[188,2164,2165],{},"expr ifnot cond",[273,2167,2154,2168,2170],{},[188,2169,2157],{}," has none.",[255,2172,2173,2178],{},[273,2174,2175],{},[188,2176,2177],{},"expr default val",[273,2179,2180,2181,166],{},"Replaces an absent value with ",[188,2182,2183],{},"val",[155,2185,2186],{},"Calculate a hit rate only when the sample is large enough, and fill the rest with zero:",[193,2188,2192],{"className":2189,"code":2190,"language":2191,"meta":198,"style":198},"language-mql shiki shiki-themes github-light","(sum($misses) \u002F (sum($hits) + sum($misses))\n  if (sum($hits) + sum($misses) >= 100)) default 0\n","mql",[188,2193,2194,2199],{"__ignoreMap":198},[202,2195,2196],{"class":204,"line":205},[202,2197,2198],{},"(sum($misses) \u002F (sum($hits) + sum($misses))\n",[202,2200,2201],{"class":204,"line":216},[202,2202,2203],{},"  if (sum($hits) + sum($misses) >= 100)) default 0\n",[168,2205,2207],{"type":2206},"warning",[155,2208,412,2209,2212,2213,2216,2217,340,2219,368,2221,2223],{},[188,2210,2211],{},"if(cond, then, else)"," ",[759,2214,2215],{},"function"," is deprecated. Use the ",[188,2218,2093],{},[188,2220,2096],{},[188,2222,2099],{}," operators instead.",[180,2225,2227],{"id":2226},"grouping","Grouping and joining",[155,2229,2230],{},"Group at the function level, at the expression level, or for the whole query:",[193,2232,2234],{"className":374,"code":2233,"language":376,"meta":198,"style":198},"# Function level.\nsum($metric) by (host_name, service_name)\navg(sum($metric) by (cpu, mode)) by (cpu)\n\n# Expression level.\nsum($metric1) by (type) \u002F sum($metric2) group by host_name\n\n# Query level, affecting every expression.\n$metric1 | $metric2 | group by host_name\n",[188,2235,2236,2241,2256,2277,2281,2286,2300,2304,2309],{"__ignoreMap":198},[202,2237,2238],{"class":204,"line":205},[202,2239,2240],{"class":909},"# Function level.\n",[202,2242,2243,2246,2249,2252,2254],{"class":204,"line":216},[202,2244,2245],{"class":395},"sum($metric",[202,2247,2248],{"class":212},") by (",[202,2250,2251],{"class":395},"host_name,",[202,2253,1207],{"class":222},[202,2255,482],{"class":212},[202,2257,2258,2261,2263,2266,2269,2272,2275],{"class":204,"line":226},[202,2259,2260],{"class":395},"avg(sum($metric",[202,2262,2248],{"class":212},[202,2264,2265],{"class":395},"cpu,",[202,2267,2268],{"class":222}," mode",[202,2270,2271],{"class":212},")) by (",[202,2273,2274],{"class":395},"cpu",[202,2276,482],{"class":212},[202,2278,2279],{"class":204,"line":234},[202,2280,922],{"emptyLinePlaceholder":10},[202,2282,2283],{"class":204,"line":930},[202,2284,2285],{"class":909},"# Expression level.\n",[202,2287,2288,2291,2293,2297],{"class":204,"line":1213},[202,2289,2290],{"class":395},"sum($metric1",[202,2292,2248],{"class":212},[202,2294,2296],{"class":2295},"sYu0t","type",[202,2298,2299],{"class":212},") \u002F sum($metric2) group by host_name\n",[202,2301,2302],{"class":204,"line":1218},[202,2303,922],{"emptyLinePlaceholder":10},[202,2305,2306],{"class":204,"line":1224},[202,2307,2308],{"class":909},"# Query level, affecting every expression.\n",[202,2310,2312,2315,2317,2320,2322,2325,2327],{"class":204,"line":2311},9,[202,2313,2314],{"class":212},"$metric1 ",[202,2316,387],{"class":386},[202,2318,2319],{"class":212}," $metric2 ",[202,2321,387],{"class":386},[202,2323,2324],{"class":395}," group",[202,2326,1230],{"class":222},[202,2328,2329],{"class":222}," host_name\n",[155,2331,2332],{},"Math between series joins them by their matching attributes, and one-to-many and many-to-one joins work without extra syntax:",[193,2334,2336],{"className":374,"code":2335,"language":376,"meta":198,"style":198},"# One-to-one.\n$mem_free + $mem_cached group by host_name\n\n# One-to-many.\n$cpu_secs by (mode) \u002F $cpu_secs by (service_name, mode)\n",[188,2337,2338,2343,2348,2352,2357],{"__ignoreMap":198},[202,2339,2340],{"class":204,"line":205},[202,2341,2342],{"class":909},"# One-to-one.\n",[202,2344,2345],{"class":204,"line":216},[202,2346,2347],{"class":212},"$mem_free + $mem_cached group by host_name\n",[202,2349,2350],{"class":204,"line":226},[202,2351,922],{"emptyLinePlaceholder":10},[202,2353,2354],{"class":204,"line":234},[202,2355,2356],{"class":909},"# One-to-many.\n",[202,2358,2359,2362,2365,2368,2371,2373],{"class":204,"line":930},[202,2360,2361],{"class":212},"$cpu_secs by (",[202,2363,2364],{"class":395},"mode",[202,2366,2367],{"class":212},") \u002F $cpu_secs by (",[202,2369,2370],{"class":395},"service_name,",[202,2372,2268],{"class":222},[202,2374,482],{"class":212},[155,2376,2377],{},"When the attribute names differ, rename one side:",[193,2379,2381],{"className":374,"code":2380,"language":376,"meta":198,"style":198},"$metric1 by (hostname as host) + $metric2 by (host_name as host)\n",[188,2382,2383],{"__ignoreMap":198},[202,2384,2385,2388,2391,2394,2397,2400,2403,2405,2407],{"class":204,"line":205},[202,2386,2387],{"class":212},"$metric1 by (",[202,2389,2390],{"class":395},"hostname",[202,2392,2393],{"class":222}," as",[202,2395,2396],{"class":222}," host",[202,2398,2399],{"class":212},") + $metric2 by (",[202,2401,2402],{"class":395},"host_name",[202,2404,2393],{"class":222},[202,2406,2396],{"class":222},[202,2408,482],{"class":212},[241,2410,2412],{"id":2411},"attribute-functions","Attribute functions",[155,2414,2415],{},"These functions run on attribute values and are valid only in a grouping expression:",[249,2417,2418,2426],{},[252,2419,2420],{},[255,2421,2422,2424],{},[258,2423,973],{},[258,2425,266],{},[268,2427,2428,2438,2448,2458,2468,2478,2488],{},[255,2429,2430,2435],{},[273,2431,2432],{},[188,2433,2434],{},"lower(attr)",[273,2436,2437],{},"Converts the value to lowercase.",[255,2439,2440,2445],{},[273,2441,2442],{},[188,2443,2444],{},"upper(attr)",[273,2446,2447],{},"Converts the value to uppercase.",[255,2449,2450,2455],{},[273,2451,2452],{},[188,2453,2454],{},"trimPrefix(attr, \"prefix\")",[273,2456,2457],{},"Removes the leading prefix.",[255,2459,2460,2465],{},[273,2461,2462],{},[188,2463,2464],{},"trimSuffix(attr, \"suffix\")",[273,2466,2467],{},"Removes the trailing suffix.",[255,2469,2470,2475],{},[273,2471,2472],{},[188,2473,2474],{},"extract(attr, pattern)",[273,2476,2477],{},"Extracts the part of the value the regexp captures.",[255,2479,2480,2485],{},[273,2481,2482],{},[188,2483,2484],{},"replace(attr, substring, replacement)",[273,2486,2487],{},"Replaces every occurrence of the substring.",[255,2489,2490,2495],{},[273,2491,2492],{},[188,2493,2494],{},"replaceRegexp(attr, pattern, replacement)",[273,2496,2497],{},"Replaces every part that matches the regexp.",[193,2499,2501],{"className":374,"code":2500,"language":376,"meta":198,"style":198},"group by lower(service_name) as service\ngroup by extract(host_name, `^uptrace-prod-(\\w+)$`) as host\ngroup by replace(host_name, 'uptrace-prod-', '') as host\n",[188,2502,2503,2527,2556],{"__ignoreMap":198},[202,2504,2505,2508,2510,2513,2516,2519,2521,2524],{"class":204,"line":205},[202,2506,2507],{"class":395},"group",[202,2509,1230],{"class":222},[202,2511,2512],{"class":222}," lower",[202,2514,2515],{"class":212},"(",[202,2517,2518],{"class":395},"service_name",[202,2520,474],{"class":212},[202,2522,2523],{"class":222},"as",[202,2525,2526],{"class":222}," service\n",[202,2528,2529,2531,2533,2536,2538,2540,2543,2546,2549,2551,2553],{"class":204,"line":216},[202,2530,2507],{"class":395},[202,2532,1230],{"class":222},[202,2534,2535],{"class":222}," extract",[202,2537,2515],{"class":212},[202,2539,2251],{"class":395},[202,2541,2542],{"class":222}," `",[202,2544,2545],{"class":395},"^uptrace-prod-(\\w+",[202,2547,2548],{"class":222},")$`",[202,2550,474],{"class":212},[202,2552,2523],{"class":222},[202,2554,2555],{"class":222}," host\n",[202,2557,2558,2560,2562,2565,2567,2569,2572,2575,2577,2579],{"class":204,"line":226},[202,2559,2507],{"class":395},[202,2561,1230],{"class":222},[202,2563,2564],{"class":222}," replace",[202,2566,2515],{"class":212},[202,2568,2251],{"class":395},[202,2570,2571],{"class":222}," 'uptrace-prod-',",[202,2573,2574],{"class":222}," ''",[202,2576,474],{"class":212},[202,2578,2523],{"class":222},[202,2580,2555],{"class":222},[180,2582,2584],{"id":2583},"expression-aliases","Expression aliases",[155,2586,2587,2588,2590],{},"Name an expression with ",[188,2589,2523],{},", then reference the name in a later expression of the same query:",[193,2592,2594],{"className":195,"code":2593,"language":197,"meta":198,"style":198},"metrics:\n  - service_cache_redis as $redis\nquery:\n  - $redis{type=\"hits\"} as hits\n  - $redis{type=\"misses\"} as misses\n  - hits \u002F (hits + misses) as hit_rate\n",[188,2595,2596,2602,2609,2615,2622,2629],{"__ignoreMap":198},[202,2597,2598,2600],{"class":204,"line":205},[202,2599,209],{"class":208},[202,2601,213],{"class":212},[202,2603,2604,2606],{"class":204,"line":216},[202,2605,219],{"class":212},[202,2607,2608],{"class":222},"service_cache_redis as $redis\n",[202,2610,2611,2613],{"class":204,"line":226},[202,2612,229],{"class":208},[202,2614,213],{"class":212},[202,2616,2617,2619],{"class":204,"line":234},[202,2618,219],{"class":212},[202,2620,2621],{"class":222},"$redis{type=\"hits\"} as hits\n",[202,2623,2624,2626],{"class":204,"line":930},[202,2625,219],{"class":212},[202,2627,2628],{"class":222},"$redis{type=\"misses\"} as misses\n",[202,2630,2631,2633],{"class":204,"line":1213},[202,2632,219],{"class":212},[202,2634,2635],{"class":222},"hits \u002F (hits + misses) as hit_rate\n",[155,2637,2638],{},"An alias that starts with an underscore takes part in the calculation but does not appear in the result, which keeps helper expressions off the chart:",[193,2640,2642],{"className":374,"code":2641,"language":376,"meta":198,"style":198},"sum($cache{type=\"hits\"}) as _hits\nsum($cache{type=\"misses\"}) as _misses\n_misses \u002F (_hits + _misses) as miss_rate\n",[188,2643,2644,2665,2683],{"__ignoreMap":198},[202,2645,2646,2649,2652,2654,2656,2659,2662],{"class":204,"line":205},[202,2647,2648],{"class":395},"sum($cache",[202,2650,2651],{"class":222},"{",[202,2653,2296],{"class":2295},[202,2655,277],{"class":222},[202,2657,2658],{"class":395},"\"hits\"",[202,2660,2661],{"class":395},"}",[202,2663,2664],{"class":212},") as _hits\n",[202,2666,2667,2669,2671,2673,2675,2678,2680],{"class":204,"line":216},[202,2668,2648],{"class":395},[202,2670,2651],{"class":222},[202,2672,2296],{"class":2295},[202,2674,277],{"class":222},[202,2676,2677],{"class":395},"\"misses\"",[202,2679,2661],{"class":395},[202,2681,2682],{"class":212},") as _misses\n",[202,2684,2685,2688,2691,2694,2696,2699],{"class":204,"line":226},[202,2686,2687],{"class":395},"_misses",[202,2689,2690],{"class":222}," \u002F",[202,2692,2693],{"class":212}," (_hits ",[202,2695,1997],{"class":222},[202,2697,2698],{"class":222}," _misses",[202,2700,2701],{"class":212},") as miss_rate\n",[180,2703,1544],{"id":2704},"scalars",[249,2706,2707,2717],{},[252,2708,2709],{},[255,2710,2711,2714],{},[258,2712,2713],{},"Scalar",[258,2715,2716],{},"Value",[268,2718,2719,2729,2739],{},[255,2720,2721,2726],{},[273,2722,2723],{},[188,2724,2725],{},"_seconds",[273,2727,2728],{},"Number of seconds in the grouping interval.",[255,2730,2731,2736],{},[273,2732,2733],{},[188,2734,2735],{},"_minutes",[273,2737,2738],{},"Number of minutes in the grouping interval.",[255,2740,2741,2746],{},[273,2742,2743],{},[188,2744,2745],{},"nan",[273,2747,2748],{},"Not-a-number literal.",[180,2750,2752],{"id":2751},"see-also","See also",[753,2754,2755,2759,2763,2768],{},[756,2756,2757],{},[159,2758,161],{"href":50},[756,2760,2761],{},[159,2762,165],{"href":54},[756,2764,2765],{},[159,2766,2767],{"href":93},"Dashboard YAML templates",[756,2769,2770],{},[159,2771,2773],{"href":2772},"\u002Fopentelemetry\u002Fmetrics","OpenTelemetry Metrics",[2775,2776,2777],"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}html pre.shiki code .sYu0t, html code.shiki .sYu0t{--shiki-default:#005CC5}",{"title":198,"searchDepth":234,"depth":216,"links":2779},[2780,2787,2792,2795,2796,2802,2803,2807,2810,2811,2812],{"id":182,"depth":216,"text":183,"children":2781},[2782,2783,2784,2785,2786],{"id":243,"depth":226,"text":244},{"id":408,"depth":226,"text":409},{"id":446,"depth":226,"text":447},{"id":485,"depth":226,"text":486},{"id":509,"depth":226,"text":510},{"id":553,"depth":216,"text":554,"children":2788},[2789,2790,2791],{"id":826,"depth":226,"text":827},{"id":870,"depth":226,"text":871},{"id":942,"depth":226,"text":943},{"id":956,"depth":216,"text":957,"children":2793},[2794],{"id":1164,"depth":226,"text":1165},{"id":1236,"depth":216,"text":1237},{"id":1491,"depth":216,"text":1492,"children":2797},[2798,2799,2800,2801],{"id":1498,"depth":226,"text":1499},{"id":1547,"depth":226,"text":1548},{"id":1666,"depth":226,"text":1667},{"id":1760,"depth":226,"text":1761},{"id":1811,"depth":216,"text":1812},{"id":1986,"depth":216,"text":1987,"children":2804},[2805,2806],{"id":1990,"depth":226,"text":1991},{"id":2131,"depth":226,"text":2132},{"id":2226,"depth":216,"text":2227,"children":2808},[2809],{"id":2411,"depth":226,"text":2412},{"id":2583,"depth":216,"text":2584},{"id":2704,"depth":216,"text":1544},{"id":2751,"depth":216,"text":2752},"Complete reference for the Uptrace metrics query language: selectors, the instrument and aggregation matrix, and every aggregate, rollup, transform, and timeseries function.","md",{"readingTime":2816},{"text":2817,"minutes":2818,"time":2819,"words":2820},"8 min read",7.885,473100,1577,{"title":29},{"title":149,"description":2813},"S1CHkkRJ_52JD7JjPl2_yAGldDw19K-l0RWdoZINXQA",[2825,2827],{"title":53,"path":54,"stem":55,"description":2826,"children":-1},"See how Uptrace extends PromQL, which functions are supported, and how to adapt Prometheus queries or Grafana dashboards.",{"title":15,"path":61,"stem":62,"description":2828,"children":-1},"Configure threshold, anomaly, outlier, forecast, error, and SLO monitors. Group related alerts into incidents and route notifications.",1791361940049]