How to restrict alerts to a specific environment
I've set up alerts with a slack webhook, but I cannot figure out how to restrict them to a specific environment.
For example here is my alert query:
SELECT
created_at,
attributes->>'deployment_environment',
http_response_status_code,
trace_id
FROM records
WHERE
level = 'error'
And attributes->>'deployment_environment' always comes back null on alerts. If it had a value, I could add a WHERE clause, e.g. to filter to production.
The issue might be more general. Does this SQL filter ever work:
attributes->>'deployment_environment' = 'production'
deployment_environment is a column, just use that instead of attributes->>'deployment_environment'
deployment_environmentis a column, just use that instead ofattributes->>'deployment_environment'
In the SQL Search UI, when I add a WHERE condition for deployment_environment="development", I get
Error: invalid query: No column named `development`.
With an AI suggested fix:
Assuming deployment_environment does exist, then it could be good to include at:
https://github.com/pydantic/logfire/blob/e9c13335653db54adcc83d0832df63db0823dfd7/docs/guides/web-ui/explore.md?plain=1#L29-L62
And in the field guide (although it might be in the part of the hidden menu, note separate UI bug):
These are all good points, thank you.
Try: deployment_environment = 'development'
Okay both of the following work, so the double quotes were the issue:
deployment_environment = 'development'
deployment_environment='development'
Also noting deployment_environment doesn't show up in the SQL editor autocomplete:
All good on my end regarding the SQL condition upon environment. I will let the team decide whether to close this issue now or use it to track the ancillary issues.