Product News & Announcements
All the latest news and announcements about Splunk products. Subscribe and never miss an update!

Observability | Create Synthetics uptime HTTP test in bulk using CSV file

maulikp
Splunk Employee
Splunk Employee

In this blog post, we will look at how to create Synthetics uptime HTTP test in bulk using a CSV file with Splunk Observability Synthetics terraform provider.

This code requires Terraform version 0.13+.

Create a CSV file with details of uptime tests such as Test name, URL, SSL validation, frequency, locations etc. as following:

 

name,url,ssl_validation,frequency,scheduling_strategy,active,user_agent,locations
Google test,https://www.google.com,true,5,round_robin,true,Splunk (Default),"aws-us-east-1,aws-us-west-1"
Amazon test,https://www.amazon.com,true,5,concurrent,true,Splunk (Default),"aws-us-east-1"

 

The above example CSV file has following columns, please update the data in each columns as per your requirements:

Column Name

Description

name

Uptime test name

url

Uptime test URL

ssl_validation

Set to true if you want to enable TLS/SSL validation, otherwise set to false

frequency

Specify test frequency number (in minutes)

scheduling_strategy

Set round_robin if you want to enable Round-robin, otherwise set concurrent

active

Set to true if you want to enable test, otherwise set to false

user_agent

Provide the User agent string you want to use, otherwise set Splunk (Default)

locations

Provide the list of locations in double quotes separated by comma, such as "aws-us-east-1,aws-us-west-1" or "aws-us-east-1". Here's the list of available Splunk Synthetics public locations.


Create main.tf terraform file as following in the same folder where your CSV file is located:

 

terraform {
  required_providers {
    synthetics = {
      version = "2.0.1"
      source   = "splunk/synthetics"
    }
  }
}

provider "synthetics" {
  product = "observability"
  realm     = "REPLACE_REALM"
  apikey   = "REPLACE_WITH_API_TOKEN"
}

locals {
  http_test_data = csvdecode(file("${path.module}/<REPLACE_WITH_CSV_FILE_NAME>.csv"))
}

resource "synthetics_create_http_check_v2" "o11y_http_check" {
  for_each = { for test_data in local.http_test_data : test_data.name => test_data }

  test {
    active                          = each.value.active
    frequency                   = each.value.frequency
    location_ids            = split(",",each.value.locations)
    name                             = each.value.name
    type                                 = "http"
    url                                   = each.value.url
    scheduling_strategy = each.value.scheduling_strategy
    request_method            = "GET"
    verify_certificates = each.value.ssl_validation
    user_agent                    = each.value.user_agent
  }
}

 

You can modify the above terraform code as per your requirement, and data provided in CSV file.

Please note that, you will have to replace Splunk Observability realm, Splunk Observability API token and CSV file name.

Once terraform and CSV files are ready, run following commands to create HTTP uptime tests from CSV file:

  • terraform init - to initialize terraform provider
  • terraform plan - verify there are no errors
  • terraform apply - Type yes as confirmation

Voila! You have now created uptime tests using CSV data.

If you want to delete existing uptime tests created using terraform automation, please run the following command:

  • terraform destroy - Type yes as confirmation
Get Updates on the Splunk Community!

Database Performance Sidebar Panel Now on APM Database Query Performance & Service ...

We’ve streamlined the troubleshooting experience for database-related service issues by adding a database ...

IM Landing Page Filter - Now Available

We’ve added the capability for you to filter across the summary details on the main Infrastructure Monitoring ...

Dynamic Links from Alerts to IM Navigators - New in Observability Cloud

Splunk continues to improve the troubleshooting experience in Observability Cloud with this latest enhancement ...