Hello, team! I would like to change below promql q...
# support
h
Hello, team! I would like to change below promql query to query builder. • rate(system_cpu_time{temporality="Cumulative",cpu="cpu11",host_name="signoz-host",os_type="linux",state="system"}[1m]) But I couldn't find how to set range vector selector([1m]) in query builder. I thought 'Aggregate Every' was a value, but the graph was made different from when I called PromQL.
Due to the company policy, I can not attach screenshots, so I upload request and response values that I checked in developer mode. PromQL • Request >
Copy code
{
>    "start":1720000800000,
>    "end":1720001460000,
>    "step":60,
>    "variables":{
>    },
>    "compositeQuery":{
>       "queryType":"promql",
>       "panelType":"graph",
>       "fillGaps":false,
>       "promQueries":{
>          "A":{
>             "name":"A",
>             "query":"rate(system_cpu_time{__temporality__=\"Cumulative\",cpu=\"cpu11\",host_name=\"signoz-host\",os_type=\"linux\",state=\"system\"}[1m])",
>             "legend":"",
>             "disabled":false
>          }
>       }
>    }
> }
• Response >
Copy code
{
>     "status": "success",
>     "data": {
>         "resultType": "",
>         "result": [
>             {
>                 "queryName": "A",
>                 "series": [
>                     {
>                         "labels": {
>                             "__temporality__": "Cumulative",
>                             "cpu": "cpu11",
>                             "host_name": "signoz-host",
>                             "os_type": "linux",
>                             "state": "system"
>                         },
>                         "labelsArray": null,
>                         "values": [
>                             {
>                                 "timestamp": 1720000800000,
>                                 "value": "0.022666666666433837"
>                             },
>                             {
>                                 "timestamp": 1720000860000,
>                                 "value": "0.01900000000023283"
>                             },
>                             {
>                                 "timestamp": 1720000920000,
>                                 "value": "0.020666666666511447"
>                             },
>                             {
>                                 "timestamp": 1720000980000,
>                                 "value": "0.026000866695517714"
>                             },
>                             {
>                                 "timestamp": 1720001040000,
>                                 "value": "0.026999999999922388"
>                             },
>                             {
>                                 "timestamp": 1720001100000,
>                                 "value": "0.025333333333643775"
>                             },
>                             {
>                                 "timestamp": 1720001160000,
>                                 "value": "0.03866666666678308"
>                             },
>                             {
>                                 "timestamp": 1720001220000,
>                                 "value": "0.022334077802535213"
>                             },
>                             {
>                                 "timestamp": 1720001280000,
>                                 "value": "0.020333333333352736"
>                             },
>                             {
>                                 "timestamp": 1720001340000,
>                                 "value": "0.02100000000015522"
>                             },
>                             {
>                                 "timestamp": 1720001400000,
>                                 "value": "0.017332755574464936"
>                             },
>                             {
>                                 "timestamp": 1720001460000,
>                                 "value": "0.025"
>                             }
>                         ]
>                     }
>                 ]
>             }
>         ]
>     }
> }
Query Builder • Request >
Copy code
{
>    "start":1720000800000,
>    "end":1720001460000,
>    "step":60,
>    "variables":{
>       
>    },
>    "compositeQuery":{
>       "queryType":"builder",
>       "panelType":"graph",
>       "fillGaps":false,
>       "builderQueries":{
>          "A":{
>             "dataSource":"metrics",
>             "queryName":"A",
>             "aggregateOperator":"rate",
>             "aggregateAttribute":{
>                "key":"system_cpu_time",
>                "dataType":"float64",
>                "type":"Sum",
>                "isColumn":true,
>                "isJSON":false,
>                "id":"system_cpu_time--float64--Sum--true"
>             },
>             "timeAggregation":"rate",
>             "spaceAggregation":"sum",
>             "functions":[
>                
>             ],
>             "filters":{
>                "items":[
>                   {
>                      "id":"09868595",
>                      "key":{
>                         "dataType":"",
>                         "isColumn":false,
>                         "key":"__temporality__",
>                         "type":""
>                      },
>                      "op":"=",
>                      "value":"Cumulative"
>                   },
>                   {
>                      "id":"03bdd894",
>                      "key":{
>                         "dataType":"string",
>                         "id":"cpu--string--tag--false",
>                         "isColumn":false,
>                         "isJSON":false,
>                         "key":"cpu",
>                         "type":"tag"
>                      },
>                      "op":"=",
>                      "value":"cpu11"
>                   },
>                   {
>                      "id":"8c7eb7e2",
>                      "key":{
>                         "dataType":"string",
>                         "id":"host_name--string--tag--false",
>                         "isColumn":false,
>                         "isJSON":false,
>                         "key":"host_name",
>                         "type":"tag"
>                      },
>                      "op":"=",
>                      "value":"signoz-host"
>                   },
>                   {
>                      "id":"3603c7f6",
>                      "key":{
>                         "dataType":"string",
>                         "id":"os_type--string--tag--false",
>                         "isColumn":false,
>                         "isJSON":false,
>                         "key":"os_type",
>                         "type":"tag"
>                      },
>                      "op":"=",
>                      "value":"linux"
>                   },
>                   {
>                      "id":"738e7ba6",
>                      "key":{
>                         "dataType":"string",
>                         "id":"state--string--tag--false",
>                         "isColumn":false,
>                         "isJSON":false,
>                         "key":"state",
>                         "type":"tag"
>                      },
>                      "op":"=",
>                      "value":"system"
>                   }
>                ],
>                "op":"AND"
>             },
>             "expression":"A",
>             "disabled":false,
>             "stepInterval":60,
>             "having":[
>                
>             ],
>             "limit":null,
>             "orderBy":[
>                
>             ],
>             "groupBy":[
>                
>             ],
>             "legend":"",
>             "reduceTo":"avg"
>          }
>       }
>    }
> }
• Response >
Copy code
{
>     "status": "success",
>     "data": {
>         "resultType": "",
>         "result": [
>             {
>                 "queryName": "A",
>                 "series": [
>                     {
>                         "labels": {},
>                         "labelsArray": null,
>                         "values": [
>                             {
>                                 "timestamp": 1720000800000,
>                                 "value": "0.021500000000135817"
>                             },
>                             {
>                                 "timestamp": 1720000860000,
>                                 "value": "0.023999999999796275"
>                             },
>                             {
>                                 "timestamp": 1720000920000,
>                                 "value": "0.022500000000097012"
>                             },
>                             {
>                                 "timestamp": 1720000980000,
>                                 "value": "0.019999999999951494"
>                             },
>                             {
>                                 "timestamp": 1720001040000,
>                                 "value": "0.023333333333478853"
>                             },
>                             {
>                                 "timestamp": 1720001100000,
>                                 "value": "0.03933333333334303"
>                             },
>                             {
>                                 "timestamp": 1720001160000,
>                                 "value": "0.021166666666492043"
>                             },
>                             {
>                                 "timestamp": 1720001220000,
>                                 "value": "0.021166666666734574"
>                             },
>                             {
>                                 "timestamp": 1720001280000,
>                                 "value": "0.02666666666676368"
>                             },
>                             {
>                                 "timestamp": 1720001340000,
>                                 "value": "0.019833333333129605"
>                             },
>                             {
>                                 "timestamp": 1720001400000,
>                                 "value": "0.02016666666677338"
>                             }
>                         ]
>                     }
>                 ]
>             }
>         ]
>     }
> }
s
Hi, You are doing it right in the query builder. What is the issue?
h
I tried to change PromQL to Query Builder, but I inquired because the result value was different.
s
It won't be absolutely the same as the PromQL because the way Prometheus does things is slightly different. But the results should match.
h
I thought so too, but I left an inquiry because the API Response value was different(The graph shape was different).
s
How much difference do you see? Looking at the above response shared I don't see much difference.
h
The graph shape is completely different. The peak position is different, and PromQL graph rises high at the point where the Query Builder graph falls low.
s
Please tell me the absolute/percentage difference. The graphs lie and knowing the actual difference is more important that visual high and low https://www.heap.io/blog/how-to-lie-with-data-visualization
Looking at your own data shared above I don't see a major difference in values. The values are most around 0.02 in both cases. As I mentioned, the Prometheus does things is differently and can produce slightly different results but they should mostly be the same overall.
h
https://www.desmos.com/calculator/lq8deqqp89 (The link above is a graph drawn from the site with a response value. For convenience, time is indicated only as 1-12. ) The value may not appear to differ much because it is a metric with a small variation, but the shape of the graph is completely different. And I called the same time zone, and the number of results is different from 12 to 11.
s
You are not getting my point. The shape of the graph lies because if you zoom out you don't see the same as when you zoom in. To reiterate my point, the calculation is different b/w Prometheus and ClickHouse query, as a result, the values also vary a little. What is more important is the overall correctness of the data, the absolute difference b/w the value and, not the graph's shape.
h
Timestamp PromQL Query Builder Difference Percentage 1720000800000 0.0226666666664338 0.0215000000001358 0.001166666666298 -5.43% 1720000860000 0.0190000000002328 0.0239999999997962 -0.004999999999563 20.83% 1720000920000 0.0206666666665114 0.0225000000000970 -0.001833333333586 8.15% 1720000980000 0.0260008666955177 0.0199999999999514 0.006000866695566 -30.00% 1720001040000 0.0269999999999223 0.0233333333334788 0.003666666666444 -15.71% 1720001100000 0.0253333333336437 0.0393333333333430 -0.013999999999699 35.59% 1720001160000 0.0386666666667830 0.0211666666664920 0.017500000000291 -82.68% 1720001220000 0.0223340778025352 0.0211666666667345 0.001167411135801 -5.52% 1720001280000 0.0203333333333527 0.0266666666667636 -0.006333333333411 23.75% 1720001340000 0.0210000000001552 0.0198333333331296 0.001166666667026 -5.88% 1720001400000 0.0173327555744649 0.0201666666667733 -0.002833911092308 14.05% 1720001460000 0.0250000000000000 The absolute difference in values is also up to 82.68%, which seems to be a big gap. No matter how different the values of promql and builder can be, it seems too much different.
s
I am not sure how else I can convey my point so I will retire. The points are around the same range. For one last time, I will reiterate that how calculations done in prom and clickhouse are a little different and they produce slightly different values. If you have a better way to solve it, the code is here https://github.com/SigNoz/signoz/tree/a6e68c65193ba448c48a1a5bb81773dd1e57444b/pkg/query-service/app/metrics please send a PR