Skip to content

Commit 4dcd757

Browse files
authored
Merge pull request #587 from metrico/fix/585
fix/585
2 parents 2922578 + fc0079a commit 4dcd757

30 files changed

+3457
-5
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ node_modules
99
/wasm_parts/vendor/
1010
/wasm_parts/main.wasm
1111
/wasm_parts/wasm_parts.iml
12+
/test/qryn_test_env/clickhouse/_data/
13+
/test/qryn_test_env/grafana/_data/

parser/registry/smart_optimizations/optimization_v3_2.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { getDuration, preJoinLabels, dist } = require('../common')
1+
const { getDuration, preJoinLabels, dist, sharedParamNames } = require('../common')
22
const reg = require('./log_range_agg_reg_v3_2')
33
const Sql = require('@cloki/clickhouse-sql')
44
const { DATABASE_NAME, checkVersion } = require('../../../lib/utils')
@@ -44,24 +44,30 @@ function isLogPipeline (token) {
4444
*/
4545
module.exports.apply = (token, fromNS, toNS, stepNS) => {
4646
fromNS = Math.floor(fromNS / 15000000000) * 15000000000
47+
const fromParam = new Sql.Parameter(sharedParamNames.from)
48+
const toParam = new Sql.Parameter(sharedParamNames.to)
4749
const tsClause = toNS
4850
? Sql.between('samples.timestamp_ns', fromNS, toNS)
4951
: Sql.Gt('samples.timestamp_ns', fromNS)
5052
let q = (new Sql.Select())
5153
.select(['samples.fingerprint', 'fingerprint'])
5254
.from([`${DATABASE_NAME()}.metrics_15s${_dist}`, 'samples'])
5355
.where(tsClause)
56+
.addParam(fromParam)
57+
.addParam(toParam)
58+
fromParam.set(fromNS)
59+
toParam.set(toNS)
5460

5561
q.ctx = {
5662
step: stepNS / 1000000000,
5763
inline: !!clusterName
5864
}
5965

60-
preJoinLabels(token, q, dist)
61-
6266
for (const streamSelectorRule of token.Children('log_stream_selector_rule')) {
6367
q = streamSelectorReg[streamSelectorRule.Child('operator').value](streamSelectorRule, q)
6468
}
69+
preJoinLabels(token, q, dist)
70+
q = q.groupBy('labels')
6571

6672
const lra = token.Child('log_range_aggregation')
6773
q = reg[lra.Child('log_range_aggregation_fn').value](lra, q)

promql/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ module.exports.series = async (query, fromMs, toMs) => {
6161
const data = await rawRequest(req.toString() + ' FORMAT JSON',
6262
null,
6363
DATABASE_NAME())
64-
return data.data.data.map(l => JSON.parse(l.labels))
64+
return data.data.data.map(l =>
65+
Object.fromEntries(Object.entries(JSON.parse(l.labels)).filter(e => e[1]))
66+
)
6567
} catch (e) {
6668
if (e instanceof prometheus.WasmError) {
6769
throw new PSQLError(e.message)

test/e2e

Submodule e2e updated from 7d77675 to e016d11
+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
version: '2.1'
2+
3+
networks:
4+
qryn-test:
5+
driver: bridge
6+
7+
services:
8+
grafana:
9+
image: grafana/grafana:11.2.2
10+
container_name: grafana
11+
user: root
12+
networks:
13+
- qryn-test
14+
volumes:
15+
- ./grafana/_data:/var/lib/grafana:rw
16+
- ./grafana/provisioning/:/etc/grafana/provisioning/
17+
environment:
18+
- GF_SECURITY_ADMIN_USER=${ADMIN_USER:-admin}
19+
- GF_SECURITY_ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin}
20+
- GF_USERS_ALLOW_SIGN_UP=false
21+
- GF_USERS_DEFAULT_THEME=light
22+
- GF_EXPLORE_ENABLED=true
23+
- GF_ALERTING_ENABLED=false
24+
- GF_UNIFIED_ALERTING_ENABLED=true
25+
- GF_FEATURE_TOGGLES_ENABLE=traceToMetrics,publicDashboards,tempoApmTable
26+
- GF_INSTALL_PLUGINS=grafana-pyroscope-app,https://storage.googleapis.com/integration-artifacts/grafana-lokiexplore-app/grafana-lokiexplore-app-latest.zip;grafana-lokiexplore-app
27+
restart: unless-stopped
28+
ports:
29+
- 3000:3000
30+
depends_on:
31+
- qryn
32+
33+
clickhouse-server:
34+
image: clickhouse/clickhouse-server:24.1
35+
container_name: clickhouse-server
36+
hostname: clickhouse
37+
restart: unless-stopped
38+
volumes:
39+
- ./clickhouse/_data:/var/lib/clickhouse
40+
networks:
41+
- qryn-test
42+
environment:
43+
- CLICKHOUSE_USER=qryn
44+
- CLICKHOUSE_PASSWORD=demo
45+
ports:
46+
- 8123:8123
47+
- 9000:9000
48+
healthcheck:
49+
test: ['CMD', 'wget', '--spider', '-q', '127.0.0.1:8123/ping']
50+
interval: 1s
51+
timeout: 1s
52+
retries: 30
53+
54+
qryn:
55+
image: node:22
56+
container_name: qryn
57+
hostname: qryn
58+
restart: unless-stopped
59+
volumes:
60+
- ../../:/app
61+
networks:
62+
- qryn-test
63+
expose:
64+
- 3100
65+
ports:
66+
- "3100:3100"
67+
environment:
68+
- CLICKHOUSE_SERVER=clickhouse-server
69+
- CLICKHOUSE_PORT=8123
70+
- CLICKHOUSE_AUTH=qryn:demo
71+
- CLICKHOUSE_DB=qryn
72+
- NODE_OPTIONS="--max-old-space-size=4096"
73+
- FASTIFY_METRICS=true
74+
working_dir: /app
75+
entrypoint: sh
76+
command:
77+
- -c
78+
- "mkdir /_app && cp -rf patches package.json package-lock.json /_app && cd /_app && npm install && cd /app && NODE_PATH='.:../_app/node_modules' node qryn_node.js"
79+
depends_on:
80+
clickhouse-server:
81+
condition: service_healthy
82+
83+
longtest:
84+
image: golang:1.22-alpine
85+
volumes:
86+
- ./longtest:/longtest
87+
working_dir: /longtest
88+
environment:
89+
MODE: LMZ
90+
URL: http://qryn:3100
91+
command: ["go", "run", "."]
92+
networks:
93+
- qryn-test
94+
depends_on:
95+
- qryn
96+
97+
otel-collector:
98+
container_name: otel-collector
99+
hostname: otel-collector
100+
image: ghcr.io/metrico/qryn-otel-collector:0.0.5
101+
networks:
102+
- qryn-test
103+
volumes:
104+
- ./otel/otel-collector-config.yaml:/etc/otel/config.yaml
105+
ports:
106+
- "3200:3100" # Loki/Logql HTTP receiver
107+
- "3201:3200" # Loki/Logql gRPC receiver
108+
- "8088:8088" # Splunk HEC receiver
109+
- "5514:5514" # Syslog TCP Rereceiverceiver
110+
- "24224:24224" # Fluent Forward receiver
111+
- "4317:4317" # OTLP gRPC receiver
112+
- "4318:4318" # OTLP HTTP receiver
113+
- "14250:14250" # Jaeger gRPC receiver
114+
- "14268:14268" # Jaeger thrift HTTP receiver
115+
- "9411:9411" # Zipkin Trace receiver
116+
- "11800:11800" # Skywalking gRPC receiver
117+
- "12800:12800" # Skywalking HTTP receiver
118+
- "8086:8086" # InfluxDB Line proto HTTP
119+
- "8062:8062" # Pyroscope jprof
120+
restart: on-failure
121+

0 commit comments

Comments
 (0)