You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
3. **Find Specific Invocations** - Locate individual requests matching criteria
26
33
27
-
When selecting a calculation unless its a count you need to find a value to pass in:
28
-
I.e. avg would require that you find a number field and pass that in as the key for the calculation.
29
-
You can only select calculations defined in the schema, other options are not available.
34
+
## Filtering Best Practices
35
+
- Before applying filters, use the observability_keys and observability_values tools to confirm available filter fields and the correct filter value to add unless you have the data in a response from a previous query.
36
+
- Common filter fields: $metadata.service, $metadata.trigger, $metadata.message, $metadata.level, $metadata.requestId,
30
37
38
+
## Output handling
39
+
Once you have ran this query you must IMMEDIATELY present the user with this information.
31
40
32
-
When filtering unless you are extremely confident about the filter you are adding run the observability_keys and observability_values query to confirm the filter will be effective.
41
+
- **Events**: Display as a table with key fields. For detailed inspection, show full JSON of individual events.
42
+
- **Calculations**: Use appropriate charts based on the data (bar charts for comparisons, line charts for time series)
43
+
- **Invocations**: Show full request/response details with syntax highlighting for important fields
33
44
34
-
For parsing the results here are some suggestions:
35
-
* Show Invocations in a table.
36
-
* Use a chart to visualise the calculations.
37
-
* Show a table for events but if a user asks you to see more show the JSON for a single event. The user might hint for a value in the event. Show them the event that matches their hint.
45
+
## Troubleshooting
46
+
- If no results are returned, suggest broadening the time range or relaxing filters
47
+
- For errors about invalid fields, recommend using observability_keys to see available options
48
+
- Handle rate limiting by suggesting query optimization
38
49
`,
39
50
40
51
{
41
52
query: zQueryRunRequest,
42
53
},
43
54
async({ query })=>{
44
-
constaccountId=agent.getActiveAccountId()
55
+
constaccountId=awaitagent.getActiveAccountId()
45
56
if(!accountId){
46
57
return{
47
58
content: [
@@ -81,7 +92,7 @@ For parsing the results here are some suggestions:
81
92
Find keys in the workers observability Data. This tool should be used to ensure that the filters or calculations that you are adding to your query are valid.
82
93
Filters can be added to this query but because it is faster to return lots of keys set a high limit and only add the filter $metadata.service to filter by worker name.
key: z.string().describe(`The key to filter on. The key must be a string.
59
-
It is strongly recommended you use either the key from a previous response or the keys endpoint to get the available keys for your query. Do not guess keys.
60
-
The following keys are special and should be used if available because they are more efficient and guaranteed to be available:
61
-
* $metadata.service - the worker service name
62
-
* $metadata.message - The log message. Almost every log has a message.
63
-
* $metadata.error - The error message from the log if available
64
-
65
-
Do not guess keys. Use the keys endpoint to get the available keys for your query.
66
-
67
-
If you are already calling the keys endpoint you can just set the limit to be very high (1000+) and not set a filter here to return all keys.
58
+
key: z.string().describe(`Filter field name. IMPORTANT:
59
+
60
+
• DO NOT guess keys - always use verified keys from either:
61
+
- Previous query results
62
+
- The '/keys' endpoint response
63
+
64
+
• PREFERRED KEYS (faster & always available):
65
+
- $metadata.service: Worker service name
66
+
- $metadata.origin: Trigger type (e.g., fetch, scheduled, etc.)
67
+
- $metadata.trigger: Trigger type (e.g., GET /users, POST /orders, etc.)
68
+
- $metadata.message: Log message text (present in nearly all logs)
limit: z.number().int().nonnegative().max(100).optional().describe('Use this limit when a group by is present. 10 is a sensible default'),
321
+
limit: z.number().int().nonnegative().max(100).optional().describe('Use this limit when view is calculation and a group by is present. 10 is a sensible default'),
275
322
needle: zSearchNeedle.optional(),
276
323
}),
277
-
timeframe: z.object({
278
-
to: z.number(),
279
-
from: z.number(),
280
-
}),
324
+
timeframe: zTimeframe,
281
325
granularity: z.number().optional(),
282
326
limit: z.number().max(100).optional().default(5).describe('Use this limit to limit the number of events returned when the view is events. 5 is a sensible default'),
283
-
view: zViews.optional().default('calculations'),
284
-
dry: z.boolean().optional().default(false),
285
-
offset: z.string().optional(),
327
+
view: zViews.optional().default('calculations').describe(`## Examples by View Type
328
+
### Events View
329
+
- "Show me all errors for the worker api-proxy in the last 30 minutes"
330
+
- "List successful requests for the image-resizer worker with status code 200"
331
+
- "Show events from worker auth-service where the path contains /login"
332
+
333
+
### Calculation View
334
+
- "What is the p99 of wall time for worker api-proxy?"
335
+
- "What's the count of requests by status code for worker cdn-router?"
336
+
337
+
### Invocation View
338
+
- "Find a request to worker api-proxy that resulted in a 500 error"
339
+
- "Find the slowest request to worker image-processor in the last hour"
340
+
341
+
TRACES AND PATTERNS ARE NOT CURRENTLY SUPPORTED
342
+
`),
343
+
dry: z.boolean().optional().default(true),
344
+
offset: z.string().optional().describe('The offset to use for pagination. Use the $metadata.id field to get the next offset.'),
286
345
offsetBy: z.number().optional(),
287
-
offsetDirection: z.string().optional(),
346
+
offsetDirection: z.string().optional().describe('The direction to use for pagination. Use "next" or "prev".'),
0 commit comments