Created
February 20, 2019 06:18
-
-
Save varver/b83960310721a201ee0b1f4942416c03 to your computer and use it in GitHub Desktop.
Fetch issues from sentry with highest frequency in 14 days
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### READ ME :::) | |
# You can fetch issues with highest frequeny from sentry using this script. | |
# It will fetch top 100 issues and some meta information related to that issue. | |
# And write everything is a csv file separated with "~" | |
# you can change environment=production in the URL used to make api call below. Please refer your project to see environment options available. | |
#### IMPO :: please change token and your organization URL/Project_Name (org_and_project) below : | |
import json | |
import requests | |
import csv | |
import os | |
############################################################ | |
token = "hfdsgfhdsgfhjdsgfhjdsgfhdsfhjsdgfhjdsfhggfsdhfgdshj" | |
org_and_project = "abccorp/project_name" | |
########################################################## | |
# curl -H 'Authorization: Bearer hfdsgfhdsgfhjdsgfhjdsgfhdsfhjsdgfhjdsfhggfsdhfgdshj' "https://sentry.io/api/0/projects/abccorp/project_name/issues/?environment=production&sort=freq&statsPeriod=14d" > output.json | |
url = 'https://sentry.io/api/0/projects/+ org_and_project +/issues/?environment=production&sort=freq&statsPeriod=14d' | |
headers = {'Authorization': 'Bearer ' + token } | |
r = requests.get(url, headers=headers) | |
lines = [["TITLE","COUNT","CULPRIT","META.TYPE","META.FILENAME","LINK"]] | |
data = r.json() | |
for x in data : | |
temp = [] | |
temp.append(x["title"]) | |
temp.append(x["count"]) | |
temp.append(x["culprit"]) | |
temp.append(x["metadata"].get("type","NA")) | |
temp.append(x["metadata"].get("filename","NA")) | |
temp.append(x["permalink"]) | |
lines.append(temp) | |
print len(data) | |
cur_dir = os.path.dirname(os.path.abspath(__file__)) | |
with open(cur_dir + '/output.csv', 'w') as writeFile: | |
writer = csv.writer(writeFile,delimiter='~') | |
writer.writerows(lines) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment