我想从sentry.io 检索问题
以下代码将问题的第一页返回给我
import json
import requests
url = "https://sentry.io/api/0/projects/my-account/my-project/issues/"
res = requests.get(url, headers={"Authorization": "Bearer <token here>")
issues = json.loads(res.text)
我正在努力使用";查询";在他们的(简要(文件中提到:https://docs.sentry.io/api/events/list-a-projects-issues/
查询(字符串(
可选的Sentry结构化搜索查询。如果没有提供隐含的";是:未解决的";假设。
问题:我将如何使用query
来过滤例如";"环境";等于";生产";?
我被文档误导了。它实际上相当直接:
import json
import requests
url = "https://sentry.io/api/0/projects/my-account/my-project/issues/"
query_str = "environment=production"
res = requests.get(f"{url}?{query_str}", headers={"Authorization": "Bearer <token here>")
issues = json.loads(res.text)
使用当前的解决方案,我也遇到了与我在哨兵仪表板上看到的不同数量的问题,但是我通过查询env
而不是environment
,只进行了很小的更正就解决了这个问题,比如:
import json
import requests
url = "https://sentry.io/api/0/projects/my-account/my-project/issues/"
query_str = "env=production" # depends on how you name the env prod/production
res = requests.get(f"{url}?{query_str}", headers={"Authorization": "Bearer <token here>")
issues = json.loads(res.text)