Skip to content

Commit

Permalink
Improve alert job details
Browse files Browse the repository at this point in the history
  • Loading branch information
devinmatte committed Apr 9, 2024
1 parent bf7f7ac commit d94e6c9
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 5 deletions.
2 changes: 1 addition & 1 deletion devops/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ GIT_SHA=`git rev-parse HEAD`
echo "Deploying version $GIT_VERSION | $GIT_SHA"

# Adding some datadog tags to get better data
DD_TAGS="git.commit.sha:$GIT_SHA,git.repository_url:github.com/transitmatters/data-ingestion"
DD_TAGS="git.commit.sha:$GIT_SHA,git.repository_url:github.com/transitmatters/data-ingestion,version:$GIT_VERSION"
DD_GIT_REPOSITORY_URL="github.com/transitmatters/data-ingestion"
DD_GIT_COMMIT_SHA="$GIT_SHA"

Expand Down
5 changes: 4 additions & 1 deletion ingestor/.chalice/policy-alerts.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
{
"Action": ["s3:GetObject", "s3:PutObject"],
"Effect": "Allow",
"Resource": ["arn:aws:s3:::tm-mbta-performance/Alerts/*"]
"Resource": [
"arn:aws:s3:::tm-mbta-performance/Alerts/*",
"arn:aws:s3:::tm-mbta-performance/Alerts/v3/*"
]
}
]
}
74 changes: 74 additions & 0 deletions ingestor/.chalice/resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
"GitVersion": {
"Type": "String",
"Description": "Current Git Id"
},
"DDGitRepositoryUrl": {
"Type": "String",
"Default": "github.com/transitmatters/data-ingestion",
"Description": "Git repository URL"
}
},
"Resources": {
Expand All @@ -35,6 +40,9 @@
},
"DD_TAGS": {
"Ref": "DDTags"
},
"DD_GIT_REPOSITORY_URL": {
"Ref": "DDGitRepositoryUrl"
}
}
}
Expand All @@ -53,6 +61,9 @@
},
"DD_TAGS": {
"Ref": "DDTags"
},
"DD_GIT_REPOSITORY_URL": {
"Ref": "DDGitRepositoryUrl"
}
}
}
Expand All @@ -74,6 +85,30 @@
},
"DD_TAGS": {
"Ref": "DDTags"
},
"DD_GIT_REPOSITORY_URL": {
"Ref": "DDGitRepositoryUrl"
}
}
}
}
},
"StoreCurrentAlerts": {
"Type": "AWS::Serverless::Function",
"Properties": {
"Environment": {
"Variables": {
"DD_API_KEY": {
"Ref": "DDApiKey"
},
"DD_VERSION": {
"Ref": "GitVersion"
},
"DD_TAGS": {
"Ref": "DDTags"
},
"DD_GIT_REPOSITORY_URL": {
"Ref": "DDGitRepositoryUrl"
}
}
}
Expand All @@ -95,6 +130,9 @@
},
"DD_TAGS": {
"Ref": "DDTags"
},
"DD_GIT_REPOSITORY_URL": {
"Ref": "DDGitRepositoryUrl"
}
}
}
Expand All @@ -114,6 +152,9 @@
},
"DD_TAGS": {
"Ref": "DDTags"
},
"DD_GIT_REPOSITORY_URL": {
"Ref": "DDGitRepositoryUrl"
}
}
}
Expand All @@ -132,6 +173,9 @@
},
"DD_TAGS": {
"Ref": "DDTags"
},
"DD_GIT_REPOSITORY_URL": {
"Ref": "DDGitRepositoryUrl"
}
}
}
Expand All @@ -150,6 +194,9 @@
},
"DD_TAGS": {
"Ref": "DDTags"
},
"DD_GIT_REPOSITORY_URL": {
"Ref": "DDGitRepositoryUrl"
}
}
}
Expand All @@ -169,6 +216,9 @@
},
"DD_TAGS": {
"Ref": "DDTags"
},
"DD_GIT_REPOSITORY_URL": {
"Ref": "DDGitRepositoryUrl"
}
}
}
Expand All @@ -187,6 +237,9 @@
},
"DD_TAGS": {
"Ref": "DDTags"
},
"DD_GIT_REPOSITORY_URL": {
"Ref": "DDGitRepositoryUrl"
}
}
}
Expand All @@ -205,6 +258,9 @@
},
"DD_TAGS": {
"Ref": "DDTags"
},
"DD_GIT_REPOSITORY_URL": {
"Ref": "DDGitRepositoryUrl"
}
}
}
Expand All @@ -223,6 +279,9 @@
},
"DD_TAGS": {
"Ref": "DDTags"
},
"DD_GIT_REPOSITORY_URL": {
"Ref": "DDGitRepositoryUrl"
}
}
}
Expand All @@ -241,6 +300,9 @@
},
"DD_TAGS": {
"Ref": "DDTags"
},
"DD_GIT_REPOSITORY_URL": {
"Ref": "DDGitRepositoryUrl"
}
}
}
Expand All @@ -259,6 +321,9 @@
},
"DD_TAGS": {
"Ref": "DDTags"
},
"DD_GIT_REPOSITORY_URL": {
"Ref": "DDGitRepositoryUrl"
}
}
}
Expand All @@ -277,6 +342,9 @@
},
"DD_TAGS": {
"Ref": "DDTags"
},
"DD_GIT_REPOSITORY_URL": {
"Ref": "DDGitRepositoryUrl"
}
}
}
Expand All @@ -295,6 +363,9 @@
},
"DD_TAGS": {
"Ref": "DDTags"
},
"DD_GIT_REPOSITORY_URL": {
"Ref": "DDGitRepositoryUrl"
}
}
}
Expand All @@ -316,6 +387,9 @@
},
"YANKEE_API_KEY": {
"Ref": "YankeeApiKey"
},
"DD_GIT_REPOSITORY_URL": {
"Ref": "DDGitRepositoryUrl"
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions ingestor/chalicelib/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ def save_v3_alerts():

service_date = get_current_service_date()
try:
all_alerts = s3.download(BUCKET, key(service_date), encoding="utf8", compressed=True)
all_alerts = s3.download(BUCKET, key(service_date, v3=True), encoding="utf8", compressed=True)
except ClientError as ex:
if ex.response["Error"]["Code"] != "NoSuchKey":
raise
all_alerts = dict()

all_alerts = dict()
for alert in alerts["data"]:
all_alerts[alert["id"]] = alert

alert_json = json.dumps(all_alerts).encode("utf8")
s3.upload(BUCKET, key(service_date), alert_json, compress=True)
s3.upload(BUCKET, key(service_date, v3=True), alert_json, compress=True)

0 comments on commit d94e6c9

Please sign in to comment.