This feature now has it's own built-in endpoint: https://docs.datadoghq.com/api/latest/metrics/#related-assets-to-a-metric
The Related Assets to a Metric
endpoint is more stable and gets updated for any new assets.
This program utilizes the datadogpy API library to accept a list of metric names and return a list of dashboards and monitors in your account that use those metrics in their queries.
Add your API and App keys to config.py.Add your metric names into config.py.Runpython3 report.py
Reports will be placed in the results folder under the names report.*
API calls are expensive and time consuming. To avoid requesting all dashboard definitions from your account every time you want a metric report, results are cached in json format in the file db_cache.txt
. If that file exists, the script will automatically use those results instead.
To get a fresh list of dashboards, either rename or delete the file db_cache.txt
.
If a widget doesn't have a title, dashboards will generate one based off the query inside. That logic was a bit too complex for me to replicate, so I just named them unitled
to avoid having an empty string when displaying the widget in the report.