influxdata / influxdata/kapacitor

Kapacitor : Coping with missing field

Open
#2,160 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.4k
Forks
479
Avg merge
4d 16h
Merged PRs (30d)
4

Description

Hi!
I've got a bit of a strange dataset where I have Jenkins logging data into InfluxDB for execution times etc under two specific measurements - job, stage. I'd like to pickup both, augment with additional information from Jenkins via UDF, then put back into InfluxDB for presentation etc.

Unfortunately, the job measurement uses a field 'jobtime' and the stage measurement uses a field 'stagetime' - all other relevant tags/fields are identical. If I pickup both separately everything works fine, however if I try to combine the two I'm hitting issues.

**Relevant Code: (tick)**
```
var buildRuns = stream
|from()
.database( jenkins_dbrp )
.retentionPolicy('autogen')
buildRuns
|eval(lambda: if( isPresent("jobtime"), (float("jobtime") / float(1000) ), float(0) ))
.as('time_secs')
.keep()

|eval(lambda: if( isPresent("stagetime"), (float("stagetime") / float(1000) ), float(0) ))
.as('time_secs')
.keep()
|OtherMagicalThings()
```

**The Error:**
For a 'stage' point:
_err="Failed to handle 2 argument: Cannot call function \"float\" argument \"jobtime\" is missing, values in scope are []"_

for a 'job' point:
_err="Failed to handle 2 argument: Cannot call function \"float\" argument \"stagetime\" is missing, values in scope are []"_

Is there a simple way to handle this that I'm missing? I've tried combining them into a single lamda if but no dice..

Help!

Contributor guide

Open the contributing guide

Research direction

Reproduce the TICK stream with the job and stage measurements, focusing on the eval lambda, isPresent checks, and float calls shown in the issue. Trace how missing fields are handled during eval and add coverage for both point types; done means the combined stream processes each point without the reported missing-field error.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
data, stream-processing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.