cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Synthetic Operational Framework

saldrich
Participant

Looking for a way to include in our application testing cycle (CI/CD pipeline for lower environments) validation code with the following steps:

1) Enable Synthetic Monitor.
2) Run Synthetic Monitor.
3) Validate if the Synthetic Monitor succeeded or failed

4) Pull important metrics from the succeeded execution (ie. failure rate, performance, availability, etc)
4) Follow or fail the process according to the above result.

5) Disable Synthetic Monitor.

Is there a simple way through the API to determine if the Synthetic Monitor ran successfully or failed? 

Does anyone have a tip on how I could get the above information?  As mentioned above, want to create an Operational Framework where this can be built into CI/CD pipeline for lower environment validations / executions.

 

Thanks for your feedback.

5 REPLIES 5

natanael_mendes
Champion

To include Dynatrace Synthetic Monitors as part of your CI/CD pipeline for lower environment validations and executions, you can use the Dynatrace Synthetic Monitoring API to programmatically interact with Synthetic Monitors and retrieve their results. Here's an outline of the steps you can follow:

1. **Enable Synthetic Monitor:**
- Use the Dynatrace Synthetic Monitoring API to enable the Synthetic Monitor for your application.

2. **Run Synthetic Monitor:**
- Trigger the Synthetic Monitor execution via the API.

3. **Validate Monitor Status:**
- Monitor the status of the Synthetic Monitor execution to determine if it succeeded or failed.

4. **Retrieve Metrics:**
- If the monitor succeeds, use the API to retrieve important metrics such as failure rate, performance, availability, etc., from the Synthetic Monitor results.

5. **Follow or Fail the Process:**
- Based on the results and metrics obtained, you can proceed with the CI/CD pipeline if the monitor succeeds or fail the process if it fails.

6. **Disable Synthetic Monitor:**
- Optionally, use the API to disable the Synthetic Monitor when it's no longer needed.

Here's more detail on steps 3 and 4:

**3. Validate Monitor Status:**

To determine if the Synthetic Monitor execution succeeded or failed, you can use the `/synthetic/monitors/{monitorId}/executions` endpoint of the Synthetic Monitoring API. When you trigger a monitor execution, it will return an execution ID. You can then query the status of that execution ID to check if it succeeded or failed.

**4. Retrieve Metrics:**

If the Synthetic Monitor execution is successful, you can use the `/synthetic/monitors/{monitorId}/executions/{executionId}/results` endpoint to retrieve metrics and results from that specific execution. You can extract metrics such as failure rate, performance, and availability from the response.

Here's a high-level example in Python using the `requests` library to interact with the Synthetic Monitoring API:

```python
import requests

# Set your API token and URL
api_token = "YOUR_API_TOKEN"
api_url = "https://YOUR_DYNATRACE_INSTANCE/api/v1"

# Enable the Synthetic Monitor
# Run the Synthetic Monitor
# (Code for steps 1 and 2)

# Check the status of the monitor execution
execution_id = "EXECUTION_ID"
execution_status_response = requests.get(
f"{api_url}/synthetic/monitors/{monitor_id}/executions/{execution_id}",
headers={"Authorization": f"Api-Token {api_token}"}
)

if execution_status_response.status_code == 200:
execution_status = execution_status_response.json()["result"]["status"]

if execution_status == "FINISHED":
# Retrieve metrics if the execution is successful
execution_metrics_response = requests.get(
f"{api_url}/synthetic/monitors/{monitor_id}/executions/{execution_id}/results",
headers={"Authorization": f"Api-Token {api_token}"}
)

if execution_metrics_response.status_code == 200:
metrics = execution_metrics_response.json()
# Extract and use the desired metrics (e.g., failure rate, performance)

else:
# Handle the case where metrics retrieval fails
pass
else:
# Handle the case where the monitor execution failed
pass
else:
# Handle the case where execution status retrieval fails
pass

# Continue with your CI/CD pipeline based on the results
```

Make sure to replace placeholders like `YOUR_API_TOKEN`, `YOUR_DYNATRACE_INSTANCE`, `EXECUTION_ID`, and `monitor_id` with your actual values. This code provides a basic structure for interacting with the Dynatrace Synthetic Monitoring API to achieve your desired integration within your CI/CD pipeline.

 

 

See this Documentation page:

https://www.dynatrace.com/support/help/platform-modules/digital-experience/synthetic-monitoring/gene...

Dynatrace Professional Certified

Wow this is great details. Are you able to provide more information on Steps 1 - 3? Thanks so much.

1. **Enable Synthetic Monitor:**
- Use the Dynatrace Synthetic Monitoring API to enable the Synthetic Monitor for your application.

2. **Run Synthetic Monitor:**
- Trigger the Synthetic Monitor execution via the API.

3. **Validate Monitor Status:**
- Monitor the status of the Synthetic Monitor execution to determine if it succeeded or failed.

Good afternoon and thanks for the above. 

Wow this is great details you provided for step 4 - 6. Are you able to provide more information on Steps 1 - 3? Thanks so much.

1. **Enable Synthetic Monitor:**
- Use the Dynatrace Synthetic Monitoring API to enable the Synthetic Monitor for your application.

2. **Run Synthetic Monitor:**
- Trigger the Synthetic Monitor execution via the API.

3. **Validate Monitor Status:**
- Monitor the status of the Synthetic Monitor execution to determine if it succeeded or failed.

HannahM
Dynatrace Leader
Dynatrace Leader

1. **Enable Synthetic Monitor:**
- Use the Dynatrace Synthetic Monitoring API to enable the Synthetic Monitor for your application.
https://www.dynatrace.com/support/help/dynatrace-api/environment-api/synthetic/synthetic-monitors/pu...

2. **Run Synthetic Monitor:**
- Trigger the Synthetic Monitor execution via the API.
https://www.dynatrace.com/support/help/dynatrace-api/environment-api/synthetic-v2/synthetic-monitor-...

3. **Validate Monitor Status:**
- Monitor the status of the Synthetic Monitor execution to determine if it succeeded or failed.

https://www.dynatrace.com/support/help/dynatrace-api/environment-api/synthetic-v2/synthetic-monitor-...

Featured Posts