Skip to content

Commit

Permalink
chore: Added Datadog heartbeat metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
syedimranhassan committed Sep 3, 2024
1 parent a145ed4 commit cf5d726
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
14 changes: 14 additions & 0 deletions devops/jobs/CreateSandboxCI.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class CreateSandboxCI {
wrappers {
credentialsBinding {
string("GENIE_KEY", "opsgenie_heartbeat_key")
string("DD_KEY", "datadog_heartbeat_key")
}
}

Expand Down Expand Up @@ -124,6 +125,19 @@ class CreateSandboxCI {
}
}
shell('curl -X GET "https://api.opsgenie.com/v2/heartbeats/SandboxCI'+type+'/ping" -H "Authorization: GenieKey ${GENIE_KEY}"')
def metricName = "SandboxCI${type}.heartbeat"
String DD_JSON = """
{
"series": [{
"metric": "${metricName}",
"points": [['\$(date +%s)', 1]],
"type": "gauge",
"tags": ["env:${deployment}", "app:check-asg-lifecycle-hooks"]
}]
}
"""

shell('curl -X POST "https://api.datadoghq.com/api/v1/series?api_key=${DD_KEY}" -H "Content-Type: application/json" -d \'' + DD_JSON + '\'')
}

triggers {
Expand Down
16 changes: 16 additions & 0 deletions devops/jobs/JenkinsHeartbeat.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class JenkinsHeartbeat{
wrappers {
credentialsBinding {
string("GENIE_KEY", "opsgenie_heartbeat_key")
string("DD_KEY", "datadog_heartbeat_key")
}
}

Expand All @@ -30,6 +31,21 @@ class JenkinsHeartbeat{
if (opsgenie_heartbeat_name) {
shell('curl -X GET "https://api.opsgenie.com/v2/heartbeats/'+opsgenie_heartbeat_name+'/ping" -H "Authorization: GenieKey ${GENIE_KEY}"')
}
String datadog_heartbeat_name = configuration.get('DATADOG_HEARTBEAT_NAME', '')
if (datadog_heartbeat_name) {
String DD_JSON = """
{
"series": [{
"metric": "${datadog_heartbeat_name}",
"points": [['\$(date +%s)', 1]],
"type": "gauge",
"tags": ["env:${deployment}", "app:check-asg-lifecycle-hooks"]
}]
}
"""

shell('curl -X POST "https://api.datadoghq.com/api/v1/series?api_key=${DD_KEY}" -H "Content-Type: application/json" -d \'' + DD_JSON + '\'')
}
}

}
Expand Down
16 changes: 16 additions & 0 deletions devops/jobs/SandboxTermination.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class SandboxTermination{
string('ROLE_ARN', "launch-sandboxes-role-arn")
string('EDX_GIT_BOT_TOKEN', "edx_git_bot_token")
string("GENIE_KEY", "opsgenie_heartbeat_key")
string("DD_KEY", "datadog_heartbeat_key")
}
}

Expand Down Expand Up @@ -102,6 +103,21 @@ class SandboxTermination{
if (opsgenie_heartbeat_name) {
shell('curl -X GET "https://api.opsgenie.com/v2/heartbeats/'+opsgenie_heartbeat_name+'/ping" -H "Authorization: GenieKey ${GENIE_KEY}"')
}
String datadog_heartbeat_name = configuration.get('DATADOG_HEARTBEAT_NAME', '')
if (datadog_heartbeat_name) {
String DD_JSON = """
{
"series": [{
"metric": "${datadog_heartbeat_name}",
"points": [['\$(date +%s)', 1]],
"type": "gauge",
"tags": ["env:${deployment}", "app:check-asg-lifecycle-hooks"]
}]
}
"""

shell('curl -X POST "https://api.datadoghq.com/api/v1/series?api_key=${DD_KEY}" -H "Content-Type: application/json" -d \'' + DD_JSON + '\'')
}
}

if (extraVars.get('NOTIFY_ON_FAILURE')){
Expand Down

0 comments on commit cf5d726

Please sign in to comment.