influxdata / influxdata/ui

NotificationRules: notification history records are being written twice

Open
#2,733 0 comments 0 reactions 0 assignees View on GitHub
bonitoo kind/bug team/automation team/ui team/unity
Dominant language
TypeScript
Stars
117
Forks
51
Avg merge
2d 15h
Merged PRs (30d)
4

Description

## About the bug

**Steps to reproduce:**
List the minimal actions needed to reproduce the behavior.

1. Create a simple http listener like the one below on an Amazon EC2 micro server and start it running with node
2. Write some sample lp data to influxdb
3. Create a deadman check based on that data with status set to critical
4. Create a notification endpoint directing notifications to the listener
5. Create a notification rule to send notifications to the listener on all critical statuses and with a short (eg 1m) interval.
6. Wait for checks and notifications to accumulate
7. Open the notification rule history

**Expected behavior:**

That the number of notifications shown in the history would be identical to the number of notification received by the listener.

**Actual behavior:**

The history is showing duplicates for every notification sent.

**Visual Proof:**

_Listener log_
```
~/app$ node app.js
Example app listening at http://0.0.0.0:3000
POST
DATA: {"_check_id":"083825a9f5ae1000","_check_name":"Ghost Check","_level":"crit","_measurement":"notifications","_message":"Check: Ghost Check is: crit","_notification_endpoint_id":"083825aa0c3ab000","_notification_endpoint_name":"Test HTTP Endpoint","_notification_rule_id":"083825aa20724000","_notification_rule_name":"Test Rule","_source_measurement":"wumpus","_source_timestamp":1632902862914000000,"_start":"2021-09-29T08:10:00Z","_status_timestamp":1632903060000000000,"_stop":"2021-09-29T08:12:00Z","_time":"2021-09-29T08:12:00Z","_type":"deadman","_version":1,"dead":true,"foo":"bar","mag":12.12}
POST
DATA: {"_check_id":"083825a9f5ae1000","_check_name":"Ghost Check","_level":"crit","_measurement":"notifications","_message":"Check: Ghost Check is: crit","_notification_endpoint_id":"083825aa0c3ab000","_notification_endpoint_name":"Test HTTP Endpoint","_notification_rule_id":"083825aa20724000","_notification_rule_name":"Test Rule","_source_measurement":"wumpus","_source_timestamp":1632902862914000000,"_start":"2021-09-29T08:11:00Z","_status_timestamp":1632903120000000000,"_stop":"2021-09-29T08:13:00Z","_time":"2021-09-29T08:13:00Z","_type":"deadman","_version":1,"dead":true,"foo":"bar","mag":12.12}
POST
DATA: {"_check_id":"083825a9f5ae1000","_check_name":"Ghost Check","_level":"crit","_measurement":"notifications","_message":"Check: Ghost Check is: crit","_notification_endpoint_id":"083825aa0c3ab000","_notification_endpoint_name":"Test HTTP Endpoint","_notification_rule_id":"083825aa20724000","_notification_rule_name":"Test Rule","_source_measurement":"wumpus","_source_timestamp":1632902862914000000,"_start":"2021-09-29T08:12:00Z","_status_timestamp":1632903180000000000,"_stop":"2021-09-29T08:14:00Z","_time":"2021-09-29T08:14:00Z","_type":"deadman","_version":1,"dead":true,"foo":"bar","mag":12.12}
POST
DATA: {"_check_id":"083825a9f5ae1000","_check_name":"Ghost Check","_level":"crit","_measurement":"notifications","_message":"Check: Ghost Check is: crit","_notification_endpoint_id":"083825aa0c3ab000","_notification_endpoint_name":"Test HTTP Endpoint","_notification_rule_id":"083825aa20724000","_notification_rule_name":"Test Rule","_source_measurement":"wumpus","_source_timestamp":1632902862914000000,"_start":"2021-09-29T08:13:00Z","_status_timestamp":1632903240000000000,"_stop":"2021-09-29T08:15:00Z","_time":"2021-09-29T08:15:00Z","_type":"deadman","_version":1,"dead":true,"foo":"bar","mag":12.12}
POST
DATA: {"_check_id":"083825a9f5ae1000","_check_name":"Ghost Check","_level":"crit","_measurement":"notifications","_message":"Check: Ghost Check is: crit","_notification_endpoint_id":"083825aa0c3ab000","_notification_endpoint_name":"Test HTTP Endpoint","_notification_rule_id":"083825aa20724000","_notification_rule_name":"Test Rule","_source_measurement":"wumpus","_source_timestamp":1632902862914000000,"_start":"2021-09-29T08:14:00Z","_status_timestamp":1632903300000000000,"_stop":"2021-09-29T08:16:00Z","_time":"2021-09-29T08:16:00Z","_type":"deadman","_version":1,"dead":true,"foo":"bar","mag":12.12}
```
_Notification Rule history_

![DoubleNotificationRecs01](https://user-images.githubusercontent.com/25881301/135233207-fc03e123-2ed2-4a33-a3c3-af6db7901b63.png)

_Note as well the duplicate time stamps_

## About your environment

**Environment info:**

Testing against latest k8sidpe (e8f71581523c ...) and latest UI (dc09f0115709db8c011deb9b39f4b6eaca7e9128) as APP_NAME on an Ubuntu 20.04 environment.

### Simple Listener

```javascript
const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => {
res.send('Hello World!')
})

app.post('/', (req,res) => {
console.log('POST')

let body = ''

req.on('data', (data) => {

console.log(`DATA: ${data}`)
body += data
})

req.on('end', () => {
res.writeHead(200, {'Content-Type': 'text'})
res.end(`received: \n ${body} \n`)
})

// res.send('POST received\n')
})

app.listen(port, '0.0.0.0', () => {
console.log(`Example app listening at http://0.0.0.0:${port}`)
})

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.