influxdata / influxdata/influxdb

Failed to evaluate map function 31:21-32:32

Open
#20,530 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

__Steps to reproduce:__
List the minimal actions needed to reproduce the behavior.

1. Create a dataset with the following values:
[double]_value: 63.5
[string]_field: CPU Temperature
[string]_measurement: 01
[string]agent_host: host01.com

![EXCEL_2021-01-17_08-08-09](https://user-images.githubusercontent.com/8303616/104859287-29b52780-58f2-11eb-8c80-1c40910e1cc7.png)

2. Create a custom alert task with below:
```
import "strings"
import "regexp"
import "influxdata/influxdb/monitor"
import "influxdata/influxdb/schema"
option task = {name: "Server CPU Temperature alert", every: 1m}
task_data = from(bucket: "telegraf")
|> range(start: -task.every)
|> filter(fn: (r) =>
(r["_measurement"] == "01" or r["_measurement"] == "02" or r["_measurement"] == "04" or r["_measurement"] == "05"))
|> filter(fn: (r) =>
(r["_field"] == "CPU Temperature" or r["_field"] == "CPU1 Temperature" or r["_field"] == "CPU2 Temperature"))
|> drop(columns: ["_start", "_stop"])
|> map(fn: (r) =>
({r with number: string(v: r._value)}))
|> last()
check = {
_check_id: "0000000000000001",
_check_name: "Server CPU Temperature alert",
_type: "custom",
tags: {},
}
ok = (r) =>
(r["number"] < "65")
info = (r) =>
(r["number"] > "65")
warn = (r) =>
(r["number"] > "75")
crit = (r) =>
(r["number"] > "80")
messageFn = (r) =>
("Server ${r.agent_host} ${r._field} is ${r.number}")
task_data
|> schema["fieldsAsCols"]()
|> monitor["check"](
data: check,
messageFn: messageFn,
ok: ok,
info: info,
warn: warn,
crit: crit,
)
```
3. Enable alert

__Expected behavior:__
Describe what you expected to happen.
Task to be completed successfully without any errors:

__Actual behavior:__
Describe What actually happened.
Error messages are emitted whenever the task is run:
```
ts=2021-01-17T01:59:00.131646Z lvl=info msg="Error exhausting result iterator" log_id=0RixFcr0000 service=task-executor error="runtime error @36:5-43:3: check: failed to evaluate map function: 32:21-32:32: interpolated expression produced a null value" name=experimental-to14
```

__Environment info:__

* System info:
```
Linux 4.19.126-1.ph3-esx x86_64
```
* InfluxDB version:
```
InfluxDB 2.0.3 (git: fe04d346df) build_date: 2020-12-15T01:00:16Z
```
* Other relevant environment details: K8S Pod deployment

__Config:__
Copy any non-default config values here or attach the full config as a gist or file.

__Logs:__
```
ts=2021-01-17T01:56:00.137595Z lvl=info msg="Error exhausting result iterator" log_id=0RixFcr0000 service=task-executor error="runtime error @36:5-43:3: check: failed to evaluate map function: 32:21-32:32: interpolated expression produced a null value" name=experimental-to14
ts=2021-01-17T01:57:00.195790Z lvl=info msg="Error exhausting result iterator" log_id=0RixFcr0000 service=task-executor error="runtime error @36:5-43:3: check: failed to evaluate map function: 32:21-32:32: interpolated expression produced a null value" name=experimental-to14
ts=2021-01-17T01:58:00.185748Z lvl=info msg="Error exhausting result iterator" log_id=0RixFcr0000 service=task-executor error="runtime error @36:5-43:3: check: failed to evaluate map function: 32:21-32:32: interpolated expression produced a null value" name=experimental-to14
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the custom alert task with the provided dataset and Flux query, focusing on the map function's string interpolation and the reported null-value error. Trace the task executor's handling of the map result and verify the task completes without emitting the error on the supplied input.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.