Advertisement
Guest User

Untitled

a guest
Jan 24th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. variable "datadog_api_key" {}
  2. variable "datadog_app_key" {}
  3.  
  4. terraform {
  5. backend "s3" {
  6. bucket = "masterson-terraform"
  7. key = "terraform.tfstate"
  8. region = "ap-southeast-1"
  9. }
  10. }
  11.  
  12. provider "datadog" {
  13. api_key = "${var.datadog_api_key}"
  14. app_key = "${var.datadog_app_key}"
  15. }
  16.  
  17. # Create a new Datadog timeboard
  18. resource "datadog_timeboard" "aws-rds-dashboard" {
  19. title = "RDS Dashboard"
  20. description = "RDS Dashboard by Terraform"
  21. read_only = true
  22.  
  23. graph {
  24. title = "CPUUtilization"
  25. viz = "timeseries"
  26. request {
  27. q = "avg:aws.rds.cpuutilization{*} by {dbinstanceidentifier}.rollup(avg, 3600)"
  28. type = "line"
  29. }
  30. }
  31. graph {
  32. title = "DatabaseConnections"
  33. viz = "timeseries"
  34. request {
  35. q = "avg:aws.rds.database_connections{*} by {dbinstanceidentifier}.rollup(avg, 3600)"
  36. type = "line"
  37. }
  38. }
  39. }
  40.  
  41. resource "datadog_timeboard" "aws-ec2-dashboard" {
  42. title = "EC2 Dashboard"
  43. description = "EC2 Dashboard by Terraform"
  44. read_only = true
  45.  
  46. graph {
  47. title = "CPUUtilization"
  48. viz = "timeseries"
  49. request {
  50. q = "avg:aws.ec2.cpuutilization{*} by {host}.rollup(avg, 3600)"
  51. type = "line"
  52. }
  53. }
  54. graph {
  55. title = "DiskIO"
  56. viz = "timeseries"
  57. request {
  58. q = "avg:aws.ebs.volume_read_ops{*} by {host,device}.rollup(avg, 3600)"
  59. type = "line"
  60. }
  61. request {
  62. q = "avg:aws.ebs.volume_write_ops{*} by {host,device}.rollup(avg, 3600)"
  63. type = "line"
  64. }
  65. }
  66. graph {
  67. title = "NetworkIO"
  68. viz = "timeseries"
  69. request {
  70. q = "avg:aws.ec2.network_in{*} by {host}.rollup(avg, 3600)"
  71. type = "line"
  72. }
  73. request {
  74. q = "avg:aws.ec2.network_out{*} by {host}.rollup(avg, 3600)"
  75. type = "line"
  76. }
  77. }
  78. }
  79. resource "datadog_monitor" "Cloudwatch_RDS_CPU_High" {
  80. name = "Common: RDS CPU High"
  81. type = "metric alert"
  82. query = "avg(last_15m):avg:aws.rds.cpuutilization{*} by {host} > 90"
  83. message = "@webhook-apigw"
  84. escalation_message = "@webhook-apigw"
  85. new_host_delay = "900"
  86. renotify_interval = "600"
  87. timeout_h = "24"
  88. notify_no_data = "false"
  89. require_full_window = "true"
  90. thresholds {
  91. warning = 70
  92. critical = 90
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement