Skip to content

Commit 910a661

Browse files
author
Jongmin Kim
authored
Merge pull request #92 from whdalsrnt/master
feat: implement alert manager APIs
2 parents ea6adf4 + 49e7b5b commit 910a661

File tree

24 files changed

+327
-10
lines changed

24 files changed

+327
-10
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import grpcClient from '@lib/grpc-client';
2+
3+
4+
const listAlerts = async (params) => {
5+
const alertManagerV1 = await grpcClient.get('alert_manager', 'v1');
6+
return await alertManagerV1.Alert.list(params);
7+
};
8+
9+
export {
10+
listAlerts
11+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import grpcClient from '@lib/grpc-client';
2+
3+
4+
const listEscalationPolicies = async (params) => {
5+
const alertManagerV1 = await grpcClient.get('alert_manager', 'v1');
6+
return await alertManagerV1.EscalationPolicy.list(params);
7+
};
8+
9+
export {
10+
listEscalationPolicies
11+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import grpcClient from '@lib/grpc-client';
2+
3+
4+
const listEventRules = async (params) => {
5+
const alertManagerV1 = await grpcClient.get('alert_manager', 'v1');
6+
return await alertManagerV1.EventRule.list(params);
7+
};
8+
9+
export {
10+
listEventRules
11+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import grpcClient from '@lib/grpc-client';
2+
3+
4+
const listNotes = async (params) => {
5+
const alertManagerV1 = await grpcClient.get('alert_manager', 'v1');
6+
return await alertManagerV1.Note.list(params);
7+
};
8+
9+
export {
10+
listNotes
11+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import grpcClient from '@lib/grpc-client';
2+
3+
4+
const listNotificationProtocols = async (params) => {
5+
const alertManagerV1 = await grpcClient.get('alert_manager', 'v1');
6+
return await alertManagerV1.NotificationProtocol.list(params);
7+
};
8+
9+
export {
10+
listNotificationProtocols
11+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import grpcClient from '@lib/grpc-client';
2+
3+
4+
const listServiceChannels = async (params) => {
5+
const alertManagerV1 = await grpcClient.get('alert_manager', 'v1');
6+
return await alertManagerV1.ServiceChannel.list(params);
7+
};
8+
9+
export {
10+
listServiceChannels
11+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import grpcClient from '@lib/grpc-client';
2+
3+
4+
const listServices = async (params) => {
5+
const alertManagerV1 = await grpcClient.get('alert_manager', 'v1');
6+
return await alertManagerV1.Service.list(params);
7+
};
8+
9+
export {
10+
listServices
11+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import grpcClient from '@lib/grpc-client';
2+
3+
4+
const listUserChannels = async (params) => {
5+
const alertManagerV1 = await grpcClient.get('alert_manager', 'v1');
6+
return await alertManagerV1.UserChannel.list(params);
7+
};
8+
9+
export {
10+
listUserChannels
11+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import grpcClient from '@lib/grpc-client';
2+
3+
4+
const listUserGroupChannels = async (params) => {
5+
const alertManagerV1 = await grpcClient.get('alert_manager', 'v1');
6+
return await alertManagerV1.UserGroupChannel.list(params);
7+
};
8+
9+
export {
10+
listUserGroupChannels
11+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import grpcClient from '@lib/grpc-client';
2+
3+
4+
const listWebhooks = async (params) => {
5+
const alertManagerV1 = await grpcClient.get('alert_manager', 'v1');
6+
return await alertManagerV1.Webhook.list(params);
7+
};
8+
9+
export {
10+
listWebhooks
11+
};

src/lib/grpc-client/proto/plugin.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ message PluginRequest {
1919
string version = 2;
2020
UpgradeMode upgrade_mode = 3;
2121
google.protobuf.Struct options = 4;
22-
string schema = 5;
22+
string schema_id = 5;
2323
google.protobuf.Struct secret_data = 6;
2424
}
2525

@@ -35,7 +35,7 @@ message PluginInfo {
3535
UpgradeMode upgrade_mode = 3;
3636
google.protobuf.Struct options = 4;
3737
google.protobuf.Struct metadata = 5;
38-
string schema = 6;
38+
string schema_id = 6;
3939
string secret_id = 7;
4040
}
4141

src/lib/grpc-client/proto/query_v2.proto

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,13 @@ message AggregateProject {
140140
bool exclude_keys = 2;
141141
}
142142

143-
message AggregateUnwind {
144-
string path = 1;
145-
}
146-
147143
message AggregateCount {
148144
string name = 1;
149145
}
150146

151147
message StatisticsAggregate {
152148
oneof aggregate_alias {
153-
AggregateUnwind unwind = 1;
149+
Unwind unwind = 1;
154150
AggregateGroup group = 2;
155151
AggregateCount count = 3;
156152
google.protobuf.ListValue sort = 4;
@@ -180,7 +176,7 @@ message TimeSeriesAnalyzeQuery {
180176
Granularity granularity = 1;
181177
string start = 2;
182178
string end = 3;
183-
repeated string group_by = 4;
179+
google.protobuf.ListValue group_by = 4;
184180
repeated string field_group = 5;
185181
repeated Filter filter = 6;
186182
repeated Filter filter_or = 7;
@@ -189,10 +185,11 @@ message TimeSeriesAnalyzeQuery {
189185
google.protobuf.Struct fields = 10;
190186
google.protobuf.Struct select = 11;
191187
string keyword = 12;
188+
Unwind unwind = 13;
192189
}
193190

194191
message AnalyzeQuery {
195-
repeated string group_by = 1;
192+
google.protobuf.ListValue group_by = 1;
196193
repeated string field_group = 2;
197194
repeated Filter filter = 3;
198195
repeated Filter filter_or = 4;
@@ -201,6 +198,7 @@ message AnalyzeQuery {
201198
google.protobuf.Struct fields = 7;
202199
google.protobuf.Struct select = 8;
203200
string keyword = 9;
201+
Unwind unwind = 10;
204202
}
205203

206204
message ExportSearchQuery {
@@ -218,7 +216,7 @@ message ExportAnalyzeQuery {
218216
repeated Filter filter_or = 2;
219217
string keyword = 3;
220218
repeated Sort sort = 4;
221-
repeated string group_by = 5;
219+
google.protobuf.ListValue group_by = 5;
222220
google.protobuf.Struct fields = 6;
223221
google.protobuf.Struct select = 7;
224222
Page page = 8;

src/routes/alert-manager/alert.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import express from 'express';
2+
import asyncHandler from 'express-async-handler';
3+
4+
import * as alert from '@controllers/alert-manager/alert';
5+
6+
const router = express.Router();
7+
8+
const controllers = [
9+
{ url: '/list', func: alert.listAlerts }
10+
];
11+
12+
controllers.forEach((config) => {
13+
router.post(config.url, asyncHandler(async (req, res) => {
14+
res.json(await config.func(req.body));
15+
}));
16+
});
17+
18+
export default router;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import express from 'express';
2+
import asyncHandler from 'express-async-handler';
3+
4+
import * as escalationPolicy from '@controllers/alert-manager/escalation-policy';
5+
6+
const router = express.Router();
7+
8+
const controllers = [
9+
{ url: '/list', func: escalationPolicy.listEscalationPolicies }
10+
];
11+
12+
controllers.forEach((config) => {
13+
router.post(config.url, asyncHandler(async (req, res) => {
14+
res.json(await config.func(req.body));
15+
}));
16+
});
17+
18+
export default router;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import express from 'express';
2+
import asyncHandler from 'express-async-handler';
3+
4+
import * as eventRule from '@controllers/alert-manager/event-rule';
5+
6+
const router = express.Router();
7+
8+
const controllers = [
9+
{ url: '/list', func: eventRule.listEventRules }
10+
];
11+
12+
controllers.forEach((config) => {
13+
router.post(config.url, asyncHandler(async (req, res) => {
14+
res.json(await config.func(req.body));
15+
}));
16+
});
17+
18+
export default router;

src/routes/alert-manager/index.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import express from 'express';
2+
3+
import alertRouter from './alert';
4+
import escalationPolicyRouter from './escalation-policy';
5+
import eventRuleRouter from './event-rule';
6+
import noteRouter from './note';
7+
import notificationProtocolRouter from './notification-protocol';
8+
import serviceRouter from './service';
9+
import serviceChannelRouter from './service-channel';
10+
import userChannelRouter from './user-channel';
11+
import userGroupChannelRouter from './user-group-channel';
12+
import webhookRouter from './webhook';
13+
14+
const router = express.Router();
15+
16+
router.use('/alert', alertRouter);
17+
router.use('/escalation-policy', escalationPolicyRouter);
18+
router.use('/event-rule', eventRuleRouter);
19+
router.use('/note', noteRouter);
20+
router.use('/notification-protocol', notificationProtocolRouter);
21+
router.use('/service', serviceRouter);
22+
router.use('/service-channel', serviceChannelRouter);
23+
router.use('/user-channel', userChannelRouter);
24+
router.use('/user-group-channel', userGroupChannelRouter);
25+
router.use('/webhook', webhookRouter);
26+
27+
export default router;

src/routes/alert-manager/note.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import express from 'express';
2+
import asyncHandler from 'express-async-handler';
3+
4+
import * as note from '@controllers/alert-manager/note';
5+
6+
const router = express.Router();
7+
8+
const controllers = [
9+
{ url: '/list', func: note.listNotes }
10+
];
11+
12+
controllers.forEach((config) => {
13+
router.post(config.url, asyncHandler(async (req, res) => {
14+
res.json(await config.func(req.body));
15+
}));
16+
});
17+
18+
export default router;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import express from 'express';
2+
import asyncHandler from 'express-async-handler';
3+
4+
import * as notificationProtocol from '@controllers/alert-manager/notification-protocol';
5+
6+
const router = express.Router();
7+
8+
const controllers = [
9+
{ url: '/list', func: notificationProtocol.listNotificationProtocols }
10+
];
11+
12+
controllers.forEach((config) => {
13+
router.post(config.url, asyncHandler(async (req, res) => {
14+
res.json(await config.func(req.body));
15+
}));
16+
});
17+
18+
export default router;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import express from 'express';
2+
import asyncHandler from 'express-async-handler';
3+
4+
import * as serviceChannel from '@controllers/alert-manager/service-channel';
5+
6+
const router = express.Router();
7+
8+
const controllers = [
9+
{ url: '/list', func: serviceChannel.listServiceChannels }
10+
];
11+
12+
controllers.forEach((config) => {
13+
router.post(config.url, asyncHandler(async (req, res) => {
14+
res.json(await config.func(req.body));
15+
}));
16+
});
17+
18+
export default router;

src/routes/alert-manager/service.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import express from 'express';
2+
import asyncHandler from 'express-async-handler';
3+
4+
import * as service from '@controllers/alert-manager/service';
5+
6+
const router = express.Router();
7+
8+
const controllers = [
9+
{ url: '/list', func: service.listServices }
10+
];
11+
12+
controllers.forEach((config) => {
13+
router.post(config.url, asyncHandler(async (req, res) => {
14+
res.json(await config.func(req.body));
15+
}));
16+
});
17+
18+
export default router;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import express from 'express';
2+
import asyncHandler from 'express-async-handler';
3+
4+
import * as userChannel from '@controllers/alert-manager/user-channel';
5+
6+
const router = express.Router();
7+
8+
const controllers = [
9+
{ url: '/list', func: userChannel.listUserChannels }
10+
];
11+
12+
controllers.forEach((config) => {
13+
router.post(config.url, asyncHandler(async (req, res) => {
14+
res.json(await config.func(req.body));
15+
}));
16+
});
17+
18+
export default router;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import express from 'express';
2+
import asyncHandler from 'express-async-handler';
3+
4+
import * as userGroupChannel from '@controllers/alert-manager/user-group-channel';
5+
6+
const router = express.Router();
7+
8+
const controllers = [
9+
{ url: '/list', func: userGroupChannel.listUserGroupChannels }
10+
];
11+
12+
controllers.forEach((config) => {
13+
router.post(config.url, asyncHandler(async (req, res) => {
14+
res.json(await config.func(req.body));
15+
}));
16+
});
17+
18+
export default router;

0 commit comments

Comments
 (0)