Dynamically adding check tags to tasks

First time really diving into Flux and I’m digging around in the documentation, but a little lost. My goal is to add tag values to a check based on an element of the results, such as a prometheus annotation, or in the example code here, just container_name. That value is part of the filter expression, so it isn’t null in any result.

import "influxdata/influxdb/monitor"
import "influxdata/influxdb/v1"

task_data = from(bucket: "kubernetes")
	|> range(start: -1m)
	|> filter(fn: (r) =>
		(r["_measurement"] == "kubernetes_pod_container"))
	|> filter(fn: (r) =>
		(r["_field"] == "cpu_usage_nanocores"))
	|> filter(fn: (r) =>
		(r["container_name"] =~ /^selenium.*$/))
	|> aggregateWindow(every: 1m, fn: mean, createEmpty: false)

option task = {name: "Testing Flux", every: 1m, offset: 0s}

containerName = (r) =>
	(r["container_name"])
check = {
	_check_id: "testtest12341234",
	_check_name: "Testing Flux",
	_type: "threshold",
	tags: {container: containerName},
}
crit = (r) =>
	(r["cpu_usage_nanocores"] > 1000.5)
ok = (r) =>
	(r["cpu_usage_nanocores"] < 1000.5)
messageFn = (r) =>
	("${r.pod_name} CPU nanocore usage is ${r._level}. Container name: ${string(v: containerName)}")

task_data
	|> v1["fieldsAsCols"]()
	|> monitor["check"](
		data: check,
		messageFn: messageFn,
		crit: crit,
		ok: ok,
	)

I’ve moved things in and out of the messageFn value for troubleshooting purposes, but what I’m gathering here is that when I’m assigning containerName, it’s not actually getting the string value or something which can be converted to a string. It looks right to me though looking at the other assignment values. I’ve tried using the string function in the assignment, and also tried assigning it with the same string formatting syntax as the messageFn variable. ${r.container_name} in messageFn even works, I just can’t seem to assign it.

Is there some method I’m just not understanding so far? Am I maybe getting into something unsupported? This is v2.0.2.

In case it looks silly, the nanocores thresholds are impossibly low on purpose to make it fire.

So, this is kind of hilarious, I didn’t realize those were already tags according to the check, I figured it was looking for a different kind of tag value. This exercise was completely meaningless.

I still want to know what the logic would be to passing the value returned by a lambda to a variable for reuse, but since the purpose of this ticket was identified, will close.