Browse Source

告警详情聚集

dev
巴林闲侠 2 years ago
parent
commit
35d6660622
  1. 8
      api/app/lib/controllers/alarm/data.js
  2. 3
      api/app/lib/routes/alarm/index.js

8
api/app/lib/controllers/alarm/data.js

@ -161,9 +161,15 @@ async function confirm (ctx) {
async function detailAggregation (ctx) {
try {
const { models } = ctx.fs.dc;
const { alarmId } = ctx.query
const { clickHouse } = ctx.app.fs
const alarmDetailAggRes = await clickHouse.dataAlarm.query(`
SELECT formatDateTime(Time,'%F %H') days, count(AlarmId) count from alarm_details WHERE AlarmId=${AlarmId} group by days;
`).toPromise();
ctx.status = 200;
ctx.body = []
ctx.body = alarmDetailAggRes
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: error`);
ctx.status = 400;

3
api/app/lib/routes/alarm/index.js

@ -35,6 +35,9 @@ module.exports = function (app, router, opts) {
app.fs.api.logAttr['GET/alarm/data/detail'] = { content: '查询数据告警详情', visible: true };
router.get('/alarm/data/detail', dataAlarm.detail);
app.fs.api.logAttr['GET/alarm/data/detail_agg'] = { content: '查询数据告警详情聚集数据', visible: true };
router.get('/alarm/data/detail_agg', dataAlarm.detailAggregation);
app.fs.api.logAttr['PUT/alarm/data/confirm'] = { content: '确认数据告警', visible: true };
router.put('/alarm/data/confirm', dataAlarm.confirm);
};

Loading…
Cancel
Save