Skip to content

Commit 2283a67

Browse files
committed
Update Advanced Search documentation for v0.8.3
- Removed outdated warnings about POST requests not working - Added comprehensive examples for POST request usage - Updated error handling examples to reflect working POST functionality - Documented Darktrace 6.1+ compatibility for POST requests - Updated parameter documentation for post_request flag
1 parent 6057ea3 commit 2283a67

1 file changed

Lines changed: 50 additions & 29 deletions

File tree

docs/modules/advanced_search.md

Lines changed: 50 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
The Advanced Search module provides access to Darktrace's advanced search functionality for querying logs and events.
44

5-
## ⚠️ Known Issues
5+
## ✅ POST Request Support (v0.8.3+)
66

7-
**POST Requests Not Supported**: POST requests to the Advanced Search API are currently not working due to unresolved authentication signature calculation issues. The Darktrace API documentation specifies that POST parameters should be included in the signature calculation, but multiple implementation attempts following the official documentation have resulted in "API SIGNATURE ERROR" responses.
7+
**RESOLVED**: POST requests to the Advanced Search API now work correctly! This was resolved in v0.8.3 by fixing JSON formatting inconsistencies in the authentication system.
88

9-
**Workaround**: Use GET requests for Advanced Search queries, which work correctly and support all the same functionality. The SDK automatically defaults to GET requests.
9+
- **Darktrace 6.1+**: POST requests are recommended for advanced queries
10+
- **Earlier versions**: GET requests continue to work as before
11+
- **Both methods supported**: You can choose between GET and POST based on your needs
1012

1113
## Initialization
1214

@@ -30,22 +32,45 @@ advanced_search = client.advanced_search
3032
Perform advanced search queries on Darktrace logs and events.
3133

3234
```python
33-
# Basic search query
35+
# Basic search query structure
3436
query = {
37+
"search": "@type:\"ssl\" AND @fields.dest_port:\"443\"",
38+
"fields": [],
3539
"offset": 0,
36-
"count": 100,
37-
"query": "*",
38-
"timeframe": "1 hour"
40+
"timeframe": "3600" # 1 hour in seconds
3941
}
42+
43+
# GET request (traditional method, works with all Darktrace versions)
4044
results = advanced_search.search(query)
45+
# or explicitly
46+
results = advanced_search.search(query, post_request=False)
4147

42-
# Search with POST request (not recommended - will raise NotImplementedError)
43-
try:
44-
results = advanced_search.search(query, post_request=True)
45-
except NotImplementedError as e:
46-
print(f"POST not supported: {e}")
47-
# Use GET instead
48-
results = advanced_search.search(query, post_request=False)
48+
# POST request (recommended for Darktrace 6.1+)
49+
results = advanced_search.search(query, post_request=True)
50+
```
51+
52+
#### Advanced Query Examples
53+
54+
```python
55+
# Search for SSL connections with custom timeframe
56+
ssl_query = {
57+
"search": "@type:\"ssl\" AND @fields.dest_port:\"443\"",
58+
"fields": ["@fields.source_ip", "@fields.dest_ip", "@fields.cipher"],
59+
"offset": 0,
60+
"timeframe": "7200" # 2 hours
61+
}
62+
results = advanced_search.search(ssl_query, post_request=True)
63+
64+
# Search with custom time range
65+
custom_time_query = {
66+
"search": "@type:\"conn\" AND @fields.proto:\"tcp\"",
67+
"fields": [],
68+
"offset": 0,
69+
"timeframe": "custom",
70+
"from": "2025-07-01T09:00:00",
71+
"to": "2025-07-01T10:00:00"
72+
}
73+
results = advanced_search.search(custom_time_query, post_request=True)
4974
```
5075

5176
#### Parameters
@@ -170,19 +195,19 @@ print(f"Graph data points: {len(graph_data.get('data', []))}")
170195

171196
```python
172197
try:
173-
results = client.advanced_search.search(query)
174-
except NotImplementedError as e:
175-
print(f"Feature not supported: {e}")
198+
results = client.advanced_search.search(query, post_request=True)
199+
# Process the data
176200
except requests.exceptions.HTTPError as e:
177-
print(f"HTTP error: {e}")
201+
print(f"HTTP error occurred: {e}")
178202
except Exception as e:
179-
print(f"Unexpected error: {e}")
203+
print(f"An error occurred: {e}")
180204
```
181205

182206
## Notes
183207

184208
- All queries are automatically base64-encoded before being sent to the API
185-
- GET requests are the recommended method due to POST authentication issues
209+
- **POST requests now supported** (v0.8.3+) for Darktrace 6.1+ installations
210+
- **GET requests continue to work** for all Darktrace versions
186211
- Time intervals for graphs are specified in seconds
187212
- Query syntax follows Darktrace's advanced search format
188213

@@ -200,11 +225,11 @@ query = {
200225
"time": {"user_interval": 0}
201226
}
202227

203-
# Execute search (GET request - recommended)
228+
# Execute search (GET request - traditional method)
204229
results = advanced_search.search(query)
205230

206-
# POST request (currently not supported - will raise NotImplementedError)
207-
# results = advanced_search.search(query, post_request=True)
231+
# Execute search (POST request - recommended for Darktrace 6.1+)
232+
results = advanced_search.search(query, post_request=True)
208233
```
209234

210235
#### Parameters
@@ -215,7 +240,7 @@ results = advanced_search.search(query)
215240
- `offset` (int): Starting offset for pagination
216241
- `timeframe` (str): Time range in seconds
217242
- `time` (dict): Time configuration
218-
- `post_request` (bool, optional): If True, attempts POST method (currently not supported)
243+
- `post_request` (bool, optional): If True, uses POST method (supported in v0.8.3+)
219244

220245
#### Response
221246

@@ -312,12 +337,8 @@ for bucket in analysis['aggregations']['terms']['buckets'][:5]:
312337

313338
```python
314339
try:
315-
results = client.advanced_search.search(query)
340+
results = client.advanced_search.search(query, post_request=True)
316341
# Process the data
317-
except NotImplementedError as e:
318-
print(f"POST request not supported: {e}")
319-
# Use GET request instead
320-
results = client.advanced_search.search(query, post_request=False)
321342
except requests.exceptions.HTTPError as e:
322343
print(f"HTTP error occurred: {e}")
323344
except Exception as e:

0 commit comments

Comments
 (0)