Skip to content

Commit

Permalink
Replace deprecated newrelic_dashboard resoure (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
xorxsan authored Sep 6, 2021
1 parent 5559ab9 commit 872fbf1
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 61 deletions.
116 changes: 62 additions & 54 deletions dashboards.tf
Original file line number Diff line number Diff line change
@@ -1,61 +1,69 @@
resource "newrelic_dashboard" "dashboard" {
resource "newrelic_one_dashboard" "dashboard" {
count = var.enable_dashboard ? 1 : 0

title = "${var.newrelic_app_name} Dashboard"
account_id = var.newrelic_account_id
name = "${var.newrelic_app_name} Dashboard"

widget {
title = "Latency (seconds)"
row = 1
column = 1
width = 3
visualization = "line_chart"
nrql = <<-EOF
SELECT
AVERAGE(duration),
PERCENTILE(duration, 50, 90, 99, 99.9)
FROM Transaction
WHERE appName = '${var.newrelic_fully_qualified_app_name}'
AND request.uri != '/'
AND request.uri != '/favicon.ico'
AND request.uri NOT LIKE '/swagger%'
AND request.uri != '/metrics'
TIMESERIES 5 minutes
SINCE 24 hours ago
EOF
}
page {
name = "${var.newrelic_app_name} Dashboard"

widget {
title = "Traffic (requests per minute)"
row = 2
column = 1
width = 1
visualization = "line_chart"
nrql = <<-EOF
SELECT rate(count(*), 1 minute) AS 'Requests per minute'
FROM Transaction
WHERE appName = '${var.newrelic_fully_qualified_app_name}'
TIMESERIES 5 minutes
SINCE 24 hours ago
EXTRAPOLATE
EOF
}
widget_line {
title = "Latency (seconds)"
row = 1
column = 1
width = 3
nrql_query {
query = <<-EOF
SELECT
AVERAGE(duration),
PERCENTILE(duration, 50, 90, 99, 99.9)
FROM Transaction
WHERE appName = '${var.newrelic_fully_qualified_app_name}'
AND request.uri != '/'
AND request.uri != '/favicon.ico'
AND request.uri NOT LIKE '/swagger%'
AND request.uri != '/metrics'
TIMESERIES 5 minutes
SINCE 24 hours ago
EOF
}
}

widget_line {
title = "Traffic (requests per minute)"
row = 2
column = 1
width = 1
nrql_query {
query = <<-EOF
SELECT rate(count(*), 1 minute) AS 'Requests per minute'
FROM Transaction
WHERE appName = '${var.newrelic_fully_qualified_app_name}'
TIMESERIES 5 minutes
SINCE 24 hours ago
EXTRAPOLATE
EOF
}
}

widget {
title = "Errors"
row = 2
column = 2
width = 2
visualization = "line_chart"
nrql = <<-EOF
SELECT
percentage(count(*), WHERE error is true) AS 'Total error rate',
percentage(count(*), WHERE ${var.response_status_variable_name} LIKE '5%') AS '5xx error rate',
percentage(count(*), WHERE ${var.response_status_variable_name} LIKE '4%') AS '4xx error rate'
FROM Transaction
WHERE appName = '${var.newrelic_fully_qualified_app_name}'
TIMESERIES 5 minutes
SINCE 24 hours ago
EXTRAPOLATE
EOF
widget_line {
title = "Errors"
row = 2
column = 2
width = 2
nrql_query {
query = <<-EOF
SELECT
percentage(count(*), WHERE error is true) AS 'Total error rate',
percentage(count(*), WHERE ${var.response_status_variable_name} LIKE '5%') AS '5xx error rate',
percentage(count(*), WHERE ${var.response_status_variable_name} LIKE '4%') AS '4xx error rate'
FROM Transaction
WHERE appName = '${var.newrelic_fully_qualified_app_name}'
TIMESERIES 5 minutes
SINCE 24 hours ago
EXTRAPOLATE
EOF
}
}
}
}
26 changes: 26 additions & 0 deletions test/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions test/test.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ module "newrelic_monitoring" {
service_healthcheck_url = var.service_healthcheck_url
enable_dashboard = true

enable_victorops_notifications = true
victorops_api_key = var.victorops_api_key
victorops_urgent_routing_key = var.victorops_urgent_routing_key
victorops_non_urgent_routing_key = var.victorops_non_urgent_routing_key
enable_victorops_notifications = false

alert_error_rate_enable = true
}
3 changes: 2 additions & 1 deletion test/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ variable "newrelic_account_id" {
}

variable "newrelic_region" {
type = string
type = string
default = "US"
}

variable "newrelic_api_key" {
Expand Down
2 changes: 1 addition & 1 deletion test/versions.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
newrelic = {
source = "terraform-providers/newrelic"
source = "newrelic/newrelic"
version = ">= 2.5.1"
}
}
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
newrelic = {
source = "terraform-providers/newrelic"
source = "newrelic/newrelic"
version = ">= 2.5.1"
}
}
Expand Down

0 comments on commit 872fbf1

Please sign in to comment.