@jcit/signoz 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +14 -5
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
2
3
|
import { formatOutput, addExamples, credential, installErrorHandler, defineCliApp } from '@jcit/core';
|
|
3
4
|
import { c as createSignozClient } from './shared/signoz.DH9MeMIj.mjs';
|
|
4
5
|
import { consola } from 'consola';
|
|
@@ -63,8 +64,9 @@ function buildPromqlRequest(query, start, end, step) {
|
|
|
63
64
|
return {
|
|
64
65
|
start,
|
|
65
66
|
end,
|
|
67
|
+
requestType: "time_series",
|
|
66
68
|
compositeQuery: {
|
|
67
|
-
queries: [{ type: "promql", spec: { name: "A", query, step } }]
|
|
69
|
+
queries: [{ type: "promql", spec: { name: "A", query, step, disabled: false } }]
|
|
68
70
|
}
|
|
69
71
|
};
|
|
70
72
|
}
|
|
@@ -72,13 +74,14 @@ function buildSqlRequest(query, start, end) {
|
|
|
72
74
|
return {
|
|
73
75
|
start,
|
|
74
76
|
end,
|
|
77
|
+
requestType: "time_series",
|
|
75
78
|
compositeQuery: {
|
|
76
79
|
queries: [{ type: "clickhouse_sql", spec: { name: "A", query, disabled: false } }]
|
|
77
80
|
}
|
|
78
81
|
};
|
|
79
82
|
}
|
|
80
83
|
function registerQuery(program) {
|
|
81
|
-
const cmd = program.command("query").description("Query traces, logs, and metrics via the unified query API").option("--promql <expr>", "PromQL expression").option("--sql <query>", "ClickHouse SQL query").option("-f, --file <path>", "Load query from JSON file (v5 query_range format)").option("--since <
|
|
84
|
+
const cmd = program.command("query").description("Query traces, logs, and metrics via the unified query API").option("--promql <expr>", "PromQL expression").option("--sql <query>", "ClickHouse SQL query (must include timestamp WHERE clause)").option("-f, --file <path>", "Load query from JSON file (v5 query_range format)").option("--since <time>", "Start time: duration ago (1h, 30m, 7d) or ISO date", "1h").option("--until <time>", "End time: 'now', duration ago, or ISO date", "now").option("--step <seconds>", "Step interval in seconds (PromQL only)", "60").option("--format <format>", "Output format: json | table | text", "json").option("--url <url>", "SigNoz API base URL").option("--token <token>", "SigNoz API token").action(async (opts) => {
|
|
82
85
|
const modes = [opts.promql, opts.sql, opts.file].filter(Boolean);
|
|
83
86
|
if (modes.length === 0) {
|
|
84
87
|
cmd.error("specify one of --promql, --sql, or --file");
|
|
@@ -91,7 +94,11 @@ function registerQuery(program) {
|
|
|
91
94
|
const end = parseUntil(opts.until);
|
|
92
95
|
let body;
|
|
93
96
|
if (opts.promql) {
|
|
94
|
-
|
|
97
|
+
const step = Number(opts.step);
|
|
98
|
+
if (Number.isNaN(step) || step <= 0) {
|
|
99
|
+
cmd.error(`invalid --step value: "${opts.step}". Provide a positive number in seconds`);
|
|
100
|
+
}
|
|
101
|
+
body = buildPromqlRequest(opts.promql, start, end, step);
|
|
95
102
|
} else if (opts.sql) {
|
|
96
103
|
body = buildSqlRequest(opts.sql, start, end);
|
|
97
104
|
} else {
|
|
@@ -107,7 +114,7 @@ function registerQuery(program) {
|
|
|
107
114
|
});
|
|
108
115
|
addExamples(cmd, [
|
|
109
116
|
"signoz query --promql 'rate(http_requests_total[5m])' --since 1h",
|
|
110
|
-
"signoz query --sql 'SELECT count() FROM signoz_logs.
|
|
117
|
+
"signoz query --sql 'SELECT count(*) AS value FROM signoz_logs.distributed_logs_v2 WHERE timestamp >= ...'",
|
|
111
118
|
"signoz query -f my-query.json --since 7d --until 1d",
|
|
112
119
|
"signoz query --promql 'up' --format table"
|
|
113
120
|
]);
|
|
@@ -123,9 +130,11 @@ function registerServices(program) {
|
|
|
123
130
|
}
|
|
124
131
|
|
|
125
132
|
installErrorHandler();
|
|
133
|
+
const require$1 = createRequire(import.meta.url);
|
|
134
|
+
const { version } = require$1("../package.json");
|
|
126
135
|
const program = defineCliApp({
|
|
127
136
|
name: "signoz",
|
|
128
|
-
version
|
|
137
|
+
version,
|
|
129
138
|
description: "CLI for SigNoz observability platform",
|
|
130
139
|
docsUrl: "https://github.com/m1heng/just-cli-it/tree/main/packages/signoz"
|
|
131
140
|
});
|