Code Monkey home page Code Monkey logo

terraform-newrelic-apm's Introduction

Community Project header

New Relic APM Terraform module

Terraform module which creates a monitoring strategy for application resources reporting into New Relic.

This module is capable of creating an alert policy, simple Synthetics monitor, and alert conditions (Apdex (High), Response Time (High), Error rate (High), Synthetics failure) for a given application reporting data into APM.

The following resource types are provisioned via use of this module:

Terraform versions

Terraform 0.12 is required.

Usage

data "newrelic_alert_channel" "pager" {
    name = "Page Developer Toolkit Team"
}

module "dummy-app-monitor" {
    source = "newrelic/apm/newrelic"

    account_id = 2520528
    application_name = "Dummy App"

    # An Apdex alert condition will be created with sensible defaults without the use of these attributes.
    apdex_warning_threshold = 0.9
    apdex_critical_threshold = 0.8

    # An error rate alert condition will be created with sensible defaults without the use of these attributes.
    error_rate_warning_threshold = 5
    error_rate_critical_threshold = 10

    # Specifying an application URL will provision a Synthetics monitor and associated alert condition.
    application_url = "https://www.dummyapp.com"
    synthetics_monitor_verify_ssl = true

    # Response time alert condition will not be provisioned unless a critical violation threshold is specified.
    response_time_critical_threshold = 3

    channel_ids = [data.newrelic_alert_channel.pager.id]
}

Notes

  1. This module does not create a notification channel. Use the newrelic_alert_channel resource for this.

Providers

Name Version
newrelic >= 1.15.1

Inputs

Name Description Type Default Required
account_id The account ID the application reports to number n/a yes
apdex_critical_threshold The threshold below which a critical violation will be triggered for the Apdex condition (percentage satisfied users) number 0.7 no
apdex_duration The evaluation window length of the Apdex condition (minutes) number 5 no
apdex_t The response time above which a transaction is considered tolerable number 0.4 no
apdex_warning_threshold The threshold below which a warning violation will be triggered for the Apdex condition (percentage satisfied users) number 0.8 no
application_name The name of the New Relic application to monitor string n/a yes
application_url The URL to use when configuring a Synthetics monitor for this application string n/a yes
channel_ids The notification channel IDs to link to this alert policy list(number) n/a yes
error_rate_critical_threshold The threshold above which a critical violation will be triggered for the error rate condition (errors/minute) number 5 no
error_rate_duration The evaluation window length of the error rate condition (minutes) number 5 no
error_rate_warning_threshold The threshold above which a warning violation will be triggered for the error rate condition (errors/minute) number 2 no
incident_preference The rollup strategy of the alert policy. Valid values are PER_POLICY, PER_CONDITION, and PER_CONDITION_AND_TARGET string "PER_POLICY" no
policy_name The name of the alert policy to manage string n/a yes
response_time_critical_threshold The threshold above which a critical violation will be triggered for the response time condition (seconds) number n/a yes
response_time_duration The evaluation window length of the error rate condition (minutes) number 5 no
response_time_warning_threshold The threshold above which a warning violation will be triggered for the response time condition (seconds) number 1 no
runbook_url A URL that points to a runbook for when this application is failing string n/a yes
synthetics_condition_duration The evaluation window length of the Synthetics condition (minutes) number 5 no
synthetics_condition_threshold The threshold above which a critical violation will be triggered for the Synthetics condition (failure count) number 0 no
synthetics_monitor_frequency The interval on which to run Synthetics checks against the provided application URL number 5 no
synthetics_monitor_locations The locations to run Synthetics checks from list(string)
[
"AWS_US_EAST_1"
]
no
synthetics_monitor_validation_string An optional string to check existence of when running Synthetics checks string n/a yes
synthetics_monitor_verify_ssl If true, verifies SSL when running Synthetics checks bool false no

Outputs

Name Description
apdex_condition_id The ID of the provisioned Apdex condition.
error_rate_condition_id The ID of the provisioned error rate condition.
policy_id The ID of the provisioned alert policy.
reponse_time_condition_id The ID of the provisioned response time condition.
synthetics_condition_id The ID of the provisioned Synthetics condition.
synthetics_monitor_id The ID of the provisioned Synthetics monitor.

Community Support

New Relic hosts and moderates an online forum where you can interact with New Relic employees as well as other customers to get help and share best practices. Like all New Relic open source community projects, there's a related topic in the New Relic Explorers Hub. You can find this project's topic/threads here:

https://discuss.newrelic.com/t/new-relic-terraform-provider-1-16-0/98241

Please do not report issues with this project to New Relic Global Technical Support. Instead, visit the Explorers Hub for troubleshooting and best-practices.

License

Apache 2.0 Licensed. See LICENSE for full details.

terraform-newrelic-apm's People

Contributors

ctrombley avatar kidk avatar nagarajantv avatar sanderblue avatar tangollama avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terraform-newrelic-apm's Issues

Module in the terraform registry is still pointing to the older version of the code

Recently there was pull request #10 to fix the versions.tf file to correct the provider path. We could see that the PR has been merged in the github, but the module in the terraform registry is still pointing to the old version of code(Version 0.0.5 - Published in July,2020)

Can you publish the latest version of module to the Terraform registry?

Unpin provider version

When using the newer alert channel configuration, the module fails as it has been pinned to 1.9.0. Example failure

Config

main.tf

# Notification channel
resource "newrelic_alert_channel" "alert_notification_email" {
  name = "<REDACTED>"
  type = "email"

  config {
    recipients              = "<REDACTED>"
    include_json_attachment = "1"
  }
}

# APM Module
#  https://registry.terraform.io/modules/newrelic/apm/newrelic/
module "WebPortal-demo-monitor" {
    source = "newrelic/apm/newrelic"

    account_id = <REDACTED>
    application_name = "WebPortal"

    apdex_warning_threshold = 0.85
    apdex_critical_threshold = 0.75
    error_rate_warning_threshold = 2
    error_rate_critical_threshold = 5

    application_url = "<REDACTED>"
    synthetics_monitor_verify_ssl = true
    response_time_critical_threshold = 3

    channel_ids = [
      data.newrelic_alert_channel.alert_notification_email.id
    ]
}

Error

Error: Unsupported argument
  on .terraform/modules/WebPortal-demo-monitor/newrelic-terraform-newrelic-apm-cef77f7/main.tf line 8, in resource "newrelic_alert_policy" "policy":
   8:   channel_ids         = var.channel_ids

An argument named "channel_ids" is not expected here.

Error: Missing required argument
  on ../../../../../../var/folders/t1/snd3btxx59sfx8f3_6c_wpk40000gn/T/tmp.6nmzUTM4/main.tf line 3, in resource "newrelic_alert_channel" "alert_notification_email":
   3: resource "newrelic_alert_channel" "alert_notification_email" {

The argument "configuration" is required, but no definition was found.

Error: Unsupported block type
  on ../../../../../../var/folders/t1/snd3btxx59sfx8f3_6c_wpk40000gn/T/tmp.6nmzUTM4/main.tf line 7, in resource "newrelic_alert_channel" "alert_notification_email":
   7:   config {

Blocks of type "config" are not expected here.

Error: Reference to undeclared resource
  on ../../../../../../var/folders/t1/snd3btxx59sfx8f3_6c_wpk40000gn/T/tmp.6nmzUTM4/main.tf line 37, in module "WebPortal-demo-monitor":
  37:       data.newrelic_alert_channel.alert_notification_email.id

A data resource "newrelic_alert_channel" "alert_notification_email" has not
been declared in the root module.

'AND accountId = var.account_id' clause breaking alerts

Hi,

My NR account does not appear to include an accountId field on transactions, so all queries which included this clause would produce zero results for me.

I made a fork with this clause removed, and it works for me. Any ideas why this wouldn't be working on my account?
It is a free/single-user account.

versions.tf in the module is referring to wrong path of newrelic provider

required_providers {
newrelic = ">= 2.2.1"
}

The above code in versions.tf is referring to newrelic provider source 'registry.terraform.io/hashicorp/newrelic' which doesn't exist. Hence while trying to execute 'terraform init' we are getting the below error:

Initializing provider plugins...
- Finding latest version of hashicorp/newrelic...
- Reusing previous version of newrelic/newrelic from the dependency lock file
- Using previously-installed newrelic/newrelic v2.49.1
╷
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/newrelic: provider registry registry.terraform.io does not have a provider named
│ registry.terraform.io/hashicorp/newrelic
│
│ Did you intend to use newrelic/newrelic? If so, you must specify that source address in each module which requires that provider. To see which modules are currently  
│ depending on hashicorp/newrelic, run the following command:
│     terraform providers

To resolve this error, under the required_providers section, newrelic provider source should be referred as 'newrelic/newrelic' similar to the one in the terraform registry documentation under 'Use Provider' section - https://registry.terraform.io/providers/newrelic/newrelic/2.49.1

Corrected versions.tf

terraform {
  required_version = ">= 0.12.6"

  required_providers {
    newrelic = {
      source  = "newrelic/newrelic"
      version = "~> 2.21"
    }
  }
}

Raised pull-request #10 to update versions.tf by including the above suggestions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.