Task

View a report on splunk via the splunk API

Make sure that the report is contained inside an app only one user can reach

Ingredients

  • Custom App
  • User with rest API capabilities
  • Curl Command
  • Route to splunk REST API (port 8089)

Recipy

Creating user with REST API capabilities

Go ahead and create a second user for testing purposes. The Second user won’t have permissions to read reports in the custom app (my_custom_app). And should therefore not have the ability to access the report we want to expose via API.

The user role should be enough to allow access to the rest api. If not; create a new role with the following capabilities and assign it to your newly created user.

  • rest_apps_view
  • rest_properties_get
  • rest_properties_set
  • search

Define roles on the Splunk platform with capabilities | Splunk Docs

Creating a Custom App

Running Curl Searches

Examples from : What capabilities does a REST API only user need? – Splunk Community

Asynchronous search:

$ curl -u admin:changeit -k https://localhost:8089/services/search/jobs -d search="search index=_internal"
    <?xml version="1.0" encoding="UTF-8"?>
    <response>
      <sid>1520569635.358</sid>
    </response>

Fetching results:

$ curl -G -u admin:changeit -k https://localhost:8089/services/search/jobs/1520569635.358/results -d output_mode=csv    

Synchronous search:

$ curl -u admin:changeit -k https://localhost:8089/services/search/jobs/export -d output_mode=csv  -d search="search index=_internal |head 10"

Getting authentication token:

$ curl -k https://localhost:8089/services/auth/login --data-urlencode username=admin --data-urlencode password=changeit
<response>
  <sessionKey>lTsi0Gyhadou77kplKboa8_4DBsMbRB1gpu6sCEvIXIFotnMqNLOJyXQgCLdwM^uhDSRgxpfg_dG0gSbtRIkObpkWrbF2TisTo</sessionKey>
</response>

Running synchronous search with authentication token:

$ curl -k -H "Authorization: Splunk lTsi0Gyhadou77kplKboa8_4DBsMbRB1gpu6sCEvIXIFotnMqNLOJyXQgCLdwM^uhDSRgxpfg_dG0gSbtRIkObpkWrbF2TisTo" 
https://localhost:8089/services/search/jobs/export 
-d output_mode=csv  
-d search="search index=_internal |head 10"

Running synchronous search writing report into file

curl -k -u test_user:XXXXXX 
  --request POST 'https://localhost:8089/services/search/jobs/export' 
  --data-urlencode 'search=| loadjob savedsearch="test_user:my_custom_app:test_api_report"' 
  --data-urlencode 'output_mode=json' 
  -o report.json

Tests

Using a user that does not have access to the app where the saved search is stored, to view the results, is impossible.

Using a user that has access to the app where a lookup is stored to view lookups by running a search | inputlookup mysecretlookup yields results

There is no endpoint in which one can access a dashboard with a user that does not have any search rights but only displaying rights because the output is not HTML but only XML
Knowledge endpoint descriptions | Splunk Docs

Erkunden Sie inspirierende Geschichten und Experteneinblicke.

Dieser Abschnitt hebt den Zweck des Blogs hervor, indem er fesselnde Geschichten, Expertenmeinungen und wertvolle Erkenntnisse bietet, damit Leser lernen und wachsen können.

Blog Kategorien

Instagram

  • Splunk API call to display scheduled report

    Task View a report on splunk via the splunk API Make sure that the report is contained inside an app only one user can reach Ingredients Recipy Creating user with REST API capabilities Go ahead and create a second user for testing purposes. The Second user won’t have…

  • Spin down Disks in Proxmox Server.

    I would like to have a silent Server and therefore I would like to spin down my disks when I don’t need them. Luckily I use a nvme for all my virtual machine storage and an ssd for booting, which are practically silent. For Longterm Storage I have…

  • Flashing an LSI SAS controller in 2025, AKA „IT-mode“ and UEFI

    This is basically a copy paste of TechSomething instructions with helpful images: Scope: # I have a controller, LSI SAS9217-4i4e, wit IR firmware and want to switch it to IT firmware. Why: # I believed I could not access my disks directly over the shell with hdparm later I figured…

  • Fixing e1000e NIC issue in Proxmox

    My Prox Mox Server suddendly loses connectivity and cannot be reached. Neither the machines it virtualizes nor the web interface itsself is reponding. when checking journalctl I stumbled upon the following error e1000e 0000:00:19.0 eno1: Detected Hardware Unit Hang Here is the proposed solution: e1000e eno1: Detected Hardware…

  • Beitragsbild von Hallo Welt

    Hello world!

    This website, shall help me retain the knowledge I have aquired throughout the many little IT-projects I work on in a daily basis, whether it’s setting up a server, utilizing a new service or troubleshooting IT-Infrastructure. Come on this journey with me, maybe you will also find pieces…


Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert