Skip to content

Commit 1fcead9

Browse files
Merge pull request #654 from Teko012/add-event-post
feat(events): add event posting
2 parents 3040061 + f70d1b5 commit 1fcead9

8 files changed

Lines changed: 635 additions & 15 deletions

File tree

Cargo.lock

Lines changed: 14 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ jaq-json = { version = "2.0.1", features = ["serde"] }
170170

171171
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
172172
reqwest = { version = ">=0.13, <0.13.3", features = ["stream"] }
173+
gethostname = "1"
173174

174175
[dev-dependencies]
175176
mockito = "1"

docs/COMMANDS.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pup <domain> <subgroup> <action> [options] # Nested commands
3838
| static-analysis | custom-rulesets (get, update, delete), custom-rules (get, create, delete, revisions, revision) | src/commands/static_analysis.rs ||
3939
| downtime | list, get, cancel | src/commands/downtime.rs ||
4040
| tags | list, get, add, update, delete | src/commands/tags.rs ||
41-
| events | list, search, get | src/commands/events.rs ||
41+
| events | post, list, search, get | src/commands/events.rs ||
4242
| on-call | teams (CRUD, memberships) | src/commands/on_call.rs ||
4343
| audit-logs | list, search | src/commands/audit_logs.rs ||
4444
| api-keys | list, get, create, delete | src/commands/api_keys.rs ||
@@ -125,6 +125,7 @@ pup events search --query="@user.id:12345"
125125
pup <domain> create [--flags]
126126
pup <domain> update <id> [--flags]
127127
pup <domain> delete <id> [--yes]
128+
pup events post --tags="version:1,application:web" --no_host --type=my_apps --aggregation_key=application:web --alert_type=info "Something big happened!" "And let me tell you all about it here!"
128129
```
129130

130131
### Nested Commands
@@ -144,7 +145,7 @@ pup infrastructure hosts list
144145
- **dbm** - Database Monitoring query samples (samples search)
145146
- **traces** - APM spans metrics (list, get, create, update, delete)
146147
- **rum** - Real User Monitoring (apps, metrics, retention-filters, sessions)
147-
- **events** - Infrastructure events (list, search, get)
148+
- **events** - Infrastructure events (post, list, search, get)
148149
- **ddsql** - DDSQL queries and discovery (table, time-series, spec, schema)
149150
- **symdb** - Symbol Database queries (search scopes, probe locations)
150151

src/client.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,14 @@ static OAUTH_EXCLUDED_ENDPOINTS: &[EndpointRequirement] = &[
724724
path: "/api/ui/profiling/",
725725
method: "GET",
726726
},
727+
// Events intake (1)
728+
// Posting an event uses the V1 intake endpoint, which authenticates with the
729+
// API key and does not accept OAuth2 bearer tokens. Listing/getting events
730+
// (GET) is fine over OAuth, so only POST is excluded.
731+
EndpointRequirement {
732+
path: "/api/v1/events",
733+
method: "POST",
734+
},
727735
];
728736

729737
// ---------------------------------------------------------------------------
@@ -1288,6 +1296,13 @@ mod tests {
12881296
assert!(!requires_api_key_fallback("POST", "/api/v2/events/search"));
12891297
}
12901298

1299+
#[test]
1300+
fn test_fallback_for_events_post() {
1301+
// Posting an event (V1 intake) requires API keys; reading events does not.
1302+
assert!(requires_api_key_fallback("POST", "/api/v1/events"));
1303+
assert!(!requires_api_key_fallback("GET", "/api/v1/events"));
1304+
}
1305+
12911306
#[test]
12921307
fn test_no_fallback_for_standard_endpoints() {
12931308
assert!(!requires_api_key_fallback("GET", "/api/v1/monitor"));
@@ -1324,7 +1339,7 @@ mod tests {
13241339

13251340
#[test]
13261341
fn test_oauth_excluded_count() {
1327-
assert_eq!(OAUTH_EXCLUDED_ENDPOINTS.len(), 54);
1342+
assert_eq!(OAUTH_EXCLUDED_ENDPOINTS.len(), 55);
13281343
}
13291344

13301345
#[test]

0 commit comments

Comments
 (0)