Splunk AppDynamics

Updating a dashboard template in json format with PowerShell?

Jonathan_Barrow
New Member

Question about working with Json data.

So I have a template file that is in json format that I need to work with.

Within that Json file there are a bunch of different "widgets". Within each widget, there is a listing of "entity" names, one per server (but invalid servers that need removed and replaced with this script).

I need to import this json file. Go into each widget. Look at the formatting of the existing entities, save that. Remove all the existing entities. Then add an entity for each server in my serverlist using the formatting template I saved.

The entities I need to remove are deep into the file, so that may throw a cog into this.

I have attached a screenshot of the entities that need to come out, you can see they are under .entityNames within each widget.

Any tips or suggestions would be helpful. I've been researching myself online.

The following text can be copied and pasted into your code editor:

# So far I'm able to successfully import my json data using this code
$jsoninput = Get-Content -Path "$thisfolder\APPD-DASHBOARD-GENERATOR.input.json" | ConvertFrom-Json
# I then run a foreach against each widget found within the json.
foreach ($widget in $jsoninput.widgetTemplates)
{
# I then look up the first entity in the widget, I'm going to use this as a template later.
$first1 = $widget.dataSeriesTemplates.metricMatchCriteriaTemplate.entityMatchCriteria.entityNames| Select-Object -First 1
# I then need a method for removing each of the existing entities found...
foreach ($entity in $widget.dataSeriesTemplates.metricMatchCriteriaTemplate.entityMatchCriteria.entityNames)
{
!!! Not sure what to do here !!!
}
# I then need a method for adding an entry for each server found in the server list.
foreach ($server in $servers)
{
# I have this template from earlier
$first1 
} 
}image.png

Labels (1)
0 Karma

Carl_Brahms
Path Finder

It's possible to do this, but I don't know powershell 😞 . I do this with a shell script, using sed to replace the entity names.  If you have the option of running this on a UNIX host I can send you an example of a script.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...