@jcit/signoz 0.2.0 → 0.2.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.
Files changed (2) hide show
  1. package/dist/cli.mjs +23 -1
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -158,6 +158,23 @@ function isEmptyResult(res) {
158
158
  if (!results) return true;
159
159
  return results.every((r) => !r.aggregations?.some((a) => a.series && a.series.length > 0));
160
160
  }
161
+ function flattenSeries(res) {
162
+ const rows = [];
163
+ for (const result of res.data?.data?.results ?? []) {
164
+ for (const agg of result.aggregations ?? []) {
165
+ for (const s of agg.series ?? []) {
166
+ const labels = {};
167
+ for (const l of s.labels ?? []) {
168
+ labels[l.key.name] = l.value;
169
+ }
170
+ for (const v of s.values ?? []) {
171
+ rows.push({ ts: new Date(v.timestamp).toISOString(), ...labels, value: v.value });
172
+ }
173
+ }
174
+ }
175
+ }
176
+ return rows;
177
+ }
161
178
  function registerQuery(program) {
162
179
  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 (use {{start_ms}} etc. for time injection)").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");
163
180
  addCommonOptions(cmd).action(async (opts) => {
@@ -190,7 +207,12 @@ function registerQuery(program) {
190
207
  method: "POST",
191
208
  body
192
209
  });
193
- formatOutput(result, opts.format);
210
+ if (opts.format === "table") {
211
+ const rows = flattenSeries(result);
212
+ formatOutput(rows.length > 0 ? rows : result, "table");
213
+ } else {
214
+ formatOutput(result, opts.format);
215
+ }
194
216
  if (opts.promql && isEmptyResult(result)) {
195
217
  consola.warn(
196
218
  'PromQL returned no data. Common causes:\n \u2022 Delta-temporality metrics (e.g. signoz_calls_total) are not queryable via PromQL \u2014 use --sql or the builder API instead\n \u2022 OTel dot-separated names require {__name__="metric.name"} syntax'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcit/signoz",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "CLI for SigNoz observability platform",
5
5
  "repository": {
6
6
  "type": "git",