@saptools/cf-events 0.1.4 → 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.
- package/README.md +31 -29
- package/dist/cli.js +253 -37
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +63 -15
- package/dist/index.js +244 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
# ☁️ `@saptools/cf-events`
|
|
4
4
|
|
|
5
|
-
**Inspect SAP BTP Cloud Foundry application audit events and detect active SSH/debug sessions from the command line.**
|
|
5
|
+
**Inspect SAP BTP Cloud Foundry application and space audit events and detect active SSH/debug sessions from the command line.**
|
|
6
6
|
|
|
7
|
-
Point it at a `region/org/space/app`
|
|
7
|
+
Point it at a `region/org/space/app`, `region/org/space`, or a bare app name and instantly answer: "what just happened?", "is anyone SSH'd in right now?", or "why did it crash?".
|
|
8
8
|
|
|
9
9
|
[](https://www.npmjs.com/package/@saptools/cf-events)
|
|
10
10
|
[](./LICENSE)
|
|
@@ -20,16 +20,15 @@ Point it at a `region/org/space/app` (or a bare app name) and instantly answer:
|
|
|
20
20
|
|
|
21
21
|
## ✨ Features
|
|
22
22
|
|
|
23
|
-
- 📜 **Audit event inspection** — list recent `audit.app.*` events
|
|
23
|
+
- 📜 **Audit event inspection** — list recent `audit.app.*` events for one app or all apps in a space
|
|
24
24
|
- 🔐 **SSH & debug session detection** — surface authorized sessions + denied attempts; infer "likely active" ones from recent `ssh-authorized` events (CF has no live session or close events)
|
|
25
|
-
- 💥 **Crash summaries** — count, last crash time/reason/exit code, and per-instance detail
|
|
25
|
+
- 💥 **Crash summaries** — count, last crash time/reason/exit code, and per-instance detail for an app or grouped by app across a space
|
|
26
26
|
- ❤️ **One-glance status** — requested state, per-instance CPU/mem/uptime, SSH flag, and the most recent audit event
|
|
27
27
|
- 👀 **Live watch** — poll `/v3/audit_events` on an interval and stream new events (Ctrl+C to stop)
|
|
28
|
-
- 🧭 **Smart selectors** — full `region/org/space/app` or bare app
|
|
29
|
-
- 🔄 **Reuses cf-sync** — topology snapshot + current-target helpers from [`@saptools/cf-sync`](https://www.npmjs.com/package/@saptools/cf-sync)
|
|
28
|
+
- 🧭 **Smart selectors** — full app selectors (`region/org/space/app`), space selectors (`region/org/space`), or bare app names resolved from the current `cf target`
|
|
30
29
|
- 🧪 **Isolated sessions** — every invocation uses a fresh ephemeral `CF_HOME`; never touches your interactive login
|
|
31
30
|
- 🧩 **CLI + typed library** — full TypeScript exports for `CfEventsRuntime`, parsers, formatters, and types
|
|
32
|
-
- 🪶 **Zero daemon, tiny deps** — commander
|
|
31
|
+
- 🪶 **Zero daemon, tiny deps** — commander only
|
|
33
32
|
|
|
34
33
|
---
|
|
35
34
|
|
|
@@ -59,12 +58,10 @@ npm install @saptools/cf-events
|
|
|
59
58
|
export SAP_EMAIL="you@company.com"
|
|
60
59
|
export SAP_PASSWORD="your-sap-password"
|
|
61
60
|
|
|
62
|
-
# 2.
|
|
63
|
-
cf-sync sync --only ap10 # or cf-sync space ap10 my-org dev
|
|
64
|
-
|
|
65
|
-
# 3. Inspect events
|
|
61
|
+
# 2. Inspect events
|
|
66
62
|
cf-events events orders-srv
|
|
67
63
|
cf-events events ap10/my-org/dev/orders-srv --limit 100 --since 6h
|
|
64
|
+
cf-events events ap10/my-org/dev --limit 200 --since 6h
|
|
68
65
|
|
|
69
66
|
# 4. Check for active SSH/debug sessions
|
|
70
67
|
cf-events ssh-status orders-srv --since 7d
|
|
@@ -79,16 +76,17 @@ cf-events status orders-srv
|
|
|
79
76
|
cf-events watch orders-srv --type crash
|
|
80
77
|
```
|
|
81
78
|
|
|
82
|
-
|
|
79
|
+
Bare app names use the current `cf target` for org/space/API context. Explicit app and space selectors do not require a topology snapshot.
|
|
83
80
|
|
|
84
81
|
---
|
|
85
82
|
|
|
86
83
|
## 🧰 CLI
|
|
87
84
|
|
|
88
|
-
All commands accept a single positional **selector
|
|
85
|
+
All commands accept a single positional **selector**. `events`, `watch`, and `crashes` accept app or space selectors; `status` and `ssh-status` require an app selector.
|
|
89
86
|
|
|
90
|
-
-
|
|
91
|
-
-
|
|
87
|
+
- App path: `ap10/my-org/dev/orders-srv`
|
|
88
|
+
- Space path: `ap10/my-org/dev`
|
|
89
|
+
- Bare app name: `orders-srv` — resolved against the current `cf target`. Bare single-segment selectors are always app names, never spaces.
|
|
92
90
|
|
|
93
91
|
Common credential flags (all commands):
|
|
94
92
|
|
|
@@ -100,13 +98,14 @@ Common credential flags (all commands):
|
|
|
100
98
|
|
|
101
99
|
### `events <selector>`
|
|
102
100
|
|
|
103
|
-
List recent audit events for the app (deployments, restarts, scaling, crashes, SSH, routes, ...).
|
|
101
|
+
List recent audit events for the app or all apps in a space (deployments, restarts, scaling, crashes, SSH, routes, ...).
|
|
104
102
|
|
|
105
103
|
```bash
|
|
106
104
|
cf-events events ap10/my-org/dev/orders-srv
|
|
107
105
|
cf-events events orders-srv --limit 100 --since 6h
|
|
108
106
|
cf-events events orders-srv --type ssh --json
|
|
109
107
|
cf-events events orders-srv --type audit.app.start,audit.app.stop
|
|
108
|
+
cf-events events ap10/my-org/dev --type ssh --json
|
|
110
109
|
```
|
|
111
110
|
|
|
112
111
|
| Flag | Description |
|
|
@@ -133,11 +132,12 @@ cf-events ssh-status orders-srv --since 7d --json
|
|
|
133
132
|
|
|
134
133
|
### `crashes <selector>`
|
|
135
134
|
|
|
136
|
-
Count and detail recent crash events (both `audit.app.crash` and `audit.app.process.crash`).
|
|
135
|
+
Count and detail recent crash events for an app or grouped by target app across a space (both `audit.app.crash` and `audit.app.process.crash`).
|
|
137
136
|
|
|
138
137
|
```bash
|
|
139
138
|
cf-events crashes orders-srv
|
|
140
139
|
cf-events crashes orders-srv --since 24h --json
|
|
140
|
+
cf-events crashes ap10/my-org/dev --since 24h --json
|
|
141
141
|
```
|
|
142
142
|
|
|
143
143
|
| Flag | Description |
|
|
@@ -156,11 +156,12 @@ cf-events status orders-srv --json
|
|
|
156
156
|
|
|
157
157
|
### `watch <selector>`
|
|
158
158
|
|
|
159
|
-
Poll `/v3/audit_events` repeatedly and print (or emit NDJSON) fresh events as they arrive. Press Ctrl+C to stop.
|
|
159
|
+
Poll `/v3/audit_events` repeatedly for an app or space and print (or emit NDJSON) fresh events as they arrive. Press Ctrl+C to stop.
|
|
160
160
|
|
|
161
161
|
```bash
|
|
162
162
|
cf-events watch orders-srv
|
|
163
163
|
cf-events watch orders-srv --interval 30000 --type crash --lookback 5m
|
|
164
|
+
cf-events watch ap10/my-org/dev --lookback 5m --type crash --json
|
|
164
165
|
```
|
|
165
166
|
|
|
166
167
|
| Flag | Description |
|
|
@@ -172,24 +173,22 @@ cf-events watch orders-srv --interval 30000 --type crash --lookback 5m
|
|
|
172
173
|
|
|
173
174
|
---
|
|
174
175
|
|
|
175
|
-
## 📁 Prerequisites &
|
|
176
|
-
|
|
177
|
-
`cf-events` relies on a `cf-sync` snapshot at `~/.saptools/cf-structure.json` for bare-app-name resolution and validation of explicit paths.
|
|
176
|
+
## 📁 Prerequisites & Selector Resolution
|
|
178
177
|
|
|
179
|
-
|
|
180
|
-
- When you pass a bare app name, `cf-events` will also consult your current `cf target` (via `cf target` output) to build a full selector before validating against the snapshot.
|
|
181
|
-
- Pure `--json` + explicit full selectors still require the snapshot for safety.
|
|
178
|
+
`cf-events` uses direct CF CLI/API calls and an isolated throw-away `CF_HOME`; it does not read or validate a `cf-sync` snapshot.
|
|
182
179
|
|
|
183
|
-
|
|
180
|
+
- Explicit app selectors (`region/org/space/app`) and space selectors (`region/org/space`) use the built-in SAP BTP region-to-API map, then authenticate and target that org/space.
|
|
181
|
+
- Bare app names use your current interactive `cf target` only to discover API endpoint, org, and space, then resolve the app GUID inside the isolated session.
|
|
182
|
+
- Space-wide audit event queries use the Cloud Foundry v3 `space_guids` audit-event filter after resolving org and space GUIDs with `/v3/organizations?names=...` and `/v3/spaces?names=...&organization_guids=...`.
|
|
184
183
|
|
|
185
|
-
|
|
184
|
+
For JSON output, `events --json` returns the same raw audit-event array shape for app and space selectors. Space events include target, space, and organization references from the CF response. `watch --json` emits newline-delimited JSON events.
|
|
186
185
|
|
|
187
186
|
## ❓ FAQ
|
|
188
187
|
|
|
189
188
|
<details>
|
|
190
189
|
<summary><b>Do I need to run cf target first?</b></summary>
|
|
191
190
|
|
|
192
|
-
Not required
|
|
191
|
+
Not required for explicit selectors. Bare app names require a current `cf target` so `cf-events` can discover the API endpoint, org, and space.
|
|
193
192
|
|
|
194
193
|
</details>
|
|
195
194
|
|
|
@@ -217,7 +216,7 @@ Yes: `--type crash` or `--type ssh`. You can also pass comma-separated full type
|
|
|
217
216
|
<details>
|
|
218
217
|
<summary><b>Is the snapshot required even for JSON output?</b></summary>
|
|
219
218
|
|
|
220
|
-
|
|
219
|
+
No. `cf-events` does not read a snapshot. Explicit selectors are resolved with the region map and live CF API/CLI calls; bare app names use the current `cf target`.
|
|
221
220
|
|
|
222
221
|
</details>
|
|
223
222
|
|
|
@@ -239,11 +238,14 @@ pnpm --filter @saptools/cf-events check # cspell + lint + type + unit + e2e
|
|
|
239
238
|
|
|
240
239
|
E2E tests are fully fake-backed (no real CF or credentials needed).
|
|
241
240
|
|
|
241
|
+
## Changelog
|
|
242
|
+
|
|
243
|
+
See [CHANGELOG.md](./CHANGELOG.md).
|
|
244
|
+
|
|
242
245
|
---
|
|
243
246
|
|
|
244
247
|
## 🌐 Related
|
|
245
248
|
|
|
246
|
-
- 🗺️ [`@saptools/cf-sync`](https://www.npmjs.com/package/@saptools/cf-sync) — the topology snapshot and current-target helpers that power selector resolution
|
|
247
249
|
- 🔐 [`@saptools/cf-xsuaa`](https://www.npmjs.com/package/@saptools/cf-xsuaa)
|
|
248
250
|
- 🐛 [`@saptools/cf-debugger`](https://www.npmjs.com/package/@saptools/cf-debugger)
|
|
249
251
|
- Full toolbox: [saptools monorepo](https://github.com/dongitran/saptools)
|