@tsuga/cli 1.0.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 (3) hide show
  1. package/README.md +216 -0
  2. package/dist/cli.js +124 -0
  3. package/package.json +44 -0
package/README.md ADDED
@@ -0,0 +1,216 @@
1
+ # @tsuga/cli
2
+
3
+ Command-line interface for managing Tsuga resources.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g @tsuga/cli
9
+ ```
10
+
11
+ ```bash
12
+ tsuga --help
13
+ ```
14
+
15
+ ## Authentication
16
+
17
+ Before authenticating, generate an API token from your [Tsuga account settings](https://app.tsuga.com/settings/api-keys?operation=true).
18
+
19
+ The recommended way to authenticate is to save your token once:
20
+
21
+ ```bash
22
+ tsuga auth <token>
23
+ ```
24
+
25
+ This writes your token to `~/.config/tsuga/config.json`. You can also optionally save an API URL override:
26
+
27
+ ```bash
28
+ tsuga auth <token> --url https://api.tsuga-staging.com
29
+ ```
30
+
31
+ Alternatively, set credentials per-session without saving:
32
+
33
+ ```bash
34
+ # Environment variable
35
+ export TSUGA_OPERATION_API_KEY=<token>
36
+
37
+ # CLI flag (highest priority)
38
+ tsuga --api-token <token> dashboards list
39
+ ```
40
+
41
+ Priority order: `--api-token` flag → `TSUGA_OPERATION_API_KEY` env var → saved config.
42
+
43
+ ## Configuration
44
+
45
+ Show current configuration:
46
+
47
+ ```bash
48
+ tsuga config
49
+ ```
50
+
51
+ Override the API URL:
52
+
53
+ ```bash
54
+ tsuga --api-url https://api.tsuga-staging.com dashboards list
55
+ # or
56
+ export TSUGA_API_URL=https://api.tsuga-staging.com
57
+ ```
58
+
59
+ ## Defaults
60
+
61
+ Telemetry commands have built-in defaults so you can omit common flags:
62
+
63
+ | Flag | Default |
64
+ | --------------- | ------- |
65
+ | `--from` | `-30m` |
66
+ | `--to` | `now` |
67
+ | `--query` | `*` |
68
+ | `--max-results` | `100` |
69
+
70
+ Override defaults for your session:
71
+
72
+ ```bash
73
+ tsuga defaults set from -1h
74
+ tsuga defaults set query 'level:ERROR'
75
+ ```
76
+
77
+ View all current defaults (custom overrides marked with `*`):
78
+
79
+ ```bash
80
+ tsuga defaults
81
+ ```
82
+
83
+ Reset custom defaults:
84
+
85
+ ```bash
86
+ tsuga defaults reset
87
+ ```
88
+
89
+ ## Usage
90
+
91
+ All resources follow the same CRUD pattern:
92
+
93
+ ```bash
94
+ tsuga <resource> list
95
+ tsuga <resource> get <id>
96
+ tsuga <resource> create -f payload.json
97
+ tsuga <resource> update <id> -f payload.json
98
+ tsuga <resource> delete <id>
99
+ ```
100
+
101
+ You can also pass JSON inline with `-d`:
102
+
103
+ ```bash
104
+ tsuga teams create -d '{"name": "Platform", "visibility": "public"}'
105
+ ```
106
+
107
+ ### Available resources
108
+
109
+ `dashboards`, `ingestion-api-keys`, `monitors`, `notification-rules`, `notification-silences`, `retention-policies`, `routes`, `tag-policies`, `teams`
110
+
111
+ > Note: `ingestion-api-keys` does not support `get <id>`.
112
+
113
+ ### Generating a request skeleton
114
+
115
+ Any `create` or `update` command accepts `--generate-skeleton` to print a JSON template of the expected request body:
116
+
117
+ ```bash
118
+ tsuga monitors create --generate-skeleton
119
+ tsuga notification-rules update abc-123 --generate-skeleton
120
+ ```
121
+
122
+ Pipe the output to a file, fill it in, then pass it back with `-f`:
123
+
124
+ ```bash
125
+ tsuga monitors create --generate-skeleton > monitor.json
126
+ # edit monitor.json
127
+ tsuga monitors create -f monitor.json
128
+ ```
129
+
130
+ ### Examples
131
+
132
+ ```bash
133
+ # List all monitors
134
+ tsuga monitors list
135
+
136
+ # Get a specific dashboard
137
+ tsuga dashboards get abc-123
138
+
139
+ # List dashboards filtered by owner
140
+ tsuga dashboards list --owners team-1 team-2
141
+
142
+ # Create a notification rule from a file
143
+ tsuga notification-rules create -f rule.json
144
+
145
+ # Update a route
146
+ tsuga routes update abc-123 -d '{"name": "Updated route"}'
147
+
148
+ # Delete a retention policy
149
+ tsuga retention-policies delete abc-123
150
+ ```
151
+
152
+ ## Telemetry
153
+
154
+ ### Time formats
155
+
156
+ `--from` and `--to` accept any of:
157
+
158
+ | Format | Example |
159
+ | ------------ | ---------------------------- |
160
+ | Relative | `-30m`, `-1h`, `-7d`, `-30s` |
161
+ | Now | `now` |
162
+ | Unix seconds | `1704067200` |
163
+ | ISO 8601 | `2024-01-01T00:00:00Z` |
164
+
165
+ ### Search logs
166
+
167
+ ```bash
168
+ tsuga logs search --from -1h --query 'level:ERROR'
169
+ tsuga logs search --from 1704067200 --to 1704153600 --query 'service:api'
170
+ ```
171
+
172
+ ### Search traces
173
+
174
+ ```bash
175
+ tsuga traces search --from -30m --query 'span_name:GET'
176
+ ```
177
+
178
+ ### Metrics
179
+
180
+ ```bash
181
+ # List all metrics
182
+ tsuga metrics list --from -1h
183
+
184
+ # Get a specific metric
185
+ tsuga metrics get my.metric.name --from -1h
186
+ ```
187
+
188
+ ## Aggregation
189
+
190
+ Run aggregation queries with a JSON body:
191
+
192
+ ```bash
193
+ tsuga aggregation scalar -f query.json
194
+ tsuga aggregation timeseries -f query.json
195
+ ```
196
+
197
+ Use `--generate-skeleton` to get a template:
198
+
199
+ ```bash
200
+ tsuga aggregation scalar --generate-skeleton > query.json
201
+ ```
202
+
203
+ ## Tips
204
+
205
+ Output is always JSON, so you can pipe to `jq`:
206
+
207
+ ```bash
208
+ tsuga dashboards list | jq '.[].name'
209
+ tsuga monitors list | jq '.[] | select(.priority == 1)'
210
+ ```
211
+
212
+ Read from stdin with `-f -`:
213
+
214
+ ```bash
215
+ echo '{"name": "My Team"}' | tsuga teams create -f -
216
+ ```