Skip to content

Commit 23b5090

Browse files
chore: Added Datadog heartbeat metrics
1 parent 21066af commit 23b5090

10 files changed

+85
-0
lines changed

dataeng/resources/opsgenie-enable-heartbeat.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414

1515
OPSGENIE_HEARTBEAT_API_URL="https://api.opsgenie.com/v2/heartbeats"
16+
PAGERDUTY_HEARTBEAT_API_URL=""
1617

1718
if [ -n "$OPSGENIE_HEARTBEAT_NAME" ] && \
1819
[ -n "$OPSGENIE_HEARTBEAT_CONFIG_KEY" ] && \

devops/jobs/CheckASGLifeCycleHooks.groovy

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class CheckASGLifeCycleHooks {
5656
credentialsBinding {
5757
string('ROLE_ARN', "check-lifecycle-hooks-${deployment}-role-arn")
5858
string("GENIE_KEY", "opsgenie_heartbeat_key")
59+
string("DD_KEY", "datadog_heartbeat_key")
5960
}
6061
}
6162

@@ -104,6 +105,21 @@ class CheckASGLifeCycleHooks {
104105
if (opsgenie_heartbeat_name) {
105106
shell('curl -X GET "https://api.opsgenie.com/v2/heartbeats/'+opsgenie_heartbeat_name+'/ping" -H "Authorization: GenieKey ${GENIE_KEY}"')
106107
}
108+
String datadog_heartbeat_name = configuration.get('DATADOG_HEARTBEAT_NAME', '')
109+
if (datadog_heartbeat_name) {
110+
String DD_JSON = """
111+
{
112+
"series": [{
113+
"metric": "${datadog_heartbeat_name}",
114+
"points": [['\$(date +%s)', 1]],
115+
"type": "gauge",
116+
"tags": ["env:${deployment}"]
117+
}]
118+
}
119+
"""
120+
121+
shell('curl -X POST "https://api.datadoghq.com/api/v1/series?api_key=${DD_KEY}" -H "Content-Type: application/json" -d \'' + DD_JSON + '\'')
122+
}
107123
}
108124
}
109125
}

devops/jobs/CheckTableSize.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class CheckTableSize {
2525
def variable = "${deployment}-table-size-monitoring"
2626
string("ROLE_ARN", variable)
2727
string("GENIE_KEY", "opsgenie_heartbeat_key")
28+
string("DD_KEY", "datadog_heartbeat_key")
2829
}
2930
}
3031

devops/jobs/CreateSandboxCI.groovy

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class CreateSandboxCI {
3232
wrappers {
3333
credentialsBinding {
3434
string("GENIE_KEY", "opsgenie_heartbeat_key")
35+
string("DD_KEY", "datadog_heartbeat_key")
3536
}
3637
}
3738

@@ -124,6 +125,18 @@ class CreateSandboxCI {
124125
}
125126
}
126127
shell('curl -X GET "https://api.opsgenie.com/v2/heartbeats/SandboxCI'+type+'/ping" -H "Authorization: GenieKey ${GENIE_KEY}"')
128+
def metricName = "SandboxCI${type}.heartbeat"
129+
String DD_JSON = """
130+
{
131+
"series": [{
132+
"metric": "${metricName}",
133+
"points": [['\$(date +%s)', 1]],
134+
"type": "gauge"
135+
}]
136+
}
137+
"""
138+
139+
shell('curl -X POST "https://api.datadoghq.com/api/v1/series?api_key=${DD_KEY}" -H "Content-Type: application/json" -d \'' + DD_JSON + '\'')
127140
}
128141

129142
triggers {

devops/jobs/Janitor.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class Janitor {
4242
credentialsBinding {
4343
string('ROLE_ARN', "tools-jenkins-janitor-${deployment}-role-arn")
4444
string("GENIE_KEY", "opsgenie_heartbeat_key")
45+
string("DD_KEY", "datadog_heartbeat_key")
4546
}
4647
}
4748

@@ -102,6 +103,7 @@ class Janitor {
102103
env('AWS_CLEANER', configuration.get('aws_cleaner'))
103104
env('DENY_LIST', configuration.get('deny_list'))
104105
env('NOOP', extraVars.get('NOOP', false))
106+
env('DEPLOYMENT', deployment)
105107
}
106108

107109

devops/jobs/JenkinsHeartbeat.groovy

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class JenkinsHeartbeat{
1919
wrappers {
2020
credentialsBinding {
2121
string("GENIE_KEY", "opsgenie_heartbeat_key")
22+
string("DD_KEY", "datadog_heartbeat_key")
2223
}
2324
}
2425

@@ -30,6 +31,20 @@ class JenkinsHeartbeat{
3031
if (opsgenie_heartbeat_name) {
3132
shell('curl -X GET "https://api.opsgenie.com/v2/heartbeats/'+opsgenie_heartbeat_name+'/ping" -H "Authorization: GenieKey ${GENIE_KEY}"')
3233
}
34+
String datadog_heartbeat_name = extraVars.get('DATADOG_HEARTBEAT_NAME', '')
35+
if (datadog_heartbeat_name) {
36+
String DD_JSON = """
37+
{
38+
"series": [{
39+
"metric": "${datadog_heartbeat_name}",
40+
"points": [['\$(date +%s)', 1]],
41+
"type": "gauge"
42+
}]
43+
}
44+
"""
45+
46+
shell('curl -X POST "https://api.datadoghq.com/api/v1/series?api_key=${DD_KEY}" -H "Content-Type: application/json" -d \'' + DD_JSON + '\'')
47+
}
3348
}
3449

3550
}

devops/jobs/ProspectusJanitor.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class ProspectusJanitor {
4141
credentialsBinding {
4242
string('ROLE_ARN', "tools-jenkins-janitor-${deployment}-role-arn")
4343
string("GENIE_KEY", "opsgenie_heartbeat_key")
44+
string("DD_KEY", "datadog_heartbeat_key")
4445
}
4546
}
4647

@@ -100,6 +101,7 @@ class ProspectusJanitor {
100101
env('AWS_REGION', configuration.get('aws_region', 'us-east-1'))
101102
env('AWS_CLEANER', configuration.get('aws_cleaner'))
102103
env('NOOP', extraVars.get('NOOP', false))
104+
env('DEPLOYMENT', deployment)
103105
}
104106

105107

devops/jobs/SandboxTermination.groovy

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class SandboxTermination{
3737
string('ROLE_ARN', "launch-sandboxes-role-arn")
3838
string('EDX_GIT_BOT_TOKEN', "edx_git_bot_token")
3939
string("GENIE_KEY", "opsgenie_heartbeat_key")
40+
string("DD_KEY", "datadog_heartbeat_key")
4041
}
4142
}
4243

@@ -102,6 +103,20 @@ class SandboxTermination{
102103
if (opsgenie_heartbeat_name) {
103104
shell('curl -X GET "https://api.opsgenie.com/v2/heartbeats/'+opsgenie_heartbeat_name+'/ping" -H "Authorization: GenieKey ${GENIE_KEY}"')
104105
}
106+
String datadog_heartbeat_name = extraVars.get('DATADOG_HEARTBEAT_NAME', '')
107+
if (datadog_heartbeat_name) {
108+
String DD_JSON = """
109+
{
110+
"series": [{
111+
"metric": "${datadog_heartbeat_name}",
112+
"points": [['\$(date +%s)', 1]],
113+
"type": "gauge"
114+
}]
115+
}
116+
"""
117+
118+
shell('curl -X POST "https://api.datadoghq.com/api/v1/series?api_key=${DD_KEY}" -H "Content-Type: application/json" -d \'' + DD_JSON + '\'')
119+
}
105120
}
106121

107122
if (extraVars.get('NOTIFY_ON_FAILURE')){

devops/resources/janitor.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,13 @@ else
4343
fi
4444

4545
curl -X GET 'https://api.opsgenie.com/v2/heartbeats/'${JOB_NAME##*/}'/ping' -H 'Authorization: GenieKey '${GENIE_KEY}
46+
curl -X POST "https://api.datadoghq.com/api/v1/series?api_key=${DD_KEY}" \
47+
-H "Content-Type: application/json" \
48+
-d '{
49+
"series" : [{
50+
"metric": '${JOB_NAME##*/}".heartbeat"',
51+
"points": [['"$(date +%s)"', 1]],
52+
"type": "gauge",
53+
"tags": ["env:'${DEPLOYMENT}'"]
54+
}]
55+
}'

devops/resources/table-size-monitoring.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,13 @@ fi
3232
python check_table_size.py --threshold ${THRESHOLD} ${RDSTHRESHOLD} ${RDSIGNORE}
3333

3434
curl -X GET 'https://api.opsgenie.com/v2/heartbeats/table-size-monitoring-'${DEPLOYMENT}'/ping' -H 'Authorization: GenieKey '${GENIE_KEY}
35+
curl -X POST "https://api.datadoghq.com/api/v1/series?api_key=${DD_KEY}" \
36+
-H "Content-Type: application/json" \
37+
-d '{
38+
"series" : [{
39+
"metric": "table-size-monitoring-'${DEPLOYMENT}'.heartbeat",
40+
"points": [['"$(date +%s)"', 1]],
41+
"type": "gauge",
42+
"tags": ["env:'${DEPLOYMENT}'"]
43+
}]
44+
}'

0 commit comments

Comments
 (0)