influxdata / influxdata/kapacitor

stream calculation output weird result

Open
#2,252 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
2.4k
Forks
479
Avg merge
4d 16h
Merged PRs (30d)
4

Description

I have a tickscript to calculate success rate based on the live data.
Here is my function:
success_rate = count('status'<400)/count('all');
The stream result ususally shows that the success_rate < 100%. But when I look into the origin data, all the data's status is 200. So that the success rate should be 100%.

Here is my script :
`var span = 1m`
`var frequency = 1m`
`var db = 'myna_publish'`
`var retentionPolicy = 'real_time_capture'`
`var sourceMeasurement = 'myna_publish_log'`
`var resultMeasurement = 'myna_publish_success_rate_per_1m'`

`var success_requests = stream `
` |from()`
` .database(db)`
`.retentionPolicy(retentionPolicy)`
`.measurement(sourceMeasurement)`
`.where(lambda: int("http_status") < 400)`
` |window()`
` .period(span)`
` .every(frequency)`
` |count('response_time')`
` .as('success_count')`

`var total_requests = stream`
` |from()`
` .database(db)`
` .retentionPolicy(retentionPolicy)`
` .measurement(sourceMeasurement)`
` |window()`
` .period(span)`
` .every(frequency)`
` |count('response_time')`
` .as('total_count')`

`success_requests`
` |join(total_requests)`
` .as('success', 'total')`
` .tolerance(1s)`
` .fill(0.0)`
` .streamName('success_rate')`
` |eval(lambda: if(float("success.success_count") / float("total.total_count") >= 1.0, 1.0, float("success.success_count") / float("total.total_count")))`
` .as('success_rate')`
` |influxDBOut()`
` .database(db)`
` .retentionPolicy('cq_retention')`
` .measurement(resultMeasurement)`

OS: Linux version 2.6.32-642.15.1.el6.x86_64 (mockbuild@c1bm.rdu2.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) ) #1 SMP Fri Feb 24 14:31:22 UTC 2017
KapacitorVersion: Kapacitor OSS 1.5.1 (git: HEAD 89828ffff6cf5cd4cb2b34bf883e134395f734de)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the supplied Tickscript with input whose http_status values are all 200, focusing on the window, count, join, fill, and eval stages. Trace the intermediate success_count and total_count values; the work is done when the cause of the lower success_rate is identified and the all-success case consistently reports 100%.

Written by the indexing model from the issue text.

Assessment

Domain
stream-processing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.