Skip to content

Enhance DataDog Synthetics Monitoring Automation - #235

Open
cawohnjing wants to merge 29 commits into
mainfrom
testing/datadog-monitors
Open

Enhance DataDog Synthetics Monitoring Automation#235
cawohnjing wants to merge 29 commits into
mainfrom
testing/datadog-monitors

Conversation

@cawohnjing

@cawohnjing cawohnjing commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Updates DataDog Synthetics monitor generation to reflect what each endpoint's original New Relic script actually tested, replacing generic/placeholder checks, and adds a new dedicated workflow file for DataDog.

Changes

Workflow

  • Added .github/workflows/update-monitoring-datadog.yml: a dedicated DataDog automation (scheduled + manual dispatch with CSV override), configured for the GovCloud DataDog site (ddog-gov.com) with its own API/App key and private-location secrets.

Monitor Routing (monitor_update_csv.py)

  • Rows with Validation_Text but no script now route to a browser test instead of a raw HTTP body-contains check. A plain HTTP request can't see content rendered client-side by JavaScript, which was causing silent failures on JS-rendered pages.
  • SSL certificate monitoring still runs for Prod Portal rows, regardless of whether HTTP or browser checks handle content validation.

API Monitors (set_api_multistep_monitor.py)

  • Replaced the previous stub, which always built a hardcoded POST to the row's base URL, with a real parser that extracts the actual HTTP method, URL, and POST body from the script.
  • Script assertion logic is now translated into a DataDog javascript assertion (via Chai's dd.assert) instead of a hand-rolled, easily broken JSONPath translation.

Browser Monitors (set_browser_monitor.py)

  • Replaced the previous stub, which created an empty, assertion-less test, with a real parser that converts Browser_Query scripts into a DataDog assertElementContent step (URL, XPath, wait timeout).
  • Falls back to building a check directly from Validation_Text when no script exists.
  • Adds the required failTestOnCannotLocate field and an XPath fix to prevent "multiple elements found" errors on pages with duplicate matching text.

Shared Helpers

  • dd_client.py gained tick_every, default_tags, build_alarm_message, and upsert_and_report.
  • Added monitors/synthetics/script_parsing.py with a shared extract_balanced_braces helper, removing logic previously duplicated across all four monitor-builder modules.
  • All monitor alert messages now use a consistent, structured format (state change, region, description) instead of a single unstructured line.

Data

  • Fixed Slack_Channel values to use channel names instead of channel IDs, matching how DataDog's Slack integration resolves @slack-<channel> mentions.

michael-fleming-nih and others added 27 commits April 8, 2026 16:44
Comment on lines +15 to +58
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Python 3.9
id: python-setup
uses: actions/setup-python@b64ffcaf5b410884ad320a9cfac8866006a109aa # v4.8.0
with:
python-version: "3.9"

- name: Install Dependencies
id: install-dependencies
run: |
python -m pip install --upgrade pip
pip install -r monitoring/scripts/datadog/requirements.txt

- name: Run the monitor update script
id: monitor-update
env:
DD_API_KEY: ${{ secrets.DD_API_KEY }}
DD_APP_KEY: ${{ secrets.DD_APP_KEY }}
DD_ALERT_EMAIL: ${{ secrets.EMAIL }}
DD_PRIVATE_LOCATION_ID: aws:us-gov-west-1
DD_SITE: "ddog-gov.com"
run: |
CSV_FILE="https://raw.githubusercontent.com/CBIIT/datacommons-devops/main/monitoring/FNL-Monitoring-List.csv"

if [ -n "${{ github.event.inputs.csv_file }}" ]; then
CSV_FILE="${{ github.event.inputs.csv_file }}"
fi

python3 -u monitoring/scripts/datadog/monitor_update_csv.py -f "$CSV_FILE"

- name: Slack Notification
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
uses: act10ns/slack@87c73aef9f8838eb6feae81589a6b1487a4a9e08 # v1.6.0
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
message: "Datadog Monitors Updated"
if: always()
@cawohnjing cawohnjing closed this Jul 27, 2026
@cawohnjing cawohnjing reopened this Jul 27, 2026
@cawohnjing cawohnjing closed this Jul 27, 2026
@cawohnjing cawohnjing reopened this Jul 27, 2026
@cawohnjing cawohnjing closed this Jul 27, 2026
@cawohnjing cawohnjing reopened this Jul 27, 2026
@cawohnjing cawohnjing changed the title Testing/datadog monitors Enhance DataDog Synthetics Monitoring Automation Jul 27, 2026

@michael-fleming-nih michael-fleming-nih left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these changes look good for the datadog scripts, please duplicate the csv file for this so the newrelic pipeline is not impacted

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we duplicate this file to be datadog specific? we will want the existing newrelic scripts to still be able to run, we just want to add in datadog scripts

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, Let me do that and push the changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants