[{"data":1,"prerenderedAt":2483},["ShallowReactive",2],{"\u002Ffeatures\u002Fmetrics\u002Fquerying-navigation":3,"\u002Ffeatures\u002Fmetrics\u002Fquerying":116,"querying-metrics":1250},[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":1245},{"id":118,"title":119,"body":120,"description":1233,"extension":1234,"image":1235,"meta":1236,"navigation":1242,"path":46,"seo":1243,"stem":47,"surround_disabled":115,"__hash__":1244},"features\u002Ffeatures\u002F03.metrics\u002F02.querying.md","Querying Metrics",{"type":121,"value":122,"toc":1216},"minimark",[123,137,140,148,153,156,159,214,217,224,228,231,262,265,283,286,311,314,360,364,367,411,415,419,426,523,527,535,548,554,578,581,584,595,599,649,656,659,662,673,677,721,724,727,735,739,853,856,872,929,933,937,940,966,973,1012,1015,1113,1117,1120,1179,1190,1194,1212],[124,125,127],"alert",{"type":126},"info",[128,129,130,131,136],"p",{},"To learn about metrics, see ",[132,133,135],"a",{"href":134},"\u002Fopentelemetry\u002Fmetrics","OpenTelemetry Metrics"," documentation.",[128,138,139],{},"Uptrace provides a powerful query language that supports joining, grouping, and aggregating multiple metrics in a single query. The Uptrace query language is backwards compatible with Prometheus (PromQL), so you can use your existing PromQL queries with Uptrace.",[128,141,142,143,147],{},"If you're already familiar with PromQL, read ",[132,144,146],{"href":145},"promql-compat","PromQL compatibility"," guide to learn more.",[149,150,152],"h2",{"id":151},"dashboards","Writing queries",[128,154,155],{},"Uptrace allows you to create dashboards using UI or YAML configuration files. This documentation uses the more compact YAML format, but you can achieve the same with the UI.",[128,157,158],{},"YAML:",[160,161,166],"pre",{"className":162,"code":163,"language":164,"meta":165,"style":165},"language-yaml shiki shiki-themes github-light","metrics:\n  - postgresql_commits as $commits\n\nquery:\n  - sum($commits)\n","yaml","",[167,168,169,182,192,198,206],"code",{"__ignoreMap":165},[170,171,174,178],"span",{"class":172,"line":173},"line",1,[170,175,177],{"class":176},"shJU0","metrics",[170,179,181],{"class":180},"sgsFI",":\n",[170,183,185,188],{"class":172,"line":184},2,[170,186,187],{"class":180},"  - ",[170,189,191],{"class":190},"sYBdl","postgresql_commits as $commits\n",[170,193,195],{"class":172,"line":194},3,[170,196,197],{"emptyLinePlaceholder":10},"\n",[170,199,201,204],{"class":172,"line":200},4,[170,202,203],{"class":176},"query",[170,205,181],{"class":180},[170,207,209,211],{"class":172,"line":208},5,[170,210,187],{"class":180},[170,212,213],{"class":190},"sum($commits)\n",[128,215,216],{},"UI:",[128,218,219],{},[220,221],"img",{"alt":222,"src":223},"Grid item form","\u002Ffeatures\u002Fquerying-metrics\u002Fgrid-item-form.png",[149,225,227],{"id":226},"aliases","Aliases",[128,229,230],{},"Because metric names can be quite long, Uptrace requires you to provide a short metric alias that must start with the dollar sign:",[160,232,234],{"className":162,"code":233,"language":164,"meta":165,"style":165},"metrics:\n  # metric aliases always start with the dollar sign\n  - system_filesystem_usage as $fs_usage\n  - system_network_packets as $packets\n",[167,235,236,242,248,255],{"__ignoreMap":165},[170,237,238,240],{"class":172,"line":173},[170,239,177],{"class":176},[170,241,181],{"class":180},[170,243,244],{"class":172,"line":184},[170,245,247],{"class":246},"sAwPA","  # metric aliases always start with the dollar sign\n",[170,249,250,252],{"class":172,"line":194},[170,251,187],{"class":180},[170,253,254],{"class":190},"system_filesystem_usage as $fs_usage\n",[170,256,257,259],{"class":172,"line":200},[170,258,187],{"class":180},[170,260,261],{"class":190},"system_network_packets as $packets\n",[128,263,264],{},"You must then use the alias instead of the metric name when writing queries:",[160,266,268],{"className":162,"code":267,"language":164,"meta":165,"style":165},"query:\n  - sum($fs_usage)\n",[167,269,270,276],{"__ignoreMap":165},[170,271,272,274],{"class":172,"line":173},[170,273,203],{"class":176},[170,275,181],{"class":180},[170,277,278,280],{"class":172,"line":184},[170,279,187],{"class":180},[170,281,282],{"class":190},"sum($fs_usage)\n",[128,284,285],{},"Uptrace also allows to specify an alias for expressions:",[160,287,289],{"className":162,"code":288,"language":164,"meta":165,"style":165},"query:\n  - $fs_usage{state=\"used\"} as used_space\n  - $fs_usage{host_name='host1', device='\u002Fdev\u002Fsdd1'} as host1_sdd1\n",[167,290,291,297,304],{"__ignoreMap":165},[170,292,293,295],{"class":172,"line":173},[170,294,203],{"class":176},[170,296,181],{"class":180},[170,298,299,301],{"class":172,"line":184},[170,300,187],{"class":180},[170,302,303],{"class":190},"$fs_usage{state=\"used\"} as used_space\n",[170,305,306,308],{"class":172,"line":194},[170,307,187],{"class":180},[170,309,310],{"class":190},"$fs_usage{host_name='host1', device='\u002Fdev\u002Fsdd1'} as host1_sdd1\n",[128,312,313],{},"You can then reference the expression using the alias:",[160,315,317],{"className":162,"code":316,"language":164,"meta":165,"style":165},"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",[167,318,319,325,332,338,345,352],{"__ignoreMap":165},[170,320,321,323],{"class":172,"line":173},[170,322,177],{"class":176},[170,324,181],{"class":180},[170,326,327,329],{"class":172,"line":184},[170,328,187],{"class":180},[170,330,331],{"class":190},"service_cache_redis as $redis\n",[170,333,334,336],{"class":172,"line":194},[170,335,203],{"class":176},[170,337,181],{"class":180},[170,339,340,342],{"class":172,"line":200},[170,341,187],{"class":180},[170,343,344],{"class":190},"$redis{type=\"hits\"} as hits\n",[170,346,347,349],{"class":172,"line":208},[170,348,187],{"class":180},[170,350,351],{"class":190},"$redis{type=\"misses\"} as misses\n",[170,353,355,357],{"class":172,"line":354},6,[170,356,187],{"class":180},[170,358,359],{"class":190},"hits \u002F (hits + misses) as hit_rate\n",[149,361,363],{"id":362},"grouping","Grouping",[128,365,366],{},"Uptrace allows to customize grouping on a function level:",[160,368,372],{"className":369,"code":370,"language":371,"meta":165,"style":165},"language-shell shiki shiki-themes github-light","sum($metric) by (attr1, attr2)\navg(sum($metric) by (attr1, attr2)) by (attr1)\n","shell",[167,373,374,392],{"__ignoreMap":165},[170,375,376,380,383,386,389],{"class":172,"line":173},[170,377,379],{"class":378},"s7eDp","sum($metric",[170,381,382],{"class":180},") by (",[170,384,385],{"class":378},"attr1,",[170,387,388],{"class":190}," attr2",[170,390,391],{"class":180},")\n",[170,393,394,397,399,401,403,406,409],{"class":172,"line":184},[170,395,396],{"class":378},"avg(sum($metric",[170,398,382],{"class":180},[170,400,385],{"class":378},[170,402,388],{"class":190},[170,404,405],{"class":180},")) by (",[170,407,408],{"class":378},"attr1",[170,410,391],{"class":180},[412,413],"partial",{"path":414},"querying-metrics",[149,416,418],{"id":417},"instruments","Instruments",[128,420,421,422,425],{},"OpenTelemetry offers various ",[132,423,417],{"href":424},"\u002Fopentelemetry\u002Fmetrics#instruments",", each with its own set of aggregate functions:",[427,428,429,442],"table",{},[430,431,432],"thead",{},[433,434,435,439],"tr",{},[436,437,438],"th",{},"Instrument Name",[436,440,441],{},"Timeseries kind",[443,444,445,464,482,496,509],"tbody",{},[433,446,447,459],{},[448,449,450,454,455],"td",{},[132,451,453],{"href":452},"\u002Fopentelemetry\u002Fmetrics#counter","Counter",", ",[132,456,458],{"href":457},"\u002Fopentelemetry\u002Fmetrics#counterobserver","CounterObserver",[448,460,461],{},[132,462,453],{"href":463},"#counter",[433,465,466,476],{},[448,467,468,454,472],{},[132,469,471],{"href":470},"\u002Fopentelemetry\u002Fmetrics#updowncounter","UpDownCounter",[132,473,475],{"href":474},"\u002Fopentelemetry\u002Fmetrics#updowncounterobserver","UpDownCounterObserver",[448,477,478],{},[132,479,481],{"href":480},"#additive","Additive",[433,483,484,490],{},[448,485,486],{},[132,487,489],{"href":488},"\u002Fopentelemetry\u002Fmetrics#gaugeobserver","GaugeObserver",[448,491,492],{},[132,493,495],{"href":494},"#gauge","Gauge",[433,497,498,504],{},[448,499,500],{},[132,501,503],{"href":502},"\u002Fopentelemetry\u002Fmetrics#histogram","Histogram",[448,505,506],{},[132,507,503],{"href":508},"#histogram",[433,510,511,517],{},[448,512,513],{},[132,514,516],{"href":515},"\u002Fingest\u002Fcloudwatch#metrics","AWS CloudWatch",[448,518,519],{},[132,520,522],{"href":521},"#summary","Summary",[524,525,453],"h3",{"id":526},"counter",[128,528,529,530,534],{},"Counter is a timeseries kind that measures additive non-decreasing values, for example, the ",[531,532,533],"strong",{},"total"," number of:",[536,537,538,542,545],"ul",{},[539,540,541],"li",{},"processed requests",[539,543,544],{},"received bytes",[539,546,547],{},"disk reads",[128,549,550,551,553],{},"Uptrace supports the following functions to aggregate ",[167,552,526],{}," timeseries:",[427,555,556,566],{},[430,557,558],{},[433,559,560,563],{},[436,561,562],{},"Expression",[436,564,565],{},"Result timeseries",[443,567,568],{},[433,569,570,575],{},[448,571,572],{},[167,573,574],{},"sum($metric)",[448,576,577],{},"Sum of timeseries",[524,579,495],{"id":580},"gauge",[128,582,583],{},"Gauge is a timeseries kind that measures non-additive values for which sum does not produce a meaningful correct result, for example:",[536,585,586,589,592],{},[539,587,588],{},"error rate",[539,590,591],{},"memory utilization",[539,593,594],{},"cache hit rate",[128,596,550,597,553],{},[167,598,580],{},[427,600,601,609],{},[430,602,603],{},[433,604,605,607],{},[436,606,562],{},[436,608,565],{},[443,610,611,621,631,641],{},[433,612,613,618],{},[448,614,615],{},[167,616,617],{},"avg($metric)",[448,619,620],{},"Avg of timeseries",[433,622,623,628],{},[448,624,625],{},[167,626,627],{},"min($metric)",[448,629,630],{},"Min of timeseries",[433,632,633,638],{},[448,634,635],{},[167,636,637],{},"max($metric)",[448,639,640],{},"Max of timeseries",[433,642,643,647],{},[448,644,645],{},[167,646,574],{},[448,648,577],{},[128,650,651,652,655],{},"* Note that the ",[167,653,654],{},"sum"," functions should not be normally used with this instrument and was added only for compatibility with Prometheus and AWS metrics.",[524,657,481],{"id":658},"additive",[128,660,661],{},"Additive is a timeseries kind which measures additive values that increase or decrease with time, for example, the number of:",[536,663,664,667,670],{},[539,665,666],{},"active requests",[539,668,669],{},"open connections",[539,671,672],{},"memory in use (megabytes)",[128,674,550,675,553],{},[167,676,658],{},[427,678,679,687],{},[430,680,681],{},[433,682,683,685],{},[436,684,562],{},[436,686,565],{},[443,688,689,697,705,713],{},[433,690,691,695],{},[448,692,693],{},[167,694,574],{},[448,696,577],{},[433,698,699,703],{},[448,700,701],{},[167,702,617],{},[448,704,620],{},[433,706,707,711],{},[448,708,709],{},[167,710,627],{},[448,712,630],{},[433,714,715,719],{},[448,716,717],{},[167,718,637],{},[448,720,640],{},[524,722,503],{"id":723},"histogram",[128,725,726],{},"Histogram is a timeseries kind that contains a histogram from recorded values, for example:",[536,728,729,732],{},[539,730,731],{},"request latency",[539,733,734],{},"request size",[128,736,550,737,553],{},[167,738,723],{},[427,740,741,749],{},[430,742,743],{},[433,744,745,747],{},[436,746,562],{},[436,748,565],{},[443,750,751,761,771,781,791,801,811,824,835,844],{},[433,752,753,758],{},[448,754,755],{},[167,756,757],{},"histogram_count($metric)",[448,759,760],{},"Number of observed values in timeseries",[433,762,763,768],{},[448,764,765],{},[167,766,767],{},"p50($metric)",[448,769,770],{},"P50 of timeseries",[433,772,773,778],{},[448,774,775],{},[167,776,777],{},"p75($metric)",[448,779,780],{},"P75 of timeseries",[433,782,783,788],{},[448,784,785],{},[167,786,787],{},"p90($metric)",[448,789,790],{},"P90 of timeseries",[433,792,793,798],{},[448,794,795],{},[167,796,797],{},"p95($metric)",[448,799,800],{},"P95 of timeseries",[433,802,803,808],{},[448,804,805],{},[167,806,807],{},"p99($metric)",[448,809,810],{},"P99 of timeseries",[433,812,813,818],{},[448,814,815],{},[167,816,817],{},"histogram_quantile(0.5, $metric)",[448,819,820,821,823],{},"Same as ",[167,822,767],{}," (PromQL-compatible)",[433,825,826,830],{},[448,827,828],{},[167,829,617],{},[448,831,832],{},[167,833,834],{},"sum($metric) \u002F histogram_count($metric)",[433,836,837,841],{},[448,838,839],{},[167,840,627],{},[448,842,843],{},"Min observed value in the histogram",[433,845,846,850],{},[448,847,848],{},[167,849,637],{},[448,851,852],{},"Max observed value in the histogram",[524,854,522],{"id":855},"summary",[128,857,858,859,454,862,454,865,867,868,871],{},"Sum is a timeseries kind that exists for compatibility with Prometheus and AWS Cloud Watch. It stores the ",[167,860,861],{},"min",[167,863,864],{},"max",[167,866,654],{},", and ",[167,869,870],{},"count"," aggregates of observed values.",[427,873,874,882],{},[430,875,876],{},[433,877,878,880],{},[436,879,562],{},[436,881,565],{},[443,883,884,892,900,911,920],{},[433,885,886,890],{},[448,887,888],{},[167,889,574],{},[448,891,577],{},[433,893,894,898],{},[448,895,896],{},[167,897,757],{},[448,899,760],{},[433,901,902,906],{},[448,903,904],{},[167,905,617],{},[448,907,908],{},[167,909,910],{},"sum($metric) \u002F count($metric)",[433,912,913,917],{},[448,914,915],{},[167,916,627],{},[448,918,919],{},"Min observed value",[433,921,922,926],{},[448,923,924],{},[167,925,637],{},[448,927,928],{},"Max observed value",[149,930,932],{"id":931},"misc","Misc",[524,934,936],{"id":935},"what-are-timeseries","What are timeseries?",[128,938,939],{},"A timeseries is a metric with an unique set of attributes, for example, each host has a separate timeseries for the same metric name:",[160,941,943],{"className":162,"code":942,"language":164,"meta":165,"style":165},"# metric_name{ attr1, attr2... }\nsystem_filesystem_usage{host_name='host1'} # timeseries 1\nsystem_filesystem_usage{host_name='host2'} # timeseries 2\n",[167,944,945,950,958],{"__ignoreMap":165},[170,946,947],{"class":172,"line":173},[170,948,949],{"class":246},"# metric_name{ attr1, attr2... }\n",[170,951,952,955],{"class":172,"line":184},[170,953,954],{"class":190},"system_filesystem_usage{host_name='host1'}",[170,956,957],{"class":246}," # timeseries 1\n",[170,959,960,963],{"class":172,"line":194},[170,961,962],{"class":190},"system_filesystem_usage{host_name='host2'}",[170,964,965],{"class":246}," # timeseries 2\n",[128,967,968,969,972],{},"You can add more attributes to create more detailed and rich timeseries, for example, you can use ",[167,970,971],{},"state"," attribute to report the number of free and used bytes in a filesystem:",[160,974,976],{"className":162,"code":975,"language":164,"meta":165,"style":165},"system_filesystem_usage{host_name='host1', state='free'} # timeseries 1\nsystem_filesystem_usage{host_name='host1', state='used'} # timeseries 2\n\nsystem_filesystem_usage{host_name='host2', state='free'} # timeseries 3\nsystem_filesystem_usage{host_name='host2', state='used'} # timeseries 4\n",[167,977,978,985,992,996,1004],{"__ignoreMap":165},[170,979,980,983],{"class":172,"line":173},[170,981,982],{"class":190},"system_filesystem_usage{host_name='host1', state='free'}",[170,984,957],{"class":246},[170,986,987,990],{"class":172,"line":184},[170,988,989],{"class":190},"system_filesystem_usage{host_name='host1', state='used'}",[170,991,965],{"class":246},[170,993,994],{"class":172,"line":194},[170,995,197],{"emptyLinePlaceholder":10},[170,997,998,1001],{"class":172,"line":200},[170,999,1000],{"class":190},"system_filesystem_usage{host_name='host2', state='free'}",[170,1002,1003],{"class":246}," # timeseries 3\n",[170,1005,1006,1009],{"class":172,"line":208},[170,1007,1008],{"class":190},"system_filesystem_usage{host_name='host2', state='used'}",[170,1010,1011],{"class":246}," # timeseries 4\n",[128,1013,1014],{},"With just 2 attributes, you can write a number of useful queries:",[160,1016,1018],{"className":162,"code":1017,"language":164,"meta":165,"style":165},"# the filesystem size (free+used bytes) on each host\nquery:\n  - sum($fs_usage) group by host_name\n\n# the number of free bytes on each host\nquery:\n  - sum($fs_usage{state='free'}) as free group by host_name\n\n# fs utilization on each host\nquery:\n  - sum($fs_usage{state='used'}) \u002F sum($fs_usage) as fs_util group by host_name\n\n# the size of your dataset on all hosts\nquery:\n  - sum($fs_usage{state='used'}) as dataset_size\n",[167,1019,1020,1025,1031,1038,1042,1047,1053,1061,1066,1072,1079,1087,1092,1098,1105],{"__ignoreMap":165},[170,1021,1022],{"class":172,"line":173},[170,1023,1024],{"class":246},"# the filesystem size (free+used bytes) on each host\n",[170,1026,1027,1029],{"class":172,"line":184},[170,1028,203],{"class":176},[170,1030,181],{"class":180},[170,1032,1033,1035],{"class":172,"line":194},[170,1034,187],{"class":180},[170,1036,1037],{"class":190},"sum($fs_usage) group by host_name\n",[170,1039,1040],{"class":172,"line":200},[170,1041,197],{"emptyLinePlaceholder":10},[170,1043,1044],{"class":172,"line":208},[170,1045,1046],{"class":246},"# the number of free bytes on each host\n",[170,1048,1049,1051],{"class":172,"line":354},[170,1050,203],{"class":176},[170,1052,181],{"class":180},[170,1054,1056,1058],{"class":172,"line":1055},7,[170,1057,187],{"class":180},[170,1059,1060],{"class":190},"sum($fs_usage{state='free'}) as free group by host_name\n",[170,1062,1064],{"class":172,"line":1063},8,[170,1065,197],{"emptyLinePlaceholder":10},[170,1067,1069],{"class":172,"line":1068},9,[170,1070,1071],{"class":246},"# fs utilization on each host\n",[170,1073,1075,1077],{"class":172,"line":1074},10,[170,1076,203],{"class":176},[170,1078,181],{"class":180},[170,1080,1082,1084],{"class":172,"line":1081},11,[170,1083,187],{"class":180},[170,1085,1086],{"class":190},"sum($fs_usage{state='used'}) \u002F sum($fs_usage) as fs_util group by host_name\n",[170,1088,1090],{"class":172,"line":1089},12,[170,1091,197],{"emptyLinePlaceholder":10},[170,1093,1095],{"class":172,"line":1094},13,[170,1096,1097],{"class":246},"# the size of your dataset on all hosts\n",[170,1099,1101,1103],{"class":172,"line":1100},14,[170,1102,203],{"class":176},[170,1104,181],{"class":180},[170,1106,1108,1110],{"class":172,"line":1107},15,[170,1109,187],{"class":180},[170,1111,1112],{"class":190},"sum($fs_usage{state='used'}) as dataset_size\n",[524,1114,1116],{"id":1115},"binary-operator-precedence","Binary operator precedence",[128,1118,1119],{},"The following list shows the precedence of binary operators in Uptrace, from highest to lowest.",[536,1121,1122,1127,1138,1146,1166,1174],{},[539,1123,1124],{},[167,1125,1126],{},"^",[539,1128,1129,454,1132,454,1135],{},[167,1130,1131],{},"*",[167,1133,1134],{},"\u002F",[167,1136,1137],{},"%",[539,1139,1140,454,1143],{},[167,1141,1142],{},"+",[167,1144,1145],{},"-",[539,1147,1148,454,1151,454,1154,454,1157,454,1160,454,1163],{},[167,1149,1150],{},"==",[167,1152,1153],{},"!=",[167,1155,1156],{},"\u003C=",[167,1158,1159],{},"\u003C",[167,1161,1162],{},">=",[167,1164,1165],{},">",[539,1167,1168,454,1171],{},[167,1169,1170],{},"and",[167,1172,1173],{},"unless",[539,1175,1176],{},[167,1177,1178],{},"or",[128,1180,1181,1182,1185,1186,1189],{},"Operators on the same precedence level are left-associative. For example, ",[167,1183,1184],{},"2 * 3 % 2"," is equivalent to ",[167,1187,1188],{},"(2 * 3) % 2",".",[149,1191,1193],{"id":1192},"see-also","See also",[536,1195,1196,1200,1206],{},[539,1197,1198],{},[132,1199,135],{"href":134},[539,1201,1202],{},[132,1203,1205],{"href":1204},"\u002Fguides\u002Fopentelemetry-postgresql","OpenTelemetry PostgreSQL metrics",[539,1207,1208],{},[132,1209,1211],{"href":1210},"\u002Fguides\u002Fopentelemetry-redis","OpenTelemetry Redis metrics",[1213,1214,1215],"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 .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}html pre.shiki code .s7eDp, html code.shiki .s7eDp{--shiki-default:#6F42C1}",{"title":165,"searchDepth":200,"depth":184,"links":1217},[1218,1219,1220,1221,1228,1232],{"id":151,"depth":184,"text":152},{"id":226,"depth":184,"text":227},{"id":362,"depth":184,"text":363},{"id":417,"depth":184,"text":418,"children":1222},[1223,1224,1225,1226,1227],{"id":526,"depth":194,"text":453},{"id":580,"depth":194,"text":495},{"id":658,"depth":194,"text":481},{"id":723,"depth":194,"text":503},{"id":855,"depth":194,"text":522},{"id":931,"depth":184,"text":932,"children":1229},[1230,1231],{"id":935,"depth":194,"text":936},{"id":1115,"depth":194,"text":1116},{"id":1192,"depth":184,"text":1193},"Write PromQL inspired metric queries with aliases, joins, and expressions that feed dashboards built in the UI or YAML.","md",null,{"readingTime":1237},{"text":1238,"minutes":1239,"time":1240,"words":1241},"4 min read",3.23,193800,646,{"title":45},{"title":119,"description":1233},"ZSUnDAwqfuF_-asJ7gtFbAF1BAN55SfKSLorVre9mXI",[1246,1248],{"title":15,"path":40,"stem":41,"description":1247,"children":-1},"Monitor infrastructure and application metrics in Uptrace using pre-built dashboards with table and grid views, or explore any metric interactively with aggregations, grouping, and filters.",{"title":49,"path":50,"stem":51,"description":1249,"children":-1},"See how Uptrace extends PromQL, which functions are supported, and how to adapt Prometheus queries or Grafana dashboards.",{"id":1251,"title":119,"body":1252,"description":1256,"extension":1234,"meta":2474,"navigation":10,"path":2479,"seo":2480,"stem":2481,"__hash__":2482},"partials\u002Fpartials\u002F_querying-metrics.md",{"type":121,"value":1253,"toc":2461},[1254,1257,1307,1310,1392,1396,1399,1452,1463,1560,1569,1612,1615,1647,1651,1654,1699,1702,1790,1793,1846,1850,1853,1889,1892,1943,1946,1973,1977,1980,2012,2022,2025,2028,2067,2077,2080,2083,2118,2135,2138,2141,2263,2267,2270,2350,2353,2379,2387,2393,2399,2415,2421,2425,2430,2437,2446,2449,2458],[128,1255,1256],{},"You can also specify grouping for the whole expression:",[160,1258,1260],{"className":369,"code":1259,"language":371,"meta":165,"style":165},"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",[167,1261,1262,1276,1280,1285],{"__ignoreMap":165},[170,1263,1264,1267,1269,1273],{"class":172,"line":173},[170,1265,1266],{"class":378},"sum($metric1",[170,1268,382],{"class":180},[170,1270,1272],{"class":1271},"sYu0t","type",[170,1274,1275],{"class":180},") \u002F sum($metric2) group by host_name\n",[170,1277,1278],{"class":172,"line":184},[170,1279,197],{"emptyLinePlaceholder":10},[170,1281,1282],{"class":172,"line":194},[170,1283,1284],{"class":246},"# The same.\n",[170,1286,1287,1289,1291,1293,1296,1299,1302,1305],{"class":172,"line":200},[170,1288,1266],{"class":378},[170,1290,382],{"class":180},[170,1292,1272],{"class":1271},[170,1294,1295],{"class":190},",",[170,1297,1298],{"class":190}," host_name",[170,1300,1301],{"class":180},") \u002F sum($metric2) by (",[170,1303,1304],{"class":378},"host_name",[170,1306,391],{"class":180},[128,1308,1309],{},"And for the whole query affecting all expressions:",[160,1311,1313],{"className":369,"code":1312,"language":371,"meta":165,"style":165},"$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",[167,1314,1315,1339,1343,1348,1365,1370],{"__ignoreMap":165},[170,1316,1317,1320,1324,1327,1330,1333,1336],{"class":172,"line":173},[170,1318,1319],{"class":180},"$metric1 ",[170,1321,1323],{"class":1322},"sD7c4","|",[170,1325,1326],{"class":378}," metric2",[170,1328,1329],{"class":1322}," |",[170,1331,1332],{"class":378}," group",[170,1334,1335],{"class":190}," by",[170,1337,1338],{"class":190}," host_name\n",[170,1340,1341],{"class":172,"line":184},[170,1342,197],{"emptyLinePlaceholder":10},[170,1344,1345],{"class":172,"line":194},[170,1346,1347],{"class":246},"# The same using expression-wide grouping.\n",[170,1349,1350,1353,1355,1358,1361,1363],{"class":172,"line":200},[170,1351,1352],{"class":180},"$metric1 group by host_name ",[170,1354,1323],{"class":1322},[170,1356,1357],{"class":180}," $metric2 ",[170,1359,1360],{"class":190},"group",[170,1362,1335],{"class":190},[170,1364,1338],{"class":190},[170,1366,1367],{"class":172,"line":208},[170,1368,1369],{"class":246},"# Or custom grouping.\n",[170,1371,1372,1374,1376,1378,1381,1383,1386,1388,1390],{"class":172,"line":354},[170,1373,1266],{"class":378},[170,1375,382],{"class":180},[170,1377,1304],{"class":378},[170,1379,1380],{"class":180},") ",[170,1382,1323],{"class":1322},[170,1384,1385],{"class":378}," sum($metric2",[170,1387,382],{"class":180},[170,1389,1304],{"class":378},[170,1391,391],{"class":180},[149,1393,1395],{"id":1394},"manipulating-attributes","Manipulating attributes",[128,1397,1398],{},"You can rename attributes like this:",[160,1400,1402],{"className":369,"code":1401,"language":371,"meta":165,"style":165},"$metric1 by (deployment_environment as env, service_name as service)\n$metric1 | group by deployment_environment as env, service_name as service\n",[167,1403,1404,1428],{"__ignoreMap":165},[170,1405,1406,1409,1412,1415,1418,1421,1423,1426],{"class":172,"line":173},[170,1407,1408],{"class":180},"$metric1 by (",[170,1410,1411],{"class":378},"deployment_environment",[170,1413,1414],{"class":190}," as",[170,1416,1417],{"class":190}," env,",[170,1419,1420],{"class":190}," service_name",[170,1422,1414],{"class":190},[170,1424,1425],{"class":190}," service",[170,1427,391],{"class":180},[170,1429,1430,1432,1434,1436,1438,1441,1443,1445,1447,1449],{"class":172,"line":184},[170,1431,1319],{"class":180},[170,1433,1323],{"class":1322},[170,1435,1332],{"class":378},[170,1437,1335],{"class":190},[170,1439,1440],{"class":190}," deployment_environment",[170,1442,1414],{"class":190},[170,1444,1417],{"class":190},[170,1446,1420],{"class":190},[170,1448,1414],{"class":190},[170,1450,1451],{"class":190}," service\n",[128,1453,1454,1455,1458,1459,1462],{},"To manipulate attribute values, you can use ",[167,1456,1457],{},"replace"," and ",[167,1460,1461],{},"replaceRegexp"," functions:",[160,1464,1466],{"className":369,"code":1465,"language":371,"meta":165,"style":165},"group by replace(host_name, 'uptrace-prod-', '') as host\ngroup by replaceRegexp(host, `^`, 'prefix ') as host\ngroup by replaceRegexp(host, `$`, ' suffix') as host\n",[167,1467,1468,1497,1530],{"__ignoreMap":165},[170,1469,1470,1472,1474,1477,1480,1483,1486,1489,1491,1494],{"class":172,"line":173},[170,1471,1360],{"class":378},[170,1473,1335],{"class":190},[170,1475,1476],{"class":190}," replace",[170,1478,1479],{"class":180},"(",[170,1481,1482],{"class":378},"host_name,",[170,1484,1485],{"class":190}," 'uptrace-prod-',",[170,1487,1488],{"class":190}," ''",[170,1490,1380],{"class":180},[170,1492,1493],{"class":190},"as",[170,1495,1496],{"class":190}," host\n",[170,1498,1499,1501,1503,1506,1508,1511,1514,1516,1519,1521,1524,1526,1528],{"class":172,"line":184},[170,1500,1360],{"class":378},[170,1502,1335],{"class":190},[170,1504,1505],{"class":190}," replaceRegexp",[170,1507,1479],{"class":180},[170,1509,1510],{"class":378},"host,",[170,1512,1513],{"class":190}," `",[170,1515,1126],{"class":378},[170,1517,1518],{"class":190},"`",[170,1520,1295],{"class":378},[170,1522,1523],{"class":190}," 'prefix '",[170,1525,1380],{"class":180},[170,1527,1493],{"class":190},[170,1529,1496],{"class":190},[170,1531,1532,1534,1536,1538,1540,1542,1544,1547,1549,1551,1554,1556,1558],{"class":172,"line":194},[170,1533,1360],{"class":378},[170,1535,1335],{"class":190},[170,1537,1505],{"class":190},[170,1539,1479],{"class":180},[170,1541,1510],{"class":378},[170,1543,1513],{"class":190},[170,1545,1546],{"class":378},"$",[170,1548,1518],{"class":190},[170,1550,1295],{"class":378},[170,1552,1553],{"class":190}," ' suffix'",[170,1555,1380],{"class":180},[170,1557,1493],{"class":190},[170,1559,1496],{"class":190},[128,1561,1562,1563,1458,1566,1462],{},"To change strings case, use ",[167,1564,1565],{},"upper",[167,1567,1568],{},"lower",[160,1570,1572],{"className":369,"code":1571,"language":371,"meta":165,"style":165},"group by lower(host_name) as host\ngroup by upper(host_name) as host\n",[167,1573,1574,1593],{"__ignoreMap":165},[170,1575,1576,1578,1580,1583,1585,1587,1589,1591],{"class":172,"line":173},[170,1577,1360],{"class":378},[170,1579,1335],{"class":190},[170,1581,1582],{"class":190}," lower",[170,1584,1479],{"class":180},[170,1586,1304],{"class":378},[170,1588,1380],{"class":180},[170,1590,1493],{"class":190},[170,1592,1496],{"class":190},[170,1594,1595,1597,1599,1602,1604,1606,1608,1610],{"class":172,"line":184},[170,1596,1360],{"class":378},[170,1598,1335],{"class":190},[170,1600,1601],{"class":190}," upper",[170,1603,1479],{"class":180},[170,1605,1304],{"class":378},[170,1607,1380],{"class":180},[170,1609,1493],{"class":190},[170,1611,1496],{"class":190},[128,1613,1614],{},"You can also use a regexp to extract a substring from the attribute value:",[160,1616,1618],{"className":369,"code":1617,"language":371,"meta":165,"style":165},"group by extract(host_name, `^uptrace-prod-(\\w+)$`) as host\n",[167,1619,1620],{"__ignoreMap":165},[170,1621,1622,1624,1626,1629,1631,1633,1635,1638,1641,1643,1645],{"class":172,"line":173},[170,1623,1360],{"class":378},[170,1625,1335],{"class":190},[170,1627,1628],{"class":190}," extract",[170,1630,1479],{"class":180},[170,1632,1482],{"class":378},[170,1634,1513],{"class":190},[170,1636,1637],{"class":378},"^uptrace-prod-(\\w+",[170,1639,1640],{"class":190},")$`",[170,1642,1380],{"class":180},[170,1644,1493],{"class":190},[170,1646,1496],{"class":190},[149,1648,1650],{"id":1649},"filtering","Filtering",[128,1652,1653],{},"Uptrace supports all the same filters just like PromQL:",[160,1655,1657],{"className":369,"code":1656,"language":371,"meta":165,"style":165},"node_cpu_seconds_total{cpu=\"0\",mode=\"idle\"}\nnode_cpu_seconds_total{cpu!=\"0\",mode~\"user|system\"}\n",[167,1658,1659,1682],{"__ignoreMap":165},[170,1660,1661,1664,1667,1670,1673,1676,1679],{"class":172,"line":173},[170,1662,1663],{"class":378},"node_cpu_seconds_total",[170,1665,1666],{"class":190},"{cpu=",[170,1668,1669],{"class":378},"\"0\"",[170,1671,1672],{"class":378},",mode",[170,1674,1675],{"class":190},"=",[170,1677,1678],{"class":378},"\"idle\"",[170,1680,1681],{"class":378},"}\n",[170,1683,1684,1686,1689,1691,1694,1697],{"class":172,"line":184},[170,1685,1663],{"class":378},[170,1687,1688],{"class":190},"{cpu!=",[170,1690,1669],{"class":378},[170,1692,1693],{"class":378},",mode~",[170,1695,1696],{"class":378},"\"user|system\"",[170,1698,1681],{"class":378},[128,1700,1701],{},"In addition, you can also add global filters that affect all expressions:",[160,1703,1705],{"className":369,"code":1704,"language":371,"meta":165,"style":165},"$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",[167,1706,1707,1740,1744,1749],{"__ignoreMap":165},[170,1708,1709,1711,1713,1715,1717,1720,1723,1726,1729,1731,1733,1735,1737],{"class":172,"line":173},[170,1710,1319],{"class":180},[170,1712,1323],{"class":1322},[170,1714,1357],{"class":180},[170,1716,1323],{"class":1322},[170,1718,1719],{"class":378}," where",[170,1721,1722],{"class":190}," host",[170,1724,1725],{"class":190}," =",[170,1727,1728],{"class":190}," \"myhost\"",[170,1730,1329],{"class":1322},[170,1732,1719],{"class":378},[170,1734,1425],{"class":190},[170,1736,1725],{"class":190},[170,1738,1739],{"class":190}," \"myservice\"\n",[170,1741,1742],{"class":172,"line":184},[170,1743,197],{"emptyLinePlaceholder":10},[170,1745,1746],{"class":172,"line":194},[170,1747,1748],{"class":246},"# The same using inline filters.\n",[170,1750,1751,1754,1756,1759,1762,1764,1767,1770,1772,1775,1778,1781,1784,1786,1788],{"class":172,"line":200},[170,1752,1753],{"class":180},"$metric1{host",[170,1755,1675],{"class":1322},[170,1757,1758],{"class":190},"\"myhost\",",[170,1760,1761],{"class":180},"service",[170,1763,1675],{"class":1322},[170,1765,1766],{"class":190},"\"myservice\"",[170,1768,1769],{"class":180},"} ",[170,1771,1323],{"class":1322},[170,1773,1774],{"class":180}," $metric2",[170,1776,1777],{"class":190},"{host=",[170,1779,1780],{"class":378},"\"myhost\"",[170,1782,1783],{"class":378},",service",[170,1785,1675],{"class":190},[170,1787,1766],{"class":378},[170,1789,1681],{"class":378},[128,1791,1792],{},"Global filters support the following operators:",[536,1794,1795,1813,1824,1835],{},[539,1796,1797,454,1799,454,1801,454,1803,454,1805,454,1807,1809,1810,1189],{},[167,1798,1675],{},[167,1800,1153],{},[167,1802,1159],{},[167,1804,1156],{},[167,1806,1165],{},[167,1808,1162],{},", for example, ",[167,1811,1812],{},"where host_name = \"myhost\"",[539,1814,1815,454,1818,1809,1821,1189],{},[167,1816,1817],{},"~",[167,1819,1820],{},"!~",[167,1822,1823],{},"where host_name ~ \"^prod-[a-z]+-[0-9]+$\"",[539,1825,1826,454,1829,1809,1832,1189],{},[167,1827,1828],{},"like",[167,1830,1831],{},"not like",[167,1833,1834],{},"where host_name like \"prod-%\"",[539,1836,1837,454,1840,1809,1843,1189],{},[167,1838,1839],{},"in",[167,1841,1842],{},"not in",[167,1844,1845],{},"where host_name in (\"host1\", \"host2\")",[149,1847,1849],{"id":1848},"joining","Joining",[128,1851,1852],{},"Uptrace supports math between series, for example, to add all equally-labelled series from both sides:",[160,1854,1856],{"className":369,"code":1855,"language":371,"meta":165,"style":165},"$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",[167,1857,1858,1863,1867,1871],{"__ignoreMap":165},[170,1859,1860],{"class":172,"line":173},[170,1861,1862],{"class":180},"$mem_free + $mem_cached group by host_name, service_name\n",[170,1864,1865],{"class":172,"line":184},[170,1866,197],{"emptyLinePlaceholder":10},[170,1868,1869],{"class":172,"line":194},[170,1870,1284],{"class":246},[170,1872,1873,1876,1878,1880,1883,1885,1887],{"class":172,"line":200},[170,1874,1875],{"class":180},"$mem_free by (",[170,1877,1482],{"class":378},[170,1879,1420],{"class":190},[170,1881,1882],{"class":180},") + $mem_cached by (",[170,1884,1482],{"class":378},[170,1886,1420],{"class":190},[170,1888,391],{"class":180},[128,1890,1891],{},"Uptrace also automatically supports one-to-many\u002Fmany-to-one joins:",[160,1893,1895],{"className":369,"code":1894,"language":371,"meta":165,"style":165},"# 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",[167,1896,1897,1902,1920,1924,1929],{"__ignoreMap":165},[170,1898,1899],{"class":172,"line":173},[170,1900,1901],{"class":246},"# One-to-many\n",[170,1903,1904,1907,1909,1912,1915,1918],{"class":172,"line":184},[170,1905,1906],{"class":180},"$metric by (",[170,1908,1272],{"class":1271},[170,1910,1911],{"class":180},") \u002F $metric by (",[170,1913,1914],{"class":378},"service_name,",[170,1916,1917],{"class":190}," type",[170,1919,391],{"class":180},[170,1921,1922],{"class":172,"line":194},[170,1923,197],{"emptyLinePlaceholder":10},[170,1925,1926],{"class":172,"line":200},[170,1927,1928],{"class":246},"# Many-to-one\n",[170,1930,1931,1933,1935,1937,1939,1941],{"class":172,"line":208},[170,1932,1906],{"class":180},[170,1934,1914],{"class":378},[170,1936,1917],{"class":190},[170,1938,1911],{"class":180},[170,1940,1272],{"class":1271},[170,1942,391],{"class":180},[128,1944,1945],{},"If attribute names don't match, you can rename them like this:",[160,1947,1949],{"className":369,"code":1948,"language":371,"meta":165,"style":165},"$metric by (hostname as host) + $metric by (host_name as host)\n",[167,1950,1951],{"__ignoreMap":165},[170,1952,1953,1955,1958,1960,1962,1965,1967,1969,1971],{"class":172,"line":173},[170,1954,1906],{"class":180},[170,1956,1957],{"class":378},"hostname",[170,1959,1414],{"class":190},[170,1961,1722],{"class":190},[170,1963,1964],{"class":180},") + $metric by (",[170,1966,1304],{"class":378},[170,1968,1414],{"class":190},[170,1970,1722],{"class":190},[170,1972,391],{"class":180},[149,1974,1976],{"id":1975},"supported-functions","Supported functions",[128,1978,1979],{},"Uptrace supports the following types of functions:",[536,1981,1982,1988,1994,2000,2006],{},[539,1983,1984],{},[132,1985,1987],{"href":1986},"#aggregate","aggregate",[539,1989,1990],{},[132,1991,1993],{"href":1992},"#rollup","rollup",[539,1995,1996],{},[132,1997,1999],{"href":1998},"#transform","transform",[539,2001,2002],{},[132,2003,2005],{"href":2004},"#attribute-manipulation","attribute manipulation",[539,2007,2008],{},[132,2009,2011],{"href":2010},"#if","if",[128,2013,2014,2015,2021],{},"If Uptrace does not support the function you need, please ",[132,2016,2020],{"href":2017,"rel":2018},"https:\u002F\u002Fgithub.com\u002Fuptrace\u002Fuptrace\u002Fissues",[2019],"nofollow","open an issue"," on GitHub.",[524,2023,2024],{"id":1987},"Aggregate",[128,2026,2027],{},"Aggregate functions combine multiple timeseries using the specified function and grouping attributes. When possible, aggregation is pushed down to ClickHouse for maximum efficiency.",[536,2029,2030,2034,2038,2042,2047],{},[539,2031,2032],{},[167,2033,861],{},[539,2035,2036],{},[167,2037,864],{},[539,2039,2040],{},[167,2041,654],{},[539,2043,2044],{},[167,2045,2046],{},"avg",[539,2048,2049,454,2052,454,2055,454,2058,454,2061,454,2064,2066],{},[167,2050,2051],{},"median",[167,2053,2054],{},"p50",[167,2056,2057],{},"p75",[167,2059,2060],{},"p90",[167,2062,2063],{},"p99",[167,2065,870],{},". Only histograms.",[128,2068,2069,2070,2072,2073,2076],{},"The ",[167,2071,870],{}," function returns the number of observed values in a histogram. To count the number of timeseries, use ",[167,2074,2075],{},"uniq($metric, attr1, attr2)",", which efficiently counts the number of timeseries in the database without selecting all timeseries.",[524,2078,2079],{"id":1993},"Rollup",[128,2081,2082],{},"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.",[536,2084,2085,2102,2110],{},[539,2086,2087,454,2090,454,2093,454,2096,454,2099],{},[167,2088,2089],{},"min_over_time",[167,2091,2092],{},"max_over_time",[167,2094,2095],{},"sum_over_time",[167,2097,2098],{},"avg_over_time",[167,2100,2101],{},"median_over_time",[539,2103,2104,1458,2107],{},[167,2105,2106],{},"rate",[167,2108,2109],{},"irate",[539,2111,2112,1458,2115],{},[167,2113,2114],{},"increase",[167,2116,2117],{},"delta",[128,2119,2120,2121,2124,2125,2128,2129,2131,2132,1189],{},"You can specify the lookbehind window in square brackets, e.g. ",[167,2122,2123],{},"rate($metric[5i])"," where ",[167,2126,2127],{},"i"," is equal to the current ",[531,2130,2127],{},"nterval. When omitted, the default lookbehind window is ",[167,2133,2134],{},"10i",[524,2136,2137],{"id":1999},"Transform",[128,2139,2140],{},"Transform functions operate on each point of each timeseries. The number of timeseries and the number of datapoints remain the same.",[536,2142,2143,2148,2159,2173,2187,2201,2209,2223,2232,2241,2253],{},[539,2144,2145],{},[167,2146,2147],{},"abs",[539,2149,2150,454,2153,454,2156],{},[167,2151,2152],{},"ceil",[167,2154,2155],{},"floor",[167,2157,2158],{},"trunc",[539,2160,2161,454,2164,454,2167,454,2170],{},[167,2162,2163],{},"cos",[167,2165,2166],{},"cosh",[167,2168,2169],{},"acos",[167,2171,2172],{},"acosh",[539,2174,2175,454,2178,454,2181,454,2184],{},[167,2176,2177],{},"sin",[167,2179,2180],{},"sinh",[167,2182,2183],{},"asin",[167,2185,2186],{},"asinh",[539,2188,2189,454,2192,454,2195,454,2198],{},[167,2190,2191],{},"tan",[167,2193,2194],{},"tanh",[167,2196,2197],{},"atan",[167,2199,2200],{},"atanh",[539,2202,2203,454,2206],{},[167,2204,2205],{},"exp",[167,2207,2208],{},"exp2",[539,2210,2211,454,2214,454,2217,454,2220],{},[167,2212,2213],{},"ln",[167,2215,2216],{},"log",[167,2218,2219],{},"log2",[167,2221,2222],{},"log10",[539,2224,2225,2228,2229,1189],{},[167,2226,2227],{},"perSec"," divides each point by the number of seconds in the grouping interval. You can achieve the same with ",[167,2230,2231],{},"$metric \u002F _seconds",[539,2233,2234,2237,2238,1189],{},[167,2235,2236],{},"perMin"," divides each point by the number of minutes in the grouping interval. You can achieve the same with ",[167,2239,2240],{},"$metric \u002F _minutes",[539,2242,2243,2246,2247,2250,2251,1189],{},[167,2244,2245],{},"clamp_min(ts timeseries, min scalar)"," clamps ",[167,2248,2249],{},"ts"," values to have a lower limit of ",[167,2252,861],{},[539,2254,2255,2246,2258,2260,2261,1189],{},[167,2256,2257],{},"clamp_max(ts timeseries, max scalar)",[167,2259,2249],{}," values to have an upper limit of ",[167,2262,864],{},[524,2264,2266],{"id":2265},"attribute-manipulation","Attribute manipulation",[128,2268,2269],{},"Additionally, these functions manipulate attributes and can only be used in grouping expressions:",[536,2271,2272,2282,2290,2300,2309,2322,2338],{},[539,2273,2274,2277,2278,2281],{},[167,2275,2276],{},"lower(attr)"," lowers the case of the ",[167,2279,2280],{},"attr"," value.",[539,2283,2284,2287,2288,2281],{},[167,2285,2286],{},"upper(attr)"," uppers the case of the ",[167,2289,2280],{},[539,2291,2292,2295,2296,2299],{},[167,2293,2294],{},"trimPrefix(attr, \"prefix\")"," removes the provided leading ",[167,2297,2298],{},"prefix"," string.",[539,2301,2302,2305,2306,2299],{},[167,2303,2304],{},"trimSuffix(attr, \"suffix\")"," removes the provided trailing ",[167,2307,2308],{},"suffix",[539,2310,2311,2314,2315,2318,2319,1189],{},[167,2312,2313],{},"extract(haystack, pattern)"," extracts a fragment of the ",[167,2316,2317],{},"haystack"," string using the regular expression ",[167,2320,2321],{},"pattern",[539,2323,2324,2327,2328,2331,2332,2334,2335,2299],{},[167,2325,2326],{},"replace(haystack, substring, replacement)"," replaces all occurrences of the ",[167,2329,2330],{},"substring"," in ",[167,2333,2317],{}," by the ",[167,2336,2337],{},"replacement",[539,2339,2340,2343,2344,2331,2346,2334,2348,2299],{},[167,2341,2342],{},"replaceRegexp(haystack, pattern, replacement)"," replaces all occurrences of the substring matching the regular expression ",[167,2345,2321],{},[167,2347,2317],{},[167,2349,2337],{},[524,2351,2352],{"id":2011},"If",[128,2354,2355,2356,2358,2359,2362,2363,2366,2367,2370,2371,2374,2375,2378],{},"The special ",[167,2357,2011],{}," function enables conditional branching. If the condition ",[167,2360,2361],{},"cond"," evaluates to a value other than zero, the function returns the result of the ",[167,2364,2365],{},"then"," expression. If cond evaluates to ",[167,2368,2369],{},"0"," or ",[167,2372,2373],{},"NaN",", then the result of the ",[167,2376,2377],{},"else"," expression is returned.",[160,2380,2385],{"className":2381,"code":2383,"language":2384},[2382],"language-text","if(cond, then)\nif(cond, then, else)\n","text",[167,2386,2383],{"__ignoreMap":165},[128,2388,2389,2390,2392],{},"For example, you can use ",[167,2391,2011],{}," to calculate the hit rate only if the number of hits and misses exceeds a certain threshold:",[160,2394,2397],{"className":2395,"code":2396,"language":2384},[2382],"if(\n  sum($hits) + sum($misses) >= 100,\n  sum($misses) \u002F (sum($hits) + sum($misses))\n) as hit_rate\n",[167,2398,2396],{"__ignoreMap":165},[128,2400,2401,2402,2404,2405,2408,2409,2411,2412,2414],{},"When you omit the ",[167,2403,2377],{}," expression, Uptrace uses the ",[167,2406,2407],{},"null"," value. If all timeseries values are ",[167,2410,2407],{},", Uptrace removes such timeseries from the result. If you want to keep all timeseries, you can specify the ",[167,2413,2377],{}," expression:",[160,2416,2419],{"className":2417,"code":2418,"language":2384},[2382],"if(cond, else, 1)\nif(cond, else, NaN)\n",[167,2420,2418],{"__ignoreMap":165},[149,2422,2424],{"id":2423},"offset","Offset",[128,2426,2069,2427,2429],{},[167,2428,2423],{}," modifier allows to set time offset for the query.",[128,2431,2432,2433,2436],{},"For example, this query retrieves the value of ",[167,2434,2435],{},"http_requests_total"," from 5 minutes ago, relative to the query evaluation time:",[160,2438,2440],{"className":369,"code":2439,"language":371,"meta":165,"style":165},"$http_requests_total offset 5m\n",[167,2441,2442],{"__ignoreMap":165},[170,2443,2444],{"class":172,"line":173},[170,2445,2439],{"class":180},[128,2447,2448],{},"A negative offset allows to look ahead of the query evaluation time:",[160,2450,2452],{"className":369,"code":2451,"language":371,"meta":165,"style":165},"$http_requests_total offset -5m\n",[167,2453,2454],{"__ignoreMap":165},[170,2455,2456],{"class":172,"line":173},[170,2457,2451],{"class":180},[1213,2459,2460],{},"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":165,"searchDepth":200,"depth":184,"links":2462},[2463,2464,2465,2466,2473],{"id":1394,"depth":184,"text":1395},{"id":1649,"depth":184,"text":1650},{"id":1848,"depth":184,"text":1849},{"id":1975,"depth":184,"text":1976,"children":2467},[2468,2469,2470,2471,2472],{"id":1987,"depth":194,"text":2024},{"id":1993,"depth":194,"text":2079},{"id":1999,"depth":194,"text":2137},{"id":2265,"depth":194,"text":2266},{"id":2011,"depth":194,"text":2352},{"id":2423,"depth":184,"text":2424},{"readingTime":2475},{"text":1238,"minutes":2476,"time":2477,"words":2478},3.725,223500,745,"\u002Fpartials\u002F_querying-metrics",{"description":1256},"partials\u002F_querying-metrics","QLI3_6o-NpIQaDjktuI--sabRLoD3BcDaHEgQXgBJBQ",1778588617844]