"Migrating from Monaco to Terraform for management zone: CD_APIGW"

CD_APIGW
Patryk Gudalewicz 2023-03-01 19:11:12 +01:00
parent 9493f8cee6
commit c0eb962427
4 changed files with 635 additions and 0 deletions

View File

@ -0,0 +1,26 @@
# DEFINE dynatrace_alerting.CD_APIGW_INT.id = vu9U3hXa3q0AAAABABhidWlsdGluOmFsZXJ0aW5nLnByb2ZpbGUABnRlbmFudAAGdGVuYW50ACQ0YTMwOGU5My1jM2U3LTMxY2QtYjk4YS1mODU2ZmI4MmQ5YjG-71TeFdrerQ
data "dynatrace_management_zone" "CD_APIGW_INT"{ name="CD_APIGW" }
resource "dynatrace_alerting" "CD_APIGW_INT" {
name = "CD_APIGW INT"
management_zone = data.dynatrace_management_zone.CD_APIGW_INT.id
rules {
rule {
delay_in_minutes = 0
include_mode = "INCLUDE_ALL"
severity_level = "AVAILABILITY"
tags = [ "Component:APIGW-WS", "Environment:INT" ]
}
rule {
delay_in_minutes = 10
include_mode = "INCLUDE_ALL"
severity_level = "CUSTOM_ALERT"
tags = [ "Component:APIGW-WS", "Environment:INT" ]
}
rule {
delay_in_minutes = 30
include_mode = "INCLUDE_ALL"
severity_level = "RESOURCE_CONTENTION"
tags = [ "Component:APIGW-WS", "Environment:INT" ]
}
}
}

View File

@ -0,0 +1,26 @@
# DEFINE dynatrace_alerting.CD_APIGW_PROD.id = vu9U3hXa3q0AAAABABhidWlsdGluOmFsZXJ0aW5nLnByb2ZpbGUABnRlbmFudAAGdGVuYW50ACQzMjVjYTU4Yi00YzA5LTMxMGMtYjhkOS04NmRhODkxN2E3YWS-71TeFdrerQ
data "dynatrace_management_zone" "CD_APIGW_PROD"{ name="CD_APIGW" }
resource "dynatrace_alerting" "CD_APIGW_PROD" {
name = "CD_APIGW PROD"
management_zone = data.dynatrace_management_zone.CD_APIGW_PROD.id
rules {
rule {
delay_in_minutes = 0
include_mode = "INCLUDE_ALL"
severity_level = "AVAILABILITY"
tags = [ "Component:APIGW-WS", "Environment:PROD" ]
}
rule {
delay_in_minutes = 10
include_mode = "INCLUDE_ALL"
severity_level = "CUSTOM_ALERT"
tags = [ "Component:APIGW-WS", "Environment:PROD" ]
}
rule {
delay_in_minutes = 30
include_mode = "INCLUDE_ALL"
severity_level = "RESOURCE_CONTENTION"
tags = [ "Component:APIGW-WS", "Environment:PROD" ]
}
}
}

View File

@ -0,0 +1,351 @@
# DEFINE dynatrace_dashboard.CD_APIGW_PROD.id = 942bcae7-e9bc-480f-a3a9-a04ca8c51c44
data "dynatrace_management_zone" "CD_APIGW_PROD"{ name="CD_APIGW" }
resource "dynatrace_dashboard" "CD_APIGW_PROD" {
dashboard_metadata {
name = "CD_APIGW PROD"
owner = "Carlo.DiMastrogiovanni@partner.bmw.de"
# preset = false
shared = true
tags = [ "APIGW", "APIGW-WS" ]
filter {
timeframe = "-24h to now"
}
}
tile {
name = "Overall Health"
configured = true
tile_type = "HEADER"
unknowns = jsonencode({
"isAutoRefreshDisabled": false
})
bounds {
height = 38
left = 38
top = 0
width = 1064
}
}
tile {
name = "Host health"
chart_visible = true
configured = true
tile_type = "HOSTS"
unknowns = jsonencode({
"isAutoRefreshDisabled": false
})
bounds {
height = 152
left = 76
top = 38
width = 304
}
filter {
management_zone {
name = "CD_APIGW"
id = data.dynatrace_management_zone.CD_APIGW_PROD.id
}
}
}
tile {
name = "Response time, Request Count and Number of Errors"
configured = true
custom_name = "Response time, Request Count and Number of Errors"
tile_type = "DATA_EXPLORER"
unknowns = jsonencode({
"isAutoRefreshDisabled": false,
"metricExpressions": [
"resolution=null\u0026(builtin:service.response.time:filter(and(and(in(\"dt.entity.service\",entitySelector(\"type(service),tag(~\"Component:APIGW-WS~\")\")),in(\"dt.entity.service\",entitySelector(\"type(service),tag(~\"Environment:PROD~\")\"))))):splitBy():avg:auto:sort(value(avg,descending)):limit(10)):limit(100):names,(builtin:service.requestCount.total:filter(and(and(in(\"dt.entity.service\",entitySelector(\"type(service),tag(~\"Environment:PROD~\")\")),in(\"dt.entity.service\",entitySelector(\"type(service),tag(~\"Component:APIGW-WS~\")\"))))):splitBy():value:auto:sort(value(sum,descending)):limit(10)):limit(100):names,(builtin:service.errors.total.count:filter(and(and(in(\"dt.entity.service\",entitySelector(\"type(service),tag(~\"Component:APIGW-WS~\")\")),in(\"dt.entity.service\",entitySelector(\"type(service),tag(~\"Environment:PROD~\")\"))))):splitBy():value:auto:sort(value(sum,descending)):limit(10)):limit(100):names"
],
"queries": [
{
"enabled": true,
"id": "A",
"metricSelector": "builtin:service.response.time:filter(and(and(in(\"dt.entity.service\",entitySelector(\"type(service),tag(~\"Component:APIGW-WS~\")\")),in(\"dt.entity.service\",entitySelector(\"type(service),tag(~\"Environment:PROD~\")\"))))):splitBy():avg:auto:sort(value(avg,descending)):limit(10)",
"rate": "NONE",
"splitBy": [],
"timeAggregation": "DEFAULT"
},
{
"enabled": true,
"id": "B",
"metricSelector": "builtin:service.requestCount.total:filter(and(and(in(\"dt.entity.service\",entitySelector(\"type(service),tag(~\"Environment:PROD~\")\")),in(\"dt.entity.service\",entitySelector(\"type(service),tag(~\"Component:APIGW-WS~\")\"))))):splitBy():value:auto:sort(value(sum,descending)):limit(10)",
"rate": "NONE",
"splitBy": [],
"timeAggregation": "DEFAULT"
},
{
"enabled": true,
"id": "C",
"metricSelector": "builtin:service.errors.total.count:filter(and(and(in(\"dt.entity.service\",entitySelector(\"type(service),tag(~\"Component:APIGW-WS~\")\")),in(\"dt.entity.service\",entitySelector(\"type(service),tag(~\"Environment:PROD~\")\"))))):splitBy():value:auto:sort(value(sum,descending)):limit(10)",
"rate": "NONE",
"splitBy": [],
"timeAggregation": "DEFAULT"
}
],
"visualConfig": {
"axes": {
"xAxis": {
"displayName": "",
"visible": true
},
"yAxes": [
{
"defaultAxis": true,
"displayName": "",
"max": "AUTO",
"min": "AUTO",
"position": "LEFT",
"queryIds": [
"A"
],
"visible": true
},
{
"defaultAxis": true,
"displayName": "",
"max": "AUTO",
"min": "AUTO",
"position": "RIGHT",
"queryIds": [
"B",
"C"
],
"visible": true
}
]
},
"global": {
"hideLegend": false
},
"graphChartSettings": {
"connectNulls": false
},
"heatmapSettings": {
"yAxis": "VALUE"
},
"rules": [
{
"matcher": "A:",
"properties": {
"color": "DEFAULT",
"seriesType": "LINE"
},
"seriesOverrides": []
},
{
"matcher": "B:",
"properties": {
"color": "DEFAULT",
"seriesType": "COLUMN"
},
"seriesOverrides": []
},
{
"matcher": "C:",
"properties": {
"color": "DEFAULT",
"seriesType": "COLUMN"
},
"seriesOverrides": []
}
],
"tableSettings": {},
"thresholds": [
{
"axisTarget": "LEFT",
"queryId": "",
"rules": [
{
"color": "#7dc540"
},
{
"color": "#f5d30f"
},
{
"color": "#dc172a"
}
],
"visible": true
}
],
"type": "GRAPH_CHART"
}
})
bounds {
height = 304
left = 38
top = 570
width = 1064
}
filter {
management_zone {
name = "CD_APIGW"
id = data.dynatrace_management_zone.CD_APIGW_PROD.id
}
}
}
tile {
name = "Failure rate (HTTP 4xx/5xx errors)"
configured = true
custom_name = "Failure rate (HTTP 4xx/5xx errors)"
tile_type = "DATA_EXPLORER"
unknowns = jsonencode({
"isAutoRefreshDisabled": false,
"metricExpressions": [
"resolution=null\u0026(builtin:service.errors.fourxx.rate:filter(and(and(in(\"dt.entity.service\",entitySelector(\"type(service),tag(~\"Component:APIGW-WS~\")\")),in(\"dt.entity.service\",entitySelector(\"type(service),tag(~\"Environment:PROD~\")\"))))):splitBy():avg:auto:sort(value(avg,descending)):limit(10)):limit(100):names,(builtin:service.errors.fivexx.rate:filter(and(and(in(\"dt.entity.service\",entitySelector(\"type(service),tag(~\"Environment:PROD~\")\")),in(\"dt.entity.service\",entitySelector(\"type(service),tag(~\"Component:APIGW-WS~\")\"))))):splitBy():avg:auto:sort(value(avg,descending)):limit(10)):limit(100):names"
],
"queries": [
{
"enabled": true,
"id": "A",
"metricSelector": "builtin:service.errors.fourxx.rate:filter(and(and(in(\"dt.entity.service\",entitySelector(\"type(service),tag(~\"Component:APIGW-WS~\")\")),in(\"dt.entity.service\",entitySelector(\"type(service),tag(~\"Environment:PROD~\")\"))))):splitBy():avg:auto:sort(value(avg,descending)):limit(10)",
"rate": "NONE",
"splitBy": [],
"timeAggregation": "DEFAULT"
},
{
"enabled": true,
"id": "B",
"metricSelector": "builtin:service.errors.fivexx.rate:filter(and(and(in(\"dt.entity.service\",entitySelector(\"type(service),tag(~\"Environment:PROD~\")\")),in(\"dt.entity.service\",entitySelector(\"type(service),tag(~\"Component:APIGW-WS~\")\"))))):splitBy():avg:auto:sort(value(avg,descending)):limit(10)",
"rate": "NONE",
"splitBy": [],
"timeAggregation": "DEFAULT"
}
],
"visualConfig": {
"axes": {
"xAxis": {
"displayName": "",
"visible": true
},
"yAxes": [
{
"defaultAxis": true,
"displayName": "",
"max": "AUTO",
"min": "AUTO",
"position": "LEFT",
"queryIds": [
"A",
"B"
],
"visible": true
}
]
},
"global": {
"hideLegend": false
},
"graphChartSettings": {
"connectNulls": false
},
"heatmapSettings": {
"yAxis": "VALUE"
},
"rules": [
{
"matcher": "A:",
"properties": {
"color": "DEFAULT",
"seriesType": "COLUMN"
},
"seriesOverrides": []
},
{
"matcher": "B:",
"properties": {
"color": "DEFAULT",
"seriesType": "COLUMN"
},
"seriesOverrides": []
}
],
"tableSettings": {},
"thresholds": [
{
"axisTarget": "LEFT",
"queryId": "",
"rules": [
{
"color": "#7dc540"
},
{
"color": "#f5d30f"
},
{
"color": "#dc172a"
}
],
"visible": true
}
],
"type": "GRAPH_CHART"
}
})
bounds {
height = 304
left = 38
top = 228
width = 1064
}
filter {
management_zone {
name = "CD_APIGW"
id = data.dynatrace_management_zone.CD_APIGW_PROD.id
}
}
}
tile {
name = "Service health"
chart_visible = true
configured = true
tile_type = "SERVICES"
unknowns = jsonencode({
"isAutoRefreshDisabled": false
})
bounds {
height = 152
left = 494
top = 38
width = 304
}
filter {
management_zone {
name = "CD_APIGW"
id = data.dynatrace_management_zone.CD_APIGW_PROD.id
}
}
}
tile {
name = "Problems"
configured = true
tile_type = "OPEN_PROBLEMS"
unknowns = jsonencode({
"isAutoRefreshDisabled": false
})
bounds {
height = 152
left = 912
top = 38
width = 152
}
filter {
management_zone {
name = "CD_APIGW"
id = data.dynatrace_management_zone.CD_APIGW_PROD.id
}
}
}
}
# DEFINE dynatrace_dashboard_sharing.CD_APIGW_PROD.id = 942bcae7-e9bc-480f-a3a9-a04ca8c51c44
resource "dynatrace_dashboard_sharing" "CD_APIGW_PROD" {
enabled = true
dashboard_id = dynatrace_dashboard.CD_APIGW_PROD.id
# preset = false
permissions {
permission {
type = "ALL"
level = "VIEW"
}
}
}

View File

@ -0,0 +1,232 @@
# DEFINE dynatrace_management_zone.CD_APIGW.id = 1449303990270766173
resource "dynatrace_management_zone" "CD_APIGW" {
name = "CD_APIGW"
rules {
type = "SERVICE"
enabled = true
propagation_types = [ "SERVICE_TO_HOST_LIKE", "SERVICE_TO_PROCESS_GROUP_LIKE" ]
conditions {
key {
type = "STATIC"
attribute = "SERVICE_NAME"
}
string {
case_sensitive = true
negate = true
operator = "CONTAINS"
value = "HealthResource"
}
}
conditions {
key {
type = "STATIC"
attribute = "SERVICE_NAME"
}
string {
case_sensitive = true
negate = true
operator = "CONTAINS"
value = "PingResource"
}
}
conditions {
key {
type = "STATIC"
attribute = "SERVICE_NAME"
}
string {
case_sensitive = true
negate = true
operator = "CONTAINS"
value = "PrometheusResource"
}
}
conditions {
key {
type = "STATIC"
attribute = "SERVICE_TAGS"
}
tag {
# negate = false
operator = "EQUALS"
value {
context = "CONTEXTLESS"
key = "Component"
value = "APIGW-APP"
}
}
}
}
rules {
type = "SERVICE"
enabled = true
propagation_types = [ "SERVICE_TO_HOST_LIKE", "SERVICE_TO_PROCESS_GROUP_LIKE" ]
conditions {
key {
type = "STATIC"
attribute = "SERVICE_NAME"
}
string {
case_sensitive = true
negate = true
operator = "CONTAINS"
value = "HealthResource"
}
}
conditions {
key {
type = "STATIC"
attribute = "SERVICE_NAME"
}
string {
case_sensitive = true
negate = true
operator = "CONTAINS"
value = "PingResource"
}
}
conditions {
key {
type = "STATIC"
attribute = "SERVICE_NAME"
}
string {
case_sensitive = true
negate = true
operator = "CONTAINS"
value = "PrometheusResource"
}
}
conditions {
key {
type = "STATIC"
attribute = "SERVICE_TAGS"
}
tag {
# negate = false
operator = "EQUALS"
value {
context = "CONTEXTLESS"
key = "Component"
value = "APIGW-WS"
}
}
}
}
rules {
type = "SERVICE"
enabled = true
propagation_types = [ "SERVICE_TO_HOST_LIKE", "SERVICE_TO_PROCESS_GROUP_LIKE" ]
conditions {
key {
type = "STATIC"
attribute = "SERVICE_NAME"
}
string {
case_sensitive = true
negate = true
operator = "CONTAINS"
value = "HealthResource"
}
}
conditions {
key {
type = "STATIC"
attribute = "SERVICE_NAME"
}
string {
case_sensitive = true
negate = true
operator = "CONTAINS"
value = "PingResource"
}
}
conditions {
key {
type = "STATIC"
attribute = "SERVICE_NAME"
}
string {
case_sensitive = true
negate = true
operator = "CONTAINS"
value = "PrometheusResource"
}
}
conditions {
key {
type = "STATIC"
attribute = "SERVICE_TAGS"
}
tag {
# negate = false
operator = "EQUALS"
value {
context = "CONTEXTLESS"
key = "Component"
value = "Service Gateway Legacy"
}
}
}
}
rules {
type = "PROCESS_GROUP"
enabled = true
propagation_types = [ "PROCESS_GROUP_TO_HOST" ]
conditions {
key {
type = "STATIC"
attribute = "PROCESS_GROUP_TAGS"
}
tag {
# negate = false
operator = "EQUALS"
value {
context = "CONTEXTLESS"
key = "Component"
value = "APIGW-APP"
}
}
}
}
rules {
type = "PROCESS_GROUP"
enabled = true
propagation_types = [ "PROCESS_GROUP_TO_HOST" ]
conditions {
key {
type = "STATIC"
attribute = "PROCESS_GROUP_TAGS"
}
tag {
# negate = false
operator = "EQUALS"
value {
context = "CONTEXTLESS"
key = "Component"
value = "APIGW-WS"
}
}
}
}
rules {
type = "PROCESS_GROUP"
enabled = true
propagation_types = [ "PROCESS_GROUP_TO_HOST" ]
conditions {
key {
type = "STATIC"
attribute = "PROCESS_GROUP_TAGS"
}
tag {
# negate = false
operator = "EQUALS"
value {
context = "CONTEXTLESS"
key = "Component"
value = "Service Gateway Legacy"
}
}
}
}
}