@oneuptime/cli 14.0.102 → 14.0.104

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 (3) hide show
  1. package/README.md +109 -58
  2. package/build/dist/Index.js +113421 -85036
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,9 +1,18 @@
1
1
  # @oneuptime/cli
2
2
 
3
- Command-line interface for managing OneUptime resources. Supports every MCP-enabled resource (records with full CRUD operations, telemetry with list, create and count), named contexts for multiple environments, and flexible output formats.
3
+ Command-line interface for OneUptime. Every resource of the OneUptime REST API is a command, with a subcommand for every request the API takes for it: list, get, create, update, delete and count, the fields a resource has, and the dashboard's buttons such as acknowledge and resolve. People at a terminal get tables, and scripts and AI agents get JSON with `--json`.
4
4
 
5
5
  ## Installation
6
6
 
7
+ Every OneUptime serves an installer for the CLI at `/install/cli`. It asks your OneUptime for its version, and installs the CLI of the same version with npm:
8
+
9
+ ```bash
10
+ curl -fsSL https://oneuptime.com/install/cli -o install.sh
11
+ ONEUPTIME_URL=https://oneuptime.com bash install.sh
12
+ ```
13
+
14
+ On a self-hosted OneUptime, download it from your OneUptime's address, and give that address as `ONEUPTIME_URL`. Or install the CLI with npm yourself:
15
+
7
16
  ```bash
8
17
  npm install -g @oneuptime/cli
9
18
  oneuptime --version
@@ -26,14 +35,23 @@ npm install -g @oneuptime/cli@<your-oneuptime-version>
26
35
  oneuptime login <api-key> <instance-url>
27
36
  oneuptime login sk-your-api-key https://oneuptime.com
28
37
 
38
+ # Check that OneUptime takes the key, and see its project
39
+ oneuptime whoami --check
40
+
29
41
  # List incidents
30
42
  oneuptime incident list --limit 10
31
43
 
32
44
  # Get a single resource by ID
33
45
  oneuptime monitor get 550e8400-e29b-41d4-a716-446655440000
34
46
 
35
- # Create a resource
36
- oneuptime monitor create --data '{"name":"API Health","projectId":"..."}'
47
+ # Create a resource, a flag per field
48
+ oneuptime monitor create --name "API Health" --monitor-type Manual
49
+
50
+ # The fields a resource has, and the flags that set them
51
+ oneuptime monitor fields
52
+
53
+ # Acknowledge an incident, as the dashboard's button does
54
+ oneuptime incident acknowledge 550e8400-e29b-41d4-a716-446655440000
37
55
 
38
56
  # See all available resources
39
57
  oneuptime resources
@@ -75,31 +93,39 @@ oneuptime context delete old-context
75
93
  2. Environment variables: `ONEUPTIME_API_KEY` and `ONEUPTIME_URL`
76
94
  3. Current context from config file (`~/.oneuptime/config.json`)
77
95
 
96
+ `oneuptime whoami` shows what the next command will use without asking OneUptime. `oneuptime whoami --check` asks OneUptime: it shows the key's project, OneUptime's version and the CLI's, says what to install when the two differ, and exits with `2` when OneUptime refuses the key.
97
+
78
98
  ## Command Reference
79
99
 
80
100
  ### Authentication
81
101
 
82
- | Command | Description |
83
- | --------------------------------- | --------------------------------- |
84
- | `oneuptime login <api-key> <url>` | Authenticate and create a context |
85
- | `oneuptime context list` | List all contexts |
86
- | `oneuptime context use <name>` | Switch active context |
87
- | `oneuptime context current` | Show current context |
88
- | `oneuptime context delete <name>` | Remove a context |
89
- | `oneuptime whoami` | Show current auth info |
102
+ | Command | Description |
103
+ | --------------------------------- | -------------------------------------------------------- |
104
+ | `oneuptime login <api-key> <url>` | Authenticate and create a context |
105
+ | `oneuptime context list` | List all contexts |
106
+ | `oneuptime context use <name>` | Switch active context |
107
+ | `oneuptime context current` | Show current context |
108
+ | `oneuptime context delete <name>` | Remove a context |
109
+ | `oneuptime whoami` | Show current auth info; `--check` asks OneUptime as well |
90
110
 
91
111
  ### Resource Operations
92
112
 
93
- Every resource supports `list`, `create` and `count`. Records (monitors, incidents, teams and the like) also support `get`, `update` and `delete`; telemetry (logs, metrics, spans and the like) does not:
94
-
95
- | Subcommand | Description |
96
- | -------------------------------------- | -------------------------------------------- |
97
- | `<resource> list [options]` | List resources with filtering and pagination |
98
- | `<resource> get <id>` | Get a single resource by ID |
99
- | `<resource> create --data <json>` | Create a new resource |
100
- | `<resource> update <id> --data <json>` | Update an existing resource |
101
- | `<resource> delete <id>` | Delete a resource |
102
- | `<resource> count [--query <json>]` | Count resources |
113
+ A resource takes the subcommands the API takes for it: `list`, `get` and `count` to read it, and `create`, `update` and `delete` to change it. Most resources take all six. The ones OneUptime writes itself, such as an email log, are read only. `oneuptime <resource> --help` lists the subcommands a resource has:
114
+
115
+ | Subcommand | Description |
116
+ | -------------------------------------------- | ------------------------------------------------------------ |
117
+ | `<resource> list [options]` | List resources with filtering and pagination |
118
+ | `<resource> get <id>` | Get a single resource by ID |
119
+ | `<resource> create [--<field> <value>]` | Create a new resource, a flag per field |
120
+ | `<resource> update <id> [--<field> <value>]` | Update an existing resource |
121
+ | `<resource> delete <id>` | Delete a resource |
122
+ | `<resource> count [--query <json>]` | Count resources |
123
+ | `<resource> fields` | List its fields: what each is for, and the flag that sets it |
124
+ | `<resource> acknowledge <id>` | Acknowledge an incident, an alert, or an episode of either |
125
+ | `<resource> resolve <id>` | Resolve one |
126
+ | `<resource> start <id>` | Start a scheduled maintenance event |
127
+ | `<resource> end <id>` | End one |
128
+ | `<resource> add-note <id> --note <markdown>` | Add a note to any of those, `--public` for its status pages |
103
129
 
104
130
  ### List Options
105
131
 
@@ -107,18 +133,33 @@ Every resource supports `list`, `create` and `count`. Records (monitors, inciden
107
133
  --query <json> Filter criteria as JSON
108
134
  --limit <n> Maximum number of results (default: 10)
109
135
  --skip <n> Number of results to skip (default: 0)
110
- --sort <json> Sort order as JSON (e.g. '{"createdAt": -1}')
136
+ --sort <json> Sort order as JSON (e.g. '{"createdAt": "DESC"}')
137
+ --fields <names> The fields to return, separated by commas
138
+ --all Every record that matches, page after page (records only)
111
139
  -o, --output Output format: json, table, wide
140
+ --json The same as -o json
141
+ ```
142
+
143
+ ### Create and Update
144
+
145
+ `create` and `update` take a flag for each field the API takes: `--title <text>`, `--incident-severity-id <id>`, `--labels <ids>` (IDs separated by commas), `--is-visible-on-status-page [true|false]` (true when given alone), `--monitor-steps <json>`. `oneuptime <resource> create --help` lists them, and `oneuptime <resource> fields` says what each field is for. `--data <json>` and `--file <path>` give the fields as JSON instead, and flags go on top of them.
146
+
147
+ Where a field names a person by user ID, a second flag names them by email address: `--user-email` beside `--user-id`, `--owner-user-emails` beside `--owner-users`. The CLI finds the person among the members and invitees of the API key's project. A team member named by an address nobody in the project has is invited, as the dashboard's Invite does:
148
+
149
+ ```bash
150
+ oneuptime incident-user-owner create --incident-id <incident-id> --user-email alice@example.com
151
+ oneuptime team-member create --team-id <team-id> --user-email new-hire@example.com
112
152
  ```
113
153
 
114
154
  ### Utility Commands
115
155
 
116
- | Command | Description |
117
- | --------------------- | --------------------------------------------------------------- |
118
- | `oneuptime version` | Print CLI version |
119
- | `oneuptime whoami` | Show current authentication info |
120
- | `oneuptime resources` | List all available resource types |
121
- | `oneuptime deploy` | Record a deploy, or another change, for charts and OneUptime AI |
156
+ | Command | Description |
157
+ | ---------------------- | ------------------------------------------------------------------ |
158
+ | `oneuptime version` | Print CLI version |
159
+ | `oneuptime whoami` | Show current authentication info |
160
+ | `oneuptime resources` | List all available resource types |
161
+ | `oneuptime deploy` | Record a deploy, or another change, for charts and OneUptime AI |
162
+ | `oneuptime dbt upload` | Send a dbt project's artifacts to Data Observability after a build |
122
163
 
123
164
  `oneuptime deploy` writes with a telemetry ingestion key, not an API key:
124
165
 
@@ -128,6 +169,14 @@ ONEUPTIME_TELEMETRY_INGESTION_KEY=xxx \
128
169
  oneuptime deploy --service checkout --service-version 2.3.1 --commit "$GIT_SHA" --environment production
129
170
  ```
130
171
 
172
+ `oneuptime dbt upload` sends a dbt project's `manifest.json` and `run_results.json` after a build, with the same key:
173
+
174
+ ```bash
175
+ ONEUPTIME_URL=https://oneuptime.com \
176
+ ONEUPTIME_TELEMETRY_INGESTION_KEY=xxx \
177
+ oneuptime dbt upload --target-path target
178
+ ```
179
+
131
180
  ## Output Formats
132
181
 
133
182
  | Format | Description |
@@ -136,7 +185,7 @@ oneuptime deploy --service checkout --service-version 2.3.1 --commit "$GIT_SHA"
136
185
  | `json` | Raw JSON (default when piped) |
137
186
  | `wide` | Table with all columns shown |
138
187
 
139
- `-o` applies to `<resource> list`, `get`, `create`, `update` and `count`, as well as `oneuptime resources` and `oneuptime context list`, and can go anywhere on the command line. Any other value is rejected with an error.
188
+ Every command takes `-o` and `--json`, anywhere on the command line. `--json` is the same as `-o json`. Any other value of `-o` is rejected with an error. A command whose answer is a sentence, such as `delete` or `acknowledge`, prints the sentence unless JSON is asked for, and with JSON asked for, an error is one JSON object on standard error.
140
189
 
141
190
  ```bash
142
191
  # Explicit format
@@ -152,7 +201,7 @@ oneuptime incident list | jq '.[].title'
152
201
 
153
202
  ```bash
154
203
  # List incidents as JSON for scripting
155
- oneuptime incident list -o json --limit 100
204
+ oneuptime incident list --json --limit 100
156
205
 
157
206
  # Count resources with filter
158
207
  oneuptime incident count --query '{"currentIncidentStateId":"..."}'
@@ -164,14 +213,20 @@ oneuptime monitor create --file monitor.json
164
213
  ONEUPTIME_API_KEY=sk-xxx ONEUPTIME_URL=https://oneuptime.com oneuptime incident list
165
214
  ```
166
215
 
216
+ Every command exits with `0` when it worked, `1` when OneUptime refused it or a value is wrong, `2` when the API key is missing or refused, and `3` when the record is not there.
217
+
218
+ ## AI Agents
219
+
220
+ An agent that runs commands can work with OneUptime through the CLI instead of the MCP server. Give it the key in `ONEUPTIME_API_KEY`, and have it add `--json` to every command. `oneuptime resources --json` lists what it can work with, `oneuptime <resource> fields --json` a resource's fields and flags, and `oneuptime <resource> --help` its subcommands.
221
+
167
222
  ## Environment Variables
168
223
 
169
- | Variable | Description |
170
- | ----------------------------------- | ---------------------------------------------- |
171
- | `ONEUPTIME_API_KEY` | API key for authentication |
172
- | `ONEUPTIME_URL` | OneUptime instance URL |
173
- | `ONEUPTIME_TELEMETRY_INGESTION_KEY` | Telemetry ingestion key for `oneuptime deploy` |
174
- | `NO_COLOR` | Disable colored output |
224
+ | Variable | Description |
225
+ | ----------------------------------- | ------------------------------------------------------------------------- |
226
+ | `ONEUPTIME_API_KEY` | API key for authentication |
227
+ | `ONEUPTIME_URL` | OneUptime instance URL |
228
+ | `ONEUPTIME_TELEMETRY_INGESTION_KEY` | Telemetry ingestion key for `oneuptime deploy` and `oneuptime dbt upload` |
229
+ | `NO_COLOR` | Disable colored output |
175
230
 
176
231
  ## Configuration File
177
232
 
@@ -200,35 +255,29 @@ Output format and list size are not read from this file. Pass `-o` and `--limit`
200
255
  | `--url <url>` | Override instance URL for this command |
201
256
  | `--context <name>` | Use a specific context for this command |
202
257
  | `-o, --output <format>` | Output format: json, table, wide |
258
+ | `--json` | The same as `-o json` |
203
259
  | `--no-color` | Disable colored output |
204
260
 
205
261
  ## Supported Resources
206
262
 
207
- Every resource is a command: `oneuptime <resource> <subcommand>`. Resources are discovered from the OneUptime models that have MCP enabled, and `oneuptime resources` lists the ones your version has (`--type database` for records, `--type analytics` for telemetry).
263
+ Every resource of the OneUptime REST API is a command: `oneuptime <resource> <subcommand>`, 450 and more of them. They are worked out from OneUptime's models by the rule the API documents itself by, so a resource OneUptime gains is a command of the CLI of the same version. `oneuptime resources` lists the ones your version has (`--type database` for records, `--type analytics` for telemetry).
208
264
 
209
- Records take `list`, `get`, `create`, `update`, `delete` and `count`:
265
+ Some of them, by area:
210
266
 
211
- | Area | Commands |
212
- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
213
- | Monitoring | `monitor`, `monitor-status`, `monitor-status-event` |
214
- | Incidents | `incident`, `incident-state`, `incident-severity`, `incident-state-timeline`, `incident-public-note`, `incident-internal-note`, `incident-alert`, `postmortem-status` |
215
- | Alerts | `alert`, `alert-state`, `alert-severity`, `alert-state-timeline`, `alert-internal-note` |
216
- | Status pages | `status-page`, `status-page-announcement` |
217
- | Scheduled maintenance | `scheduled-maintenance-event`, `scheduled-maintenance-state`, `scheduled-maintenance-state-timeline` |
218
- | Teams and on-call | `team`, `on-call-policy` |
219
- | Security | `security-case`, `security-case-evidence`, `security-case-note`, `security-case-priority`, `security-case-status`, `security-case-task`, `security-detection`, `security-playbook` |
220
- | Data security | `data-store`, `data-store-finding`, `data-store-access-entry`, `data-security-identity`, `data-flow`, `data-security-issue`, `data-security-scan`, `custom-data-type`, `check-setting`, `residency-rule`, `data-security-setting` |
221
- | Labels | `label` |
267
+ | Area | Commands |
268
+ | --------------------- | ----------------------------------------------------------------------------------------------------------------------- |
269
+ | Monitoring | `monitor`, `monitor-status`, `monitor-group`, `probe` |
270
+ | Incidents | `incident`, `incident-severity`, `incident-state`, `incident-internal-note`, `incident-public-note`, `incident-episode` |
271
+ | Alerts | `alert`, `alert-severity`, `alert-state`, `alert-internal-note`, `alert-episode` |
272
+ | Status pages | `status-page`, `status-page-announcement`, `status-page-subscriber` |
273
+ | Scheduled maintenance | `scheduled-maintenance-event`, `scheduled-maintenance-state` |
274
+ | On-call | `on-call-policy`, `on-call-policy-schedule`, `escalation-rule` |
275
+ | Teams and access | `team`, `team-member`, `label`, `api-key` |
276
+ | Infrastructure | `host`, `kubernetes-cluster`, `network-device`, `service` |
277
+ | Automation | `workflow`, `runbook`, `dashboard` |
278
+ | Telemetry | `log`, `metric`, `span`, `exception-instance`, `monitor-log`, `audit-log` |
222
279
 
223
- Telemetry takes `list`, `create` and `count`:
224
-
225
- | Area | Commands |
226
- | ---------------- | ------------------------------------------------------------ |
227
- | Observability | `log`, `metric`, `span`, `exception-instance`, `monitor-log` |
228
- | Security | `security-event`, `threat-intel-indicator` |
229
- | Changes and cost | `change-event`, `kubernetes-cost-allocation` |
230
-
231
- As more models are MCP-enabled in OneUptime, they become available in the CLI as well. The [command reference](https://oneuptime.com/docs/cli/command-reference) describes every command and its options.
280
+ The [command reference](https://oneuptime.com/docs/cli/command-reference) describes every command and its options.
232
281
 
233
282
  ## Development
234
283
 
@@ -242,6 +291,8 @@ npm run build # Bundle into build/dist/Index.js, the file npm publishe
242
291
  npm run smoke-test # Pack, install as a customer does, and run it
243
292
  ```
244
293
 
294
+ The tests never touch your own `~/.oneuptime`: each test file runs in a throwaway home of its own (`Tests/Setup`), and a run fails if your `~/.oneuptime` changed while it ran.
295
+
245
296
  ## License
246
297
 
247
298
  Apache-2.0