Datasource mismatch between Alert Rule and Screenshot

  • What Grafana version and what operating system are you using?

grafana: v11.6.1
image renderer: v3.12.6

  • What are you trying to achieve?
    I want to ensure that when an alert fires, the screenshot is generated using the specific datasource defined in that alert rule’s conditions.

  • How are you trying to achieve it?
    I’m using Grafana’s alerting feature with screenshots enabled via the following configuration:

unified_alerting.screenshots:
  capture: true
  upload_external_image_storage: true

and add Alert Rules with specific datasource.
It linked a dashboard panel.

  • What happened?
    When an alert rule enters the firing state, a screenshot is automatically generated as expected. However, the datasource used to generate this screenshot is not the one specified in the alert rule itself. Instead, it seems to be using a different datasource from the dashboard’s variables.

Is there a way to resolve this issue?

  • What did you expect to happen?
    I suspect it’s using either the default value for the var-datasource or the most recently saved one.