Trying to setup some http monitoring using Dynatra...
# python
s
Trying to setup some http monitoring using Dynatrace pulumi package in my python3.8 venv and running into some issues.. Below is the code snippet..
Copy code
import pulumi
import lbrlabs_pulumi_dynatrace as dynatrace

# The following code sets up a synthetic HTTP monitor using Dynatrace

# Define an HTTP monitor that simulates a user interaction by making an HTTP request to your application endpoint
http_monitor = dynatrace.HttpMonitor("sample-app-http-monitor",
    # Name your monitor, provide descriptions, and tag it appropriately
    name="Sample Application Health Monitor",
    # Set up the script that defines the HTTP request to be made by the monitor
    script=dynatrace.HttpMonitorScriptArgs(
        requests=[
            dynatrace.HttpMonitorScriptRequestArgs(
                url="<Sample App URL?",
                method="GET",  # HTTP method to use for the health check
                # Configure validation rules to define what a successful response looks like
                validation=dynatrace.HttpMonitorScriptRequestValidationArgs(
                    rules=[
                        dynatrace.HttpMonitorScriptRequestValidationRuleArgs(
                            type="HTTP_STATUS_CODE_IS",
                            value="200",  # Expecting a 200 OK status code for a healthy response
                            pass_if_found=True
                        ),
                        dynatrace.HttpMonitorScriptRequestValidationRuleArgs(
                            type="RESPONSE_BODY_MATCHES",
                            value="Application is healthy",  # A sample response body validation
                            pass_if_found=True
                        )
                    ]
                ),
                description="Health Check Request"  # A description of the request for clarity
            )
        ]
    ),
    # Define the monitoring frequency
    frequency=5,  # Frequency in minutes
    # Specify the locations from which the synthetic monitoring checks should be performed
    locations=["AWS_US_WEST_1"],
    # Enable the monitor to get it running
    enabled=True,
)

# Output the HTTP monitor ID for reference
pulumi.export('http_monitor_id', http_monitor.id)