Validating configurations using the btool REST API

Use the btool REST API to validate configuration changes in Splunk Cloud Platform securely, reducing troubleshooting time and preventing system failures.

Use the btool REST API to securely validate configuration changes in Splunk Cloud Platform without CLI access. This API allows you to detect errors before deployment, reducing troubleshooting time, and preventing potential system failures.

The btool REST API is adapted to Splunk Cloud Platform deployments. It is an alternative to the btool CLI available in Splunk Enterprise.

Validate a configuration file using the btool REST API

Validate a configuration file in Splunk Cloud Platform, using the REST API that uses btool to verify the values assigned to configuration keys.

You need a configuration file with a corresponding .conf.spec file. For example:
Configuration file Specification file
inputs.conf inputs.conf.spec
outputs.conf outputs.conf.spec
savedsearches.conf savedsearches.conf.spec
To validate a configuration file using btool REST API, take the following steps:
  1. To prepare a configuration file for validation, copy it to the current directory and save it to a file with a .conf extension, for example, inputs.conf.
  2. Send a REST API request following the endpoint pattern:
    CODE
    POST /services/properties/<config_file>?validate=true
    where:
    • <config_file> - Name of the configuration file without the .conf extension

    • validate=true - Required query parameter that triggers validation.

    CODE
    curl -k -u admin:password -X POST \
         --data-binary @inputs.conf \
         "https://splunk-instance:8089/services/properties/inputs?validate=true"
    where:
    • --data-binary - Flag that informs curl to send data to the HTTP server without any processing.

    • @inputs.conf - Path to a local configuration file to be validated. The @ prefix informs curl that inputs.conf is a file path. As a result, curl sends the contents of this file in the request body.

  3. Verify the validation results in the server response.
    Possible validation status:
    • success - Returns HTTP status code 200: OK.

      Example:
      JSON
      {
        "validation_status": "success",
         "config_type": "inputs",
          "content_size": "156"
      }
    • failed - Returns HTTP status code 400: Bad Request.

      Example:
      JSON
      {
        "validation_status": "failed",
         "config_type": "inputs",
         "content_size": "234",
         "error_count": "2",
         "errors": [
            "Invalid key in stanza [monitor:///var/log/app.log] in inputs.conf, line 2: invalid_setting (value: bad_value).",
            "Invalid key in stanza [tcp://9997] in inputs.conf, line 5: unknown_param (value: test)."
      	]
      } 
      where:
      • config_type - Type of the validated configuration file

      • content_size - Size of the validated configuration in bytes

      • error_count - Number of validation errors. This field appears when the validation status is failed.

      • errors - Validation errors returned by btool REST API.