Is there anyway through api or other to check whet...
# gooddata-cloud
c
Is there anyway through api or other to check whether a metric is currently being used in a visual?
k
Yes, there are a couple of approaches you can use to find out if a metric is being used in a visualization: 1. Dependency Graph API The most direct option is the Dependency Graph API. Specifically, the endpoint
<https://www.gooddata.com/docs/cloud/api-and-sdk/api/api_reference_all/#operation/getDependentEntitiesGraphFromEntryPoints|getDependentEntitiesGraphFromEntryPoints>
allows you to pass the ID of a metric and it will return all dependent objects — including visualizations and dashboards that reference it. [dependency graph API] > Note: Based on community feedback, this API works in one direction — passing a metric ID will return the objects that depend on it (e.g., visualizations, dashboards). The reverse (passing a dashboard ID to get its dependencies) does not appear to work as expected. [dashboard dependency discussion] 2. Manual traversal via REST API If the Dependency Graph API doesn't fully meet your needs, you can also do this manually: 1. Fetch all visualizations in a workspace via the visualization objects API. 2. Inspect each visualization's definition to check if your metric ID is referenced within it. This is confirmed as a valid approach by GoodData support. [dashboard dependency discussion] 3. Python SDK You can also use the GoodData Python SDK to programmatically fetch all visualizations and inspect their definitions for metric references, which can be integrated into automated or CI/CD workflows. [broken visualizations discussion] ------------------------- Recommendation: Start with the Dependency Graph API endpoint, as it is the most purpose-built option for this use case. If you need more control or automation, the Python SDK with custom scripting is the next best approach. 👍 0 button 👎 0 button â„šī¸ Tip: Mention @kapa.ai in the thread for follow-ups. 👀 Our Support team monitors all messages and will jump in if needed.
c
The dependency graph is a good start but it seems to spit out unique IDs rather than visual names is there anyway to get visual names?
j
Hi Chris, To get the names of the visuals, you can use the Visualization Objects API. This API allows you to fetch all visualizations in a workspace. Each visualization's definition includes its name, which you can then match with the unique IDs you got from the Dependency Graph API. Here is the endpoint for the Visualization Objects API:
GET /api/v1/entities/workspaces/{workspaceId}/visualizationObjects
Please note that this approach requires manual traversal and inspection of each visualization's definition to check if your metric ID is referenced within it. For more details, you can refer to the GoodData API documentation.