Configure a data input

In this walkthrough, we'll be configuring the template for this add-on to create data inputs, kind of an "input maker" for users of your add-on. Users will be able to create multiple data inputs based on this configuration we're creating here.

First, you'll need a source of data to set up a data input. For this walkthrough, we'll configure a data input that uses the Article Search API to search the New York Times articles to retrieve headlines, abstracts, and more. The data input we configure will search articles with a user-specified query. Add-on users will then be able to create a data input per query.

According to the Article Search API, the base URL is:
https://api.nytimes.com/svc/search/v2/articlesearch.json

The Article Search API parameters we'll use are:

  • q: Search term, to be provided by the add-on end user when creating a data input from this configuration. We'll use a token for this value in the REST request.
  • api-key: The New York Times API key, to be required by the user when setting up the add-on. We'll use a password field so that the value is obfuscated.
  • sort: Sorts results by "oldest" or "newest".
  • begin-date: Searches for articles beginning with the date specified, using the format "YYYYMMDD".

Refer to the Article Search API for details about the API and valid parameters.

Configure a data input

  1. On the add-on home page, click Configure Data Collection.
  2. On the Configure Data Collection page, click New Input.
  3. The Create Data Input wizards opens. Now we can create our data input.

Create Data Input wizard: Input Method

In this step, we'll select the type of data input to create.

  • On the Choose Input Method page, click Modular input using a REST API.
    This option creates a modular input for you, based on a REST URL that you provide.

Create Data Input wizard: Inputs & Parameters

  1. On the Create Data input page, specify the properties of the data input:
    • Source type name: enter "nytimes".
    • Input display name: Enter "NYTimes" for the data input title. This title appears in the Splunk Web UI.
    • Input name: Leave the auto-filled value, "nytimes".
    • Description: Enter "Data input for NYT article search" for the data input description.
    • Collection interval: Enter "86400", which means the add-on will request data once a day (every 86400 seconds). We will collect data once a day because the begin-date parameter is specified in days, rather than hours and minutes. Running this input any more frequently would result in duplicate data. You'd get the same data until the date changed.
  2. Click the Data Input Parameters tab.
  3. This page displays a form where you can configure the parameters that are specific to this data input. This form will be displayed to users of your add-on each time they create a data input from this configuration.

  4. From Component Library, drag and drop a Text field to the center panel. We'll use this field to prompt users for a query string to search on.
  5. Click the text field to select it, then specify the properties in the Property Editor:
    • Display label: enter "Query".
    • Internal name: leave the default value "query". We'll use this internal name to refer to this input later on.
    • Default display text: leave this blank.
    • Default value: leave this blank.
    • Help text: enter "Enter a phrase to search for" to provide users with help.
    • Required: select this option because a search term is required.
  6. Click the Add-on Setup Parameters tab.
  7. This page displays a form where you can configure the setup parameters that are common to your add-on. This form will be displayed to users of your add-on as a setup page to configure your add-on before using it.

  8. From Component Library, drag and drop a Password field to the center panel. We'll use a Password field to prompt users for their New York Times API key and obfuscate the value. We'll include this as a setup option because we only need to prompt for this value one time for the add-on rather than each time a data input is created.
  9. Click the password field to select it, then specify the properties in the Property Editor:
    • Display label: enter "API key".
    • Internal name: leave the default value "api_key". We'll use this internal name to refer to this input later on.
    • Default display text: leave this blank.
    • Default value: leave this blank.
    • Help text: enter "Enter your New York Times API key" to provide users with help.
    • Required: select this option because an API key is required.

    Now we have defined the properties of the data input, including the input parameters and setup parameters.

  10. Click Next.

>>  Continue to Define REST settings.