Terraform Provider for Mezmo

Public BetaPublic Beta

About the Terraform Provider for Mezmo

Mezmo is a centralized log management platform. The Terraform provider from Mezmo allows organizations to manage Views and Alerts programmatically via Terraform commands. With the Terraform provider, which utilizes our Mezmo Configuration API, you can automate deployments of Views and Alerts to your Mezmo environment.

Read the full documentation on the official Terraform site. If you are interested in contributing to this project, the source is in GitHub.

Scenarios for Using the Terraform Provider

One use case for the Terraform provider is if you need to quickly spin up multiple Alerts on Views in several Kubernetes clusters and you need them to all be exactly the same. You can use Terraform to create and deploy the Alerts. Automation like this helps reduce the risk of error and speeds the process.

Other use cases include:

  • As a developer, I want to replicate a set of Views/Alerts with minor tweaks from a base template in the same or different account.
  • I want to manage my infrastructure and infrastructure SaaS apps (ex. PagerDuty, Sysdig, etc.) including Mezmo from the same toolset.
  • As a SRE manager, I want all changes to a critical set of views/alerts to be code reviewed so that my workflow and alerting doesn’t get disrupted by accident, and mistakes can be quickly undone.

Example

This example code for creating a new View and Alert is in HCL (Hashicorp Configuration Language).

terraform {
  required_providers {
    logdna = {
      source = "logdna/logdna"
      version = "1.0.0"
    }
  }
}
# Configure the LogDNA Provider
provider "logdna" {
  servicekey = <your_service_key_goes_here>
}

resource "logdna_view" "my_view" {
  apps     = ["app1", "app2"]
  categories = ["Demo1", "Demo2"]
  hosts    = ["host1", "host2"]
  levels   = ["fatal", "critical"]
  name     = "Email PagerDuty and Webhook View-specific Alerts"
  query    = "test"
  tags     = ["tag1", "tag2"]

  email_channel {
    emails          = ["[email protected]"]
    immediate       = "false"
    operator        = "absence"
    terminal        = "true"
    timezone        = "Pacific/Samoa"
    triggerinterval = "15m"
    triggerlimit    = 15
  }

  pagerduty_channel {
    immediate       = "false"
    key             = <your_service_key_goes_here>
    terminal        = "true"
    triggerinterval = "15m"
    triggerlimit    = 15
  }

  webhook_channel {
    bodytemplate = jsonencode({
      hello = "test1"
      test  = "test2"
    })
    headers = {
      hello = "test3"
      test  = "test2"
    }
    immediate       = "false"
    method          = "post"
    terminal        = "true"
    triggerinterval = "15m"
    triggerlimit    = 15
    url             = "https://yourwebhook/endpoint"
  }
}

📘

Your service key can be generated or retrieved from the Mezmo web application. Navigate to Settings > Organization > API Keys.

🚧

Note that if you create a new View using Terraform, but then delete the View by using the Mezmo Dashboard UI and not Terraform, then Terraform will not be aware of the deletion and displays an Error: Resource Not Found message.
For more information about handling "deletion drift" refer to our full documentation on the official Terraform site.

🚧

Be aware that running terraform plan and/or terraform apply may not display the full delta of possible changes, if TF is not aware of all existing Mezmo resources.