koigrid 0.20.0 → 0.22.0

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/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ All notable changes to the koigrid CLI are documented here. Format: [Keep a Chan
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.22.0] — 2026-11-29
8
+
9
+ ### Added
10
+
11
+ - `koigrid db metrics <id>` and `koigrid redis metrics <id>` take `--metric cpu_pct,connections`, `--bucket 1m|5m|15m|1h|6h|1d`, `--stat avg|max|min` and `--hours 1..168`: only the series you ask for, one point per bucket (at most 2000 per series), like CloudWatch GetMetricData. Without them, the same raw samples as before. Backed by `GET /databases/:id/metrics` and `GET /redis/:id/metrics`.
12
+
13
+ ## [0.21.0] — 2026-11-29
14
+
15
+ ### Added
16
+
17
+ - `koigrid apps requests <id> [--since ISO] [--until ISO] [--by section|path|ua|ip|viewer|status|method] [--step 1m] [--top N] [--path /prefix] [--status 5xx]`: your app's requests per minute, split by path, section, user-agent, IP, visitor (as your CDN reports it), status or method, from koigrid's edge access log, kept 30 days — like CloudFront access logs. Backed by `GET /apps/:id/requests`.
18
+
7
19
  ## [0.20.0] — 2026-11-29
8
20
 
9
21
  ### Added
@@ -222,6 +222,26 @@ export async function apps(a) {
222
222
  }
223
223
  return;
224
224
  }
225
+ // Las peticiones por minuto desde el registro del edge (ficha fd0fe3cc), como los access logs de CloudFront: --since/--until
226
+ // (ISO UTC, 30 días) · --by section|path|ua|ip|viewer|status|method (def. section) · --step 1m|5m|15m|1h|1d · --top N · --path /x · --status 5xx.
227
+ case 'requests': {
228
+ need(' [--since ISO] [--until ISO] [--by section|path|ua|ip|viewer|status|method] [--step 1m] [--top 10] [--path /prefix] [--status 5xx]');
229
+ const q = new URLSearchParams();
230
+ for (const k of ['since', 'until', 'by', 'step', 'top', 'path', 'status'])
231
+ if (a.flags[k] !== undefined && a.flags[k] !== true)
232
+ q.set(k, String(a.flags[k]));
233
+ const r = await api(`/apps/${encodeURIComponent(id)}/requests${q.size ? `?${q}` : ''}`);
234
+ if (json)
235
+ return console.log(JSON.stringify(r, null, 2));
236
+ console.log(`${r.since} → ${r.until} · ${r.total} requests · by ${r.by} · step ${r.step}`);
237
+ output(r.groups || [], false, { rows: (r.groups || []).map((g) => ({ requests: String(g.requests), key: String(g.key).slice(0, 100) })), columns: ['requests', 'key'] });
238
+ if (r.otherRequests)
239
+ console.log(`(+${r.otherRequests} in other groups)`);
240
+ output(r.series || [], false, { rows: (r.series || []).map((p) => ({ t: String(p.t), requests: String(p.requests), '5xx': String(p.errors5xx) })), columns: ['t', 'requests', '5xx'] });
241
+ for (const n of r.notes || [])
242
+ console.log(`note: ${n}`);
243
+ return;
244
+ }
225
245
  case 'rm':
226
246
  case 'delete':
227
247
  need('');
@@ -125,9 +125,15 @@ export async function db(a) {
125
125
  const l = st.members || [];
126
126
  return output(l, false, { rows: l.map((x) => ({ member: x.member, role: x.role + (x.papel === 'dr' ? ' (dr)' : ''), allocated: x.measured ? `${x.allocatedGb} GB` : 'not measured', used: x.measured ? `${x.usedGb} GB` : '', pct: x.measured ? `${x.usedPct}%` : '', ago: x.measured ? `${x.measuredAgoSec}s` : '' })), columns: ['member', 'role', 'allocated', 'used', 'pct', 'ago'] });
127
127
  }
128
- case 'metrics':
128
+ case 'metrics': {
129
+ // ?metric=a,b · ?bucket=5m&stat=max · ?hours (ficha c6f869c8, como CloudWatch GetMetricData)
129
130
  need();
130
- return console.log(JSON.stringify(await api(`/databases/${encodeURIComponent(id)}/metrics`), null, 2));
131
+ const q = new URLSearchParams();
132
+ for (const k of ['hours', 'metric', 'bucket', 'stat'])
133
+ if (a.flags[k] != null)
134
+ q.set(k, String(a.flags[k]));
135
+ return console.log(JSON.stringify(await api(`/databases/${encodeURIComponent(id)}/metrics${q.size ? `?${q}` : ''}`), null, 2));
136
+ }
131
137
  // Lo que le pasó a la base y cuándo (ficha faec5dcd, como «Events» de RDS): cambios de líder, máquina perdida,
132
138
  // mantenimiento, copias. `--type` repetible, `--since/--until` (ISO con zona), `--hours`, `--limit`, `--cursor`.
133
139
  case 'events': {
@@ -48,9 +48,15 @@ export async function redis(a) {
48
48
  const res = spawnSync('redis-cli', ['-u', uri], { stdio: 'inherit' });
49
49
  return process.exit(res.status ?? 0);
50
50
  }
51
- case 'metrics':
51
+ case 'metrics': {
52
+ // ?metric=a,b · ?bucket=5m&stat=max · ?hours (ficha c6f869c8, como CloudWatch GetMetricData)
52
53
  need();
53
- return console.log(JSON.stringify(await api(`/redis/${encodeURIComponent(id)}/metrics`), null, 2));
54
+ const q = new URLSearchParams();
55
+ for (const k of ['hours', 'metric', 'bucket', 'stat'])
56
+ if (a.flags[k] != null)
57
+ q.set(k, String(a.flags[k]));
58
+ return console.log(JSON.stringify(await api(`/redis/${encodeURIComponent(id)}/metrics${q.size ? `?${q}` : ''}`), null, 2));
59
+ }
54
60
  case 'apply-config': {
55
61
  // SEC-REDIS-CUTOVER: recrea los nodos para que dejen de llevar la contraseña en sus Args (docker inspect).
56
62
  need();
package/dist/manifest.js CHANGED
@@ -20,8 +20,8 @@ export const CLI_COMMANDS = [
20
20
  --no-wait (or --detach) returns at once · --timeout <min> (default 20) · with --json it returns at once unless --wait
21
21
  Other --project <id> · --json`,
22
22
  },
23
- subs: ['ls', 'deploy', 'logs', 'http', 'rm', 'rename', 'health-path', 'port', 'release', 'build-settings', 'traffic-ramp', 'max-surge', 'deploy-analysis', 'scale', 'resize', 'autoscale', 'scale-out', 'env', 'domains', 'volumes', 'cdn', 'cache', 'protection', 'retention', 'github', 'github-repos', 'hooks', 'rollback', 'pause', 'resume', 'restore', 'migrate', 'deployments', 'previews', 'preview', 'rules', 'rule', 'rule-rm', 'rule-toggle', 'registry', 'loadtest'],
24
- endpoints: ['apps', 'apps/[id]', 'apps/[id]/deployments', 'apps/[id]/source-upload', 'apps/[id]/logs', 'apps/[id]/http', 'apps/[id]/scale', 'apps/[id]/resources', 'apps/[id]/autoscale', 'apps/[id]/scale-out', 'apps/[id]/env', 'apps/[id]/env/verify', 'apps/[id]/domains', 'apps/[id]/domains/verify', 'apps/[id]/volumes', 'apps/[id]/volumes/[volId]', 'apps/[id]/volumes/[volId]/backups', 'apps/[id]/volumes/[volId]/backups/[backupId]/restore', 'apps/[id]/cdn', 'apps/[id]/cache', 'apps/[id]/cache/purge', 'apps/[id]/protection', 'apps/[id]/protection/evaluate', 'apps/[id]/retention', 'apps/[id]/github', 'github/repos', 'apps/[id]/deploy-hooks', 'apps/[id]/deploy-hooks/[hookId]', 'apps/[id]/rollback', 'apps/[id]/pause', 'apps/[id]/resume', 'apps/[id]/restore', 'apps/[id]/migrate', 'apps/[id]/previews', 'apps/[id]/rules', 'apps/[id]/rules/[ruleId]', 'apps/[id]/registry', 'apps/[id]/loadtest'],
23
+ subs: ['ls', 'deploy', 'logs', 'http', 'requests', 'rm', 'rename', 'health-path', 'port', 'release', 'build-settings', 'traffic-ramp', 'max-surge', 'deploy-analysis', 'scale', 'resize', 'autoscale', 'scale-out', 'env', 'domains', 'volumes', 'cdn', 'cache', 'protection', 'retention', 'github', 'github-repos', 'hooks', 'rollback', 'pause', 'resume', 'restore', 'migrate', 'deployments', 'previews', 'preview', 'rules', 'rule', 'rule-rm', 'rule-toggle', 'registry', 'loadtest'],
24
+ endpoints: ['apps', 'apps/[id]', 'apps/[id]/deployments', 'apps/[id]/source-upload', 'apps/[id]/logs', 'apps/[id]/http', 'apps/[id]/requests', 'apps/[id]/scale', 'apps/[id]/resources', 'apps/[id]/autoscale', 'apps/[id]/scale-out', 'apps/[id]/env', 'apps/[id]/env/verify', 'apps/[id]/domains', 'apps/[id]/domains/verify', 'apps/[id]/volumes', 'apps/[id]/volumes/[volId]', 'apps/[id]/volumes/[volId]/backups', 'apps/[id]/volumes/[volId]/backups/[backupId]/restore', 'apps/[id]/cdn', 'apps/[id]/cache', 'apps/[id]/cache/purge', 'apps/[id]/protection', 'apps/[id]/protection/evaluate', 'apps/[id]/retention', 'apps/[id]/github', 'github/repos', 'apps/[id]/deploy-hooks', 'apps/[id]/deploy-hooks/[hookId]', 'apps/[id]/rollback', 'apps/[id]/pause', 'apps/[id]/resume', 'apps/[id]/restore', 'apps/[id]/migrate', 'apps/[id]/previews', 'apps/[id]/rules', 'apps/[id]/rules/[ruleId]', 'apps/[id]/registry', 'apps/[id]/loadtest'],
25
25
  },
26
26
  { name: 'db', aliases: ['databases', 'database'], product: 'databases', summary: 'Managed Postgres (HA) — incl. SQL console (db query/tables) + branching (db branch) + managed restore (db restore-dump)', subs: ['ls', 'info', 'create', 'rm', 'rename', 'pause', 'resume', 'retention', 'weekly', 'monthly', 'url', 'connect', 'metrics', 'events', 'top-queries', 'slots', 'logs', 'backups', 'restore', 'restore-dump', 'fix-ownership', 'analyze', 'import', 'restore-status', 'ext', 'replicas', 'dr-copy', 'network', 'recovery-cert', 'backup-key', 'backup-access', 'pub', 'query', 'tables', 'branch', 'roles', 'params', 'pooler', 'rotation', 'patching', 'sync', 'slot-cap', 'resize', 'apply-config', 'maintenance', 'subs', 'data', 'rpc'], endpoints: ['databases', 'databases/[id]', 'databases/[id]/pause', 'databases/[id]/resume', 'databases/[id]/connection', 'databases/[id]/backups', 'databases/[id]/restore', 'databases/[id]/restore-dump', 'databases/[id]/restore-dump/upload-url', 'databases/[id]/restore-dump/[jobId]', 'databases/[id]/fix-ownership', 'databases/[id]/analyze', 'databases/[id]/metrics', 'databases/[id]/events', 'databases/[id]/queries', 'databases/[id]/replication-slots', 'databases/[id]/logs', 'databases/[id]/extensions', 'databases/[id]/replicas', 'databases/[id]/dr-copy', 'databases/[id]/network', 'databases/recovery-certificate', 'databases/[id]/backups/encryption-key', 'databases/[id]/backups/access', 'databases/[id]/publications', 'databases/[id]/subscriptions', 'databases/[id]/subscriptions/preflight', 'databases/[id]/subscriptions/verify', 'databases/[id]/subscriptions/verify/[verificationId]', 'databases/[id]/subscriptions/sync-sequences', 'databases/[id]/apply-config', 'databases/[id]/maintenance/apply', 'databases/[id]/maintenance/defer', 'databases/[id]/query', 'databases/[id]/branches', 'databases/[id]/branches/[branchId]', 'databases/[id]/branches/[branchId]/reset', 'databases/[id]/roles', 'databases/[id]/roles/[roleName]', 'databases/[id]/parameters', 'databases/[id]/pooler', 'databases/[id]/rotation', 'databases/[id]/rotation/rotate', 'databases/[id]/rotation/migrate', 'databases/[id]/data/[table]', 'databases/[id]/rpc/[fn]'] },
27
27
  { name: 'redis', aliases: ['cache'], product: 'cache', summary: 'Managed Redis (HA)', subs: ['apply-config', 'ls', 'create', 'rm', 'rename', 'resize', 'url', 'connect', 'metrics', 'backups', 'restore', 'dr-copy', 'network', 'password', 'maintenance'], endpoints: ['redis/[id]/apply-config', 'redis/[id]/maintenance/defer', 'redis/[id]/password', 'redis', 'redis/[id]', 'redis/[id]/connection', 'redis/[id]/backups', 'redis/[id]/restore', 'redis/[id]/metrics', 'redis/[id]/dr-copy', 'redis/[id]/network'] },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koigrid",
3
- "version": "0.20.0",
3
+ "version": "0.22.0",
4
4
  "description": "koigrid CLI — deploy apps, databases, redis, storage and more from your terminal (or your AI agent).",
5
5
  "bin": {
6
6
  "koigrid": "dist/index.js"