Splunk AppDynamics

API Access to Slow Transaction Thresholds, etc.

Robert_Bratton
Explorer

I want to import/export all the information on the "Show Transaction Thresholds" page Under Configuration: 
Slow Transaction Threshold, Very Slow Transaction Threshold, Stall, etc.

We want to make sure we're consistent across applications. We have many applications and several environments per application (Lab, QA, Production, etc).

Labels (1)
0 Karma
1 Solution

Robert_Bratton
Explorer

I was able to make it work by inserting the X-CSRF-Token as a header.

<code>

$uri = $BaseURL + "/controller/auth?action=login"
Invoke-WebRequest -uri $uri -headers $Headers -SessionVariable WebSession | out-null

$Uri = $BaseURL + "/controller/restui/dashboards/getAllDashboardsByType/false"

if (-not $headers.ContainsKey("X-CSRF-Token")) {
    $XCSRFToken = $WebSession.Cookies.GetCookies($uri) | Where-Object { $_.Name -eq 'X-CSRF-Token' } | Select-Object -First 1 -ExpandProperty Value
    $Headers.Add("X-CSRF-Token", $XCSRFToken)
}

$Result = Invoke-RestMethod -Uri $Uri -Headers $Headers -WebSession $WebSession

</code>

View solution in original post

iamryan
Community Manager
Community Manager

Hi @Robert.Bratton,

Have you seen our API Documentation page? If not, please check it out - https://docs.appdynamics.com/22.1/en/extend-appdynamics/appdynamics-apis

Let me know if you were able to find the right API you need in that list.

0 Karma

Robert_Bratton
Explorer

Thanks for the tip. I have viewed the API documentation.

Only the export API supports listing dashboards. I can't access that with the normal account I use for the AppDynamics web UI and non-export API methods (/controller/restui/dashboards/getAllDashboardsByType/false). The regular API methods can only export a dashboard for which you know the ID. I created a brute-force script that just attempts to export each ID from 1 to 32767. It's inefficient but better than exporting each dashboard manually through the web API.

Configuration Import and Export API (appdynamics.com)

Robert_Bratton
Explorer

I was able to make it work by inserting the X-CSRF-Token as a header.

<code>

$uri = $BaseURL + "/controller/auth?action=login"
Invoke-WebRequest -uri $uri -headers $Headers -SessionVariable WebSession | out-null

$Uri = $BaseURL + "/controller/restui/dashboards/getAllDashboardsByType/false"

if (-not $headers.ContainsKey("X-CSRF-Token")) {
    $XCSRFToken = $WebSession.Cookies.GetCookies($uri) | Where-Object { $_.Name -eq 'X-CSRF-Token' } | Select-Object -First 1 -ExpandProperty Value
    $Headers.Add("X-CSRF-Token", $XCSRFToken)
}

$Result = Invoke-RestMethod -Uri $Uri -Headers $Headers -WebSession $WebSession

</code>

iamryan
Community Manager
Community Manager

Hi @Robert.Bratton,

Thanks for doing some testing and reporting back. Knowledge sharing is what drives this community forward - so thanks for passing the solution along. 

0 Karma
Get Updates on the Splunk Community!

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...

Splunk App Dev Community Updates – What’s New and What’s Next

Welcome to your go-to roundup of everything happening in the Splunk App Dev Community! Whether you're building ...

The Latest Cisco Integrations With Splunk Platform!

Join us for an exciting tech talk where we’ll explore the latest integrations in Cisco &#43; Splunk! We’ve ...