/conf23-dev1091b

Come back soon :)

Primary LanguagePython

Introduction

This is intended to assist users in the DEV1091B workshop at Splunk .conf23 in Las Vegas, however you may find some of these resources helpful when starting out using Splunk's UCC app framework.

The aim of the workshop is to introduce you to UCC and walk through how to get started with a simple API data collection example. In this case we are pulling energy usage data from Equine Energy's API).

Note: Equine Energy is a ficitious company used for the purposes of the workshop. We intend to keep the API available for a number of weeks after the conference to allow you to continue using it for development.

Prerequisites

Snippets

  • Validate UCC is installed and working:
    ucc-gen --help

  • Create Barebones app
    ucc-gen init --addon-name "ta_equine_energy" --addon-display-name "Equine Energy Add-on for Splunk" --addon-input-name energy_usage --addon-rest-root ta_equine_energy

  • Build app: ucc-gen build --ta-version 1.0.0

  • Package app: slim package output/ta_equine_energy

Code addition

import requests
def get_data_from_api(logger: logging.Logger, api_key: str):
    logger.info("Getting data from an external API")
    resp = requests.get(
                "https://energyapi.splunk.engineer/getUsage",
                headers = {"x-api-key":api_key}
            )
    return resp.json()

Also see the full Python script energy_usage.py

Useful Links