Dashboarding
Dynatrace dashboards, notebooks, and data explorer explained.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dashboard Variables in Code Tile

Mikko
Visitor

I'm building a dashboard with a code tile and I want to use a variable to filter my query. The variable is set on the dashboard, but I cannot find a way to reference it inside the code tile. I tried getting it through context:

export default async function (context) {
  console.log(context)
  const cluster = context.variables.Cluster;
  ...
}

The console out:

{
  "$dt_timeframe_from": "2026-06-05T04:47:00.000Z",
  "$dt_timeframe_to": "2026-06-05T06:47:00.000Z"
}

So basically my question is that is there any way to reference the Dashboard Variable within the code tile?

2 REPLIES 2

dannemca
DynaMight Guru
DynaMight Guru

Have you tried reference it "as is"? $yourvarname

I have a var called $Tenant in one of my Dashboards, and in the code tile I just mention the var as is, $Tenant

Screenshot 2026-06-05 100551.png

Site Reliability Engineer @ Kyndryl

AndyHubert
Observer

Yeah, you should just be able to reference it in the code with the standard $varName syntax. 

AndyHubert_0-1780668686484.png

 

Featured Posts