-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Insights Webtests - Url Ping Test #1687
Comments
FWIW: Here is the start of our workaround module: resource "random_uuid" "webtest" {
keepers = {
id_guid = "${format("%v-webtest", var.name)}"
}
}
resource "random_uuid" "request" {
keepers = {
request_guid = "${format("%v-request", var.name)}"
}
}
data "template_file" "webtest" {
template = <<EOF
<WebTest Name="$${name}" Id="$${idGuid}" Enabled="$${enabled}" CssProjectStructure="" CssIteration="" Timeout="$${timeout}" WorkItemIds="" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" Description="" CredentialUserName="$${credentialUserName}" CredentialPassword="$${credentialPassword}" PreAuthenticate="True" Proxy="default" StopOnError="False" RecordedResultFile="" ResultsLocale=""><Items><Request Method="$${requestMethod}" Guid="$${requestGuid}" Version="1.1" Url="$${requestURL}" ThinkTime="0" Timeout="$${timeout}" ParseDependentRequests="False" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="$${expectedHttpStatusCode}" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False" /></Items></WebTest>
EOF
vars {
name = "${var.name}"
idGuid = "${random_uuid.webtest.result}"
enabled = "${var.enabled}"
timeout = "${var.timeout}"
credentialUserName = "${var.credential_username}"
credentialPassword = "${var.credential_password}"
requestMethod = "${var.request_method}"
requestGuid = "${random_uuid.request.result}"
requestURL = "${var.request_url}"
expectedHttpStatusCode = "${var.expected_http_status_code}"
}
}
resource "azurerm_template_deployment" "default" {
name = "${format("%s-arm-webtest", var.name)}"
resource_group_name = "${var.resource_group_name}"
deployment_mode = "Incremental"
template_body = <<DEPLOY
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"type": "string"
},
"appInsightsName": {
"type": "string"
},
"appInsightsLocation" : {
"type": "string"
},
"testLocations" : {
"type": "string"
},
"timeout":{
"type":"string",
"defaultValue": "120"
},
"frequency":{
"type":"string",
"defaultValue": "300"
},
"enabled": {
"type":"string",
"defaultValue": "True"
},
"webTest":{
"type": "string"
}
},
"variables": {
"concatName" : "[trim( toLower( concat( parameters('name'),'-', parameters('appInsightsName') ) ) )]",
"aiLocation" : "[trim( toLower( replace( parameters('appInsightsLocation'),' ', '') ) )]",
"testLocations" : "[split(parameters('testLocations'),',')]",
"enabled" : "[bool(parameters('enabled'))]",
"hiddenLink" : "[concat('hidden-link:',resourceId('microsoft.insights/components',parameters('appInsightsName')))]",
"copy": [
{
"name":"locations",
"count":"[length(variables('testLocations'))]",
"input":{
"Id":"[variables('testLocations')[copyIndex('locations')]]"
}
}
]
},
"resources": [
{
"type": "microsoft.insights/webtests",
"name": "[variables('concatName')]",
"apiVersion": "2015-05-01",
"location": "[variables('aiLocation')]",
"tags": {
"[variables('hiddenLink')]":"Resource"
},
"scale": null,
"properties": {
"SyntheticMonitorId": "[variables('concatName')]",
"Name": "[parameters('name')]",
"Description": "",
"Enabled": "[variables('enabled')]",
"Frequency":"[int(parameters('frequency'))]",
"Timeout": "[int(parameters('timeout'))]",
"Kind": "ping",
"RetryEnabled": true,
"Locations": "[variables('locations')]",
"Configuration": {
"WebTest": "[trim(parameters('webTest'))]"
}
},
"dependsOn": []
}
],
"outputs": {
"hiddenLink": {
"type": "string",
"value": "[variables('hiddenLink')]"
},
"concatName": {
"type": "string",
"value": "[variables('concatName')]"
},
"aiLocation": {
"type": "string",
"value": "[variables('aiLocation')]"
},
"webTest": {
"type": "string",
"value": "[parameters('webTest')]"
},
"tetsLocations": {
"type": "Array",
"value": "[variables('locations')]"
}
}
}
DEPLOY
parameters {
name = "${var.name}"
appInsightsName = "${var.app_insights_name}"
appInsightsLocation = "${var.app_insights_location}"
testLocations = "${var.test_locations}"
timeout = "${var.timeout}"
frequency = "${var.frequency}"
enabled = "${var.enabled}"
webTest = "${data.template_file.webtest.rendered}"
}
}
The caveat is the required reference to the Application Insights resource via the |
Does anyone know if this has been implemented? |
After this now for my company as @jamie3 says above, anyone know if its been implemented? |
@jamie3 @wellingk this functionality isn't natively supported at this time - however you can use the Taking a quick look into this it appears support is available in the Azure SDK for Go such that it'd be possible to implement this - but unfortunately we don't have a timeline for when we'd support this at this time (although, we'd be happy to assist with a community PR in the interim if someone's interested in seeing this natively supported 😄) Thanks! |
i've had a go at this, and other than a few minor odds and ends i still need to sort the code looks ok (but i'm no Go expert by any stretch) Problem I'm hitting is this:
On the off chance has anyone seen this before? (possibly @tombuildsstuff) |
have this working. adding tests/docs and then will raise a PR I've left the actual test config as xml. the original request above from @cdhunt went for parameters instead - thoughts?
|
@AndyMoore This looks awesome, but have two questions:
I'm super excited for this resource to be merged, so if there's any way I can help please let me know. |
i'll definitely put an example into the documentation - i've used one for testing (iirc) straight off the Microsoft site, but there's some things in there I'm not a fan of (each test will need a unique guid for example, and i'm not sure that can be bodged) If we were to go back to the design from the original post, there'd be less flexibility, but it'd be easier to use. It'd also be reasonably trivial to extend Or we could have both maybe.. (i think) I've never done one of these before, so looking to someone else to give pointers In terms of alerts @nexxai I think this i a different API - https://docs.microsoft.com/en-gb/azure/templates/microsoft.insights/2016-03-01/alertrules - so might well be a separate resource for this |
@AndyMoore That makes sense given the variability it test definitions. |
fwiw @nexxai I think what you're after is https://www.terraform.io/docs/providers/azurerm/r/monitor_metric_alert.html and https://www.terraform.io/docs/providers/azurerm/r/monitor_metric_alertrule.html will be looking to test these myself over the next few days.. |
This has been released in version 1.29.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example: provider "azurerm" {
version = "~> 1.29.0"
}
# ... other configuration ... |
@AndyMoore thanks for implementing the web test resource! For the alerts, it looks like Below is a snippet from this quickstart example showing how to setup |
Yes, that is exactly what I was referring to, thanks @praneetloke ! |
Hi Guys, |
Error To recreate, copy/paste the example in the Terraform documentation: https://www.terraform.io/docs/providers/azurerm/r/application_insights_webtests.html Also fails on my own test definition with the same error. Versions
|
it would appear that the module name is actually azurerm_application_insights_web_test so either the documentation needs to be changed or the module needs to be changed. There is also an issue with the section of the documentation "output "webtest_provisioning_state" { This does not appear to be a valid output for the module. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks! |
Community Note
Description
Please add a resource for
microsoft.insights/webtests
.New or Affected Resource(s)
Potential Terraform Configuration
References
The text was updated successfully, but these errors were encountered: