Skip to content

Commit ccf66df

Browse files
feat(template): Add base path api parameter (#46)
Co-authored-by: Pasquale De Vita <[email protected]>
1 parent 7a21436 commit ccf66df

10 files changed

+1085
-19
lines changed

src/opex_dashboard/templates/api-management_queries/availability.kusto

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
{% load stringify uri_to_regex %}
1+
{% load add_str stringify uri_to_regex %}
22
let threshold = {{ threshold|default:"0.99" }};
33
AzureDiagnostics
4-
| where url_s matches regex "{{ endpoint|uri_to_regex }}"
4+
| where url_s matches regex "{{ base_path|default:""|add_str:endpoint|uri_to_regex }}"
55
| summarize
66
Total=count(),
77
Success=count(responseCode_d < 500) by bin(TimeGenerated, {{ timespan }})

src/opex_dashboard/templates/api-management_queries/response_codes.kusto

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
{% load stringify uri_to_regex %}
2-
let api_url = "{{ endpoint|uri_to_regex }}";
1+
{% load add_str stringify uri_to_regex %}
2+
let api_url = "{{ base_path|default:""|add_str:endpoint|uri_to_regex }}";
33
AzureDiagnostics
44
| where url_s matches regex api_url
55
| extend HTTPStatus = case(

src/opex_dashboard/templates/api-management_queries/response_time.kusto

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
{% load stringify uri_to_regex %}
1+
{% load add_str stringify uri_to_regex %}
22
let threshold = {{ threshold|default:"1" }};
33
AzureDiagnostics
4-
| where url_s matches regex "{{ endpoint|uri_to_regex }}"
4+
| where url_s matches regex "{{ base_path|default:""|add_str:endpoint|uri_to_regex }}"
55
| summarize
66
watermark=threshold,
77
duration_percentile_95=percentiles(todouble(DurationMs)/1000, 95) by bin(TimeGenerated, {{ timespan }})

src/opex_dashboard/templates/app-gateway_queries/availability.kusto

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
{% load stringify uri_to_regex %}
1+
{% load add_str stringify uri_to_regex %}
22
let api_hosts = datatable (name: string) {{ hosts|stringify }};
33
let threshold = {{ threshold|default:"0.99" }};
44
AzureDiagnostics
55
| where originalHost_s in (api_hosts)
6-
| where requestUri_s matches regex "{{ endpoint|uri_to_regex }}"
6+
| where requestUri_s matches regex "{{ base_path|default:""|add_str:endpoint|uri_to_regex }}"
77
| summarize
88
Total=count(),
99
Success=count(httpStatus_d < 500) by bin(TimeGenerated, {{ timespan }})

src/opex_dashboard/templates/app-gateway_queries/response_codes.kusto

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
{% load stringify uri_to_regex %}
2-
let api_url = "{{ endpoint|uri_to_regex }}";
1+
{% load add_str stringify uri_to_regex %}
2+
let api_url = "{{ base_path|default:""|add_str:endpoint|uri_to_regex }}";
33
let api_hosts = datatable (name: string) {{ hosts|stringify }};
44
AzureDiagnostics
55
| where originalHost_s in (api_hosts)

src/opex_dashboard/templates/app-gateway_queries/response_time.kusto

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
{% load stringify uri_to_regex %}
1+
{% load add_str stringify uri_to_regex %}
22
let api_hosts = datatable (name: string) {{ hosts|stringify }};
33
let threshold = {{ threshold|default:"1" }};
44
AzureDiagnostics
55
| where originalHost_s in (api_hosts)
6-
| where requestUri_s matches regex "{{ endpoint|uri_to_regex }}"
6+
| where requestUri_s matches regex "{{ base_path|default:""|add_str:endpoint|uri_to_regex }}"
77
| summarize
88
watermark=threshold,
99
duration_percentile_95=percentiles(timeTaken_d, 95) by bin(TimeGenerated, {{ timespan }})

src/opex_dashboard/templates/azure_dashboard_raw.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
},
8080
{
8181
"name": "PartSubTitle",
82-
"value": "{{ endpoint }}",
82+
"value": "{{ base_path|default:""|add_str:endpoint }}",
8383
"isOptional": true
8484
},
8585
{
@@ -202,7 +202,7 @@
202202
},
203203
{
204204
"name": "PartSubTitle",
205-
"value": "{{ endpoint }}",
205+
"value": "{{ base_path|default:""|add_str:endpoint }}",
206206
"isOptional": true
207207
},
208208
{
@@ -341,7 +341,7 @@
341341
},
342342
{
343343
"name": "PartSubTitle",
344-
"value": "{{ endpoint }}",
344+
"value": "{{ base_path|default:""|add_str:endpoint }}",
345345
"isOptional": true
346346
},
347347
{

src/opex_dashboard/templates/azure_dashboard_terraform.tf

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ resource "azurerm_portal_dashboard" "this" {
2222

2323
{% for endpoint,props in endpoints.items %}
2424
resource "azurerm_monitor_scheduled_query_rules_alert" "alarm_availability_{{ forloop.counter0 }}" {
25-
name = replace(join("_",split("/", "${local.name}-availability @ {{endpoint}}")), "/\\{|\\}/", "")
25+
name = replace(join("_",split("/", "${local.name}-availability @ {{base_path|default:""|add_str:endpoint}}")), "/\\{|\\}/", "")
2626
resource_group_name = data.azurerm_resource_group.this.name
2727
location = data.azurerm_resource_group.this.location
2828

@@ -31,7 +31,7 @@ resource "azurerm_monitor_scheduled_query_rules_alert" "alarm_availability_{{ fo
3131
}
3232

3333
data_source_id = "{{ data_source_id }}"
34-
description = "Availability for {{endpoint}} is less than or equal to 99% - ${local.dashboard_base_addr}${azurerm_portal_dashboard.this.id}"
34+
description = "Availability for {{base_path|default:""|add_str:endpoint}} is less than or equal to 99% - ${local.dashboard_base_addr}${azurerm_portal_dashboard.this.id}"
3535
enabled = true
3636
auto_mitigation_enabled = false
3737

@@ -53,7 +53,7 @@ resource "azurerm_monitor_scheduled_query_rules_alert" "alarm_availability_{{ fo
5353
}
5454

5555
resource "azurerm_monitor_scheduled_query_rules_alert" "alarm_time_{{ forloop.counter0 }}" {
56-
name = replace(join("_",split("/", "${local.name}-responsetime @ {{endpoint}}")), "/\\{|\\}/", "")
56+
name = replace(join("_",split("/", "${local.name}-responsetime @ {{base_path|default:""|add_str:endpoint}}")), "/\\{|\\}/", "")
5757
resource_group_name = data.azurerm_resource_group.this.name
5858
location = data.azurerm_resource_group.this.location
5959

@@ -62,7 +62,7 @@ resource "azurerm_monitor_scheduled_query_rules_alert" "alarm_time_{{ forloop.co
6262
}
6363

6464
data_source_id = "{{ data_source_id }}"
65-
description = "Response time for {{endpoint}} is less than or equal to 1s - ${local.dashboard_base_addr}${azurerm_portal_dashboard.this.id}"
65+
description = "Response time for {{base_path|default:""|add_str:endpoint}} is less than or equal to 1s - ${local.dashboard_base_addr}${azurerm_portal_dashboard.this.id}"
6666
enabled = true
6767
auto_mitigation_enabled = false
6868

0 commit comments

Comments
 (0)