Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Generate a Filtered Screenshots of Dashboard Charts #32037

Open
juliacebria opened this issue Jan 30, 2025 · 5 comments
Open

Unable to Generate a Filtered Screenshots of Dashboard Charts #32037

juliacebria opened this issue Jan 30, 2025 · 5 comments
Labels
alert-reports Namespace | Anything related to the Alert & Reports feature

Comments

@juliacebria
Copy link

Discussed in #32036

Originally posted by juliacebria January 30, 2025
I have a dashboard with multiple charts, each showing data for different counties. I need to generate a PDF for each county with the relevant filtered data.

If generating a filtered PDF is not possible, I want to capture a screenshot of each chart individually with the county filter applied. However, when using GET /api/v1/chart/{pk}/cache_screenshot/, the API does not allow filtering.

Is there a way to pass filters when generating a screenshot via API, or an alternative method to schedule or generate a filtered PDF of the dashboard?

@dosubot dosubot bot added the alert-reports Namespace | Anything related to the Alert & Reports feature label Jan 30, 2025
Copy link

dosubot bot commented Jan 30, 2025

Hello @juliacebria! I'm here to help you with any bugs, questions, or contributions you have.

There is a way to pass filters when generating a screenshot via the API in Apache Superset. You can use the DownloadScreenshot component, which utilizes the dataMask from the Redux state to include the current filter state of the dashboard. This dataMask is part of the jsonPayload in the POST request to the /api/v1/dashboard/${dashboardId}/cache_dashboard_screenshot/ endpoint, ensuring that the screenshot reflects the current filters applied to the dashboard [1].

Additionally, you can generate a PDF of the dashboard with the applied filters. The process involves caching the screenshot and then retrieving it in PDF format using functions like cache_dashboard_screenshot and build_pdf_from_screenshots, which ensure that the PDF reflects the current state of the dashboard, including any filters [2].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

Copy link

dosubot bot commented Jan 30, 2025

A 404 Not Found response when accessing the /api/v1/dashboard/{dashboard_id}/cache_dashboard_screenshot/ endpoint can occur for several reasons:

  1. Dashboard Not Found: Ensure that the dashboard_id (in your case, 2) corresponds to an existing dashboard. If the dashboard does not exist, a 404 response will be returned [1].

  2. Feature Flags Disabled: The endpoint requires the THUMBNAILS and ENABLE_DASHBOARD_SCREENSHOT_ENDPOINTS feature flags to be enabled. If either of these flags is disabled, the endpoint will return a 404 response [1].

  3. Incorrect Payload Structure: The payload structure you are using seems incorrect. The expected payload should be a JSON object with the following structure:

    {
        "dataMask": {},
        "activeTabs": [],
        "anchor": "",
        "urlParams": []
    }

    Ensure that your payload matches this structure. The dataMask should be directly within the main JSON object, not nested under jsonPayload [1][2].

Please verify these aspects to resolve the 404 error.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@juliacebria
Copy link
Author

Thank you! That worked and now I get Status Code: 202 and the cache_key.

No obstant, I'm encountering a 404 Not Found error when trying to retrieve a cached screenshot using the following API endpoint:

GET http://localhost:8088/api/v1/dashboard/2/screenshot/{cache_key}/

The cache_key I received from a previous API call is bed09521aa9f663df42b625577cff7b5. I correctly replace {cache_key} with the actual value, but I still get the 404 Not Found error, with the following response:

{
"message": "Not found"
}

Copy link

dosubot bot commented Jan 30, 2025

A 404 Not Found error when trying to retrieve a cached screenshot using the cache_key can occur for a couple of reasons:

  1. Dashboard Does Not Exist: Ensure that the dashboard with the specified ID (in your case, 2) actually exists. If the dashboard does not exist, a 404 response will be returned.

  2. Screenshot Not in Cache: Even if the dashboard exists, the screenshot might not be available in the cache. The cache might not have been set correctly, or it might have expired or been cleared.

Make sure that the cache_key is valid and that the cache is properly configured and operational. If the cache key was set with a timeout, it might have expired, leading to the screenshot not being found in the cache [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@juliacebria
Copy link
Author

juliacebria commented Jan 30, 2025

@dosu
I am able to successfully post to the cache dashboard screenshot API endpoint (/api/v1/dashboard/2/cache_dashboard_screenshot/) and receive a 202 Accepted status with a valid cache_key in the response.

However, when I try to fetch the screenshot using the generated cache_key with the following endpoint:

GET http://localhost:8088/api/v1/dashboard/2/screenshot/{cache_key}/

I get a 404 Not Found error with the response message "Not found", even though the dashboard exists and the cache key seems correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alert-reports Namespace | Anything related to the Alert & Reports feature
Projects
None yet
Development

No branches or pull requests

1 participant