Watcher alert not working for multiple query with percentage calculation

watcher alert not working for multiple query with percentage calculation

code
{
"trigger": {
"schedule": {
"interval": "2m"
}
},
"input": {
"chain": {
"inputs": [
{
"first": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"heartbeat-"
],
"types": [],
"body": {
"query": {
"bool": {
"must": [
{
"match_phrase": {
"http.url": "https://nexus-amazon-uat.intranet/"
}
},
{
"range": {
"@timestamp": {
"gte": "now-28d"
}
}
}
]
}
},
"_source": [
"message"
]
}
}
}
}
},
{
"second": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"heartbeat-
"
],
"types": ,
"body": {
"query": {
"bool": {
"must": [
{
"match_phrase": {
"http.url": "https://nexus-amazon-uat.intranet/"
}
},
{
"match": {
"monitor.status": "up"
}
},
{
"range": {
"@timestamp": {
"gte": "now-28d"
}
}
}
]
}
},
"_source": [
"message"
]
}
}
}
}
}
]
}
},
"condition": {
"script": {
"source": "ctx.vars_SLO_Percentage = ((ctx.payload.first.hits.total / ctx.payload.second.hits.total) * 100) <= 100",
"lang": "painless"
}
},
"actions": {
"email_administrator": {
"email": {
"profile": "standard",
"from": "noreply-ESaaS@xyz.com",
"to": [
"abc@xyz.com"
],
"subject": "ELASTIC STACK ALERT: SLO nexus V2 - SLO breached {{ctx.vars_SLO_Percentage}}",
"body": {
"html": "--Alerts Notification Details--
This alert triggered because a total of {{ctx.payload.second.hits.total}} Nexusv2 success hits and {{ctx.payload.first.hits.total}} nexusv2 total hits were found in the application within the last 24 hour!"
}
}
}
},
"metadata": {
"app": "dxdt",
"description": "Alert if status is down",
"env": "DX DT/Teamcity UAT"
},
"throttle_period_in_millis": 100000
}

i want to print value of ctx.vars_SLO_Percentage in subject line but its not generating .

this is working now used return .

"condition": {
"script": {
"source": "ctx.vars.SLO_percentage = ctx.payload.second.hits.total * 100 / ctx.payload.first.hits.total; return ctx.vars.SLO_percentage <= 100",
"lang": "painless"
}
},
"action