This repository has been archived by the owner on Dec 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAlert-service.yml
233 lines (223 loc) · 8.75 KB
/
Alert-service.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
consumes:
- application/json
produces:
- application/json
schemes:
- http
- https
swagger: '2.0'
info:
description: |-
Alert service provides the capabilities to monitor Intel® RSP Controller status and send alerts. Intel® RSP Controller status is updated periodically based on events sent through Heartbeat listener from EdgeX Core Data and alerts are generated when heartbeats are missed. Also, alert events are processed and posted to the REST endpoint specified.
__Configuration Values__
<blockquote>Alert service configuration is split between values set in a configuration file and those set as environment values in compose file. The configuration file is expected to be contained in a docker secret for production deployments, but can be on a docker volume for validation and development.
<blockquote><b>Configuration file values</b>
<blockquote>•<b> serviceName</b> - Runtime name of the service.</blockquote>
<blockquote>•<b> loggingLevel</b> - Logging level to use: "info" (default) or "debug" (verbose).</blockquote>
<blockquote>•<b> notificationChanSize</b> - Channel size of a go channel named as notificationChan.</blockquote>
<blockquote>•<b> port</b> - Port to run the service's HTTP Server on.</blockquote>
<blockquote>•<b> watchdogSeconds</b> - Time interval set to check the status of registered gateways</blockquote>
<blockquote>•<b> maxMissedHeartbeats</b> - Maximum heart beats that can be missed before the gateway gets deregistered.</blockquote>
<blockquote>•<b> cloudConnectorURL</b> - URL for Cloud-connector service.</blockquote>
<blockquote>•<b> cloudConnectorEndpoint</b> - Endpoint for Cloud-connector service.</blockquote>
<blockquote>•<b> mappingSkuURL</b> - URL for Product Data Service.</blockquote>
<blockquote>•<b> mappingSkuEndpoint</b> - Endpoint for Product Data Service.</blockquote>
<blockquote>•<b> telemetryEndpoint</b> - URL of the telemetry service receiving the metrics from the service.</blockquote>
<blockquote>•<b> telemetryDataStoreName</b> - Name of the data store in the telemetry service to store the metrics.</blockquote>
<blockquote>•<b> heartbeatDestination</b> - Destination to which heartbeats are forwarded.</blockquote>
<blockquote>•<b> alertDestination</b> - Destination to which alerts are sent.</blockquote>
<blockquote>•<b> alertDestinationAuthEndpoint</b> - If the alertDestination requires authorization, this endpoint is first used to fetch an authorization token according to the authorization type, client ID, and secret.</blockquote>
<blockquote>•<b> alertDestinationAuthType</b> - Authorization type, (e.g., oauth2), sent to the Cloud Connector Service.</blockquote>
<blockquote>•<b> alertDestinationClientID</b> - Authorization Client ID, sent to the Cloud Connector.</blockquote>
<blockquote>•<b> alertDestinationClientSecret</b> - Authorization Client Secret, sent to the Cloud Connector.</blockquote>
<blockquote>•<b> sendNotWhitelistedAlert</b> - If true, the service will check ASNs for product IDs that aren't whitelisted (e.g., the Product Data Service doesn't have an entry for the product ID) and send alerts when any are detected.</blockquote>
<blockquote>•<b> batchSizeMax</b> - </blockquote>
<pre><b>Example configuration file json
	{
		"serviceName": "Alert service",
		"loggingLevel": "debug",
		"notificationChanSize": 100,
		"port": "8080",
		"contextSensing": "127.0.0.1:8888",
		"watchdogSeconds": 1,
		"maxMissedHeartbeats": 3,
		"cloudConnectorURL": "http://127.0.0.1:8081",
		"cloudConnectorEndpoint": "/aws/invoke",
		"cloudConnectorEndpoint: "/callwebhook"
		"heartbeatEndpoint: "/heartbeat"
		"mappingSkuEndpoint: "/skus"
		"alertDestination: ""
		"heartbeatDestination: ""
		"batchSizeMax: 50
		"sendNotWhitelistedAlert: "false"
		"alertDestinationAuthEndpoint: ""
		"alertDestinationAuthType: ""
		"alertDestinationClientID: ""
		"alertDestinationClientSecret: ""
	}
</b></pre>
</blockquote>
__Secrets__
The following values/files are passed to the service via Docker Secrets
<blockquote>
<blockquote>•<b> configuration.json</b> - Configuration file referenced above</blockquote>
</blockquote>
title: Alert Service API
version: 0.0.1
host: 'alert-service:8080'
basePath: /
paths:
/:
get:
description: 'Endpoint that is used to determine if the application is ready to take web requests, i.e is healthy'
consumes:
- application/json
produces:
- application/json
schemes:
- http
tags:
- default
summary: Healthcheck Endpoint
operationId: Healthcheck
responses:
'200':
description: OK
/alert/alertmessage:
post:
description: |-
Alert message for events should be in request body payload in JSON format.<br><br>
Example AlertMessage Input:
```
{
	"application":"Inventory-service",
	"value": {
		"sent_on":1531522680000,
		"alert_description":"Deletion of system database tag collection is complete",
		"severity":"critical",
		"optional":"event alert related data"
	}
}
```
+ application - the application sending the alert message
+ sent_on - the time that alert message is sent in millisecond epoch
+ alert_description - the detailed message for the alert
+ severity - the severity of the alert
+ optional - contains any alert related data or evidence and can be omitted
Response will be either Ok or error messages when posting to cloud connector fails.
consumes:
- application/json
produces:
- application/json
schemes:
- http
summary: Send alert message for events and post the message to the cloud connector
operationId: sendAlertMessage
responses:
'200':
$ref: '#/responses/statusOk'
'400':
$ref: '#/responses/schemaValidation'
'500':
$ref: '#/responses/internalError'
'503':
$ref: '#/responses/serviceUnavailable'
definitions:
AdvanceShippingNotice:
description: AdvanceShippingNotice is the model containing advance shipping item epcs
type: object
properties:
asnId:
type: string
x-go-name: AsnID
eventTime:
type: string
x-go-name: EventTime
items:
type: array
items:
$ref: '#/definitions/AdvanceShippingNoticeItem'
x-go-name: Items
siteId:
type: string
x-go-name: SiteID
AdvanceShippingNoticeItem:
type: object
properties:
itemEpcs:
type: array
items:
type: string
x-go-name: Epcs
itemGtin:
type: string
x-go-name: ProductID
itemId:
type: string
x-go-name: Sku
ErrReport:
description: ErrReport is used to wrap schema validation errors int json object
type: object
properties:
description:
type: string
x-go-name: Description
errortype:
type: string
x-go-name: ErrorType
field:
type: string
x-go-name: Field
value:
type: object
x-go-name: Value
ProdData:
description: ProdData represents the product data schema in the database
type: object
properties:
productList:
type: array
items:
$ref: '#/definitions/ProductMetadata'
x-go-name: ProductList
ProductID:
description: ProductID represents the ProductID object
type: object
properties:
productId:
type: string
x-go-name: ProductID
ProductMetadata:
description: ProductMetadata represents the ProductList schema attribute in the database
type: object
properties:
productId:
type: string
x-go-name: ProductID
SkuMappingResponse:
description: |-
SkuMappingResponse is the model of the response from the mapping sku service
with the selection of only the product id
type: object
properties:
results:
type: array
items:
$ref: '#/definitions/ProdData'
x-go-name: ProdData
responses:
internalError:
description: JSONError is the response for errors that occur within the API.
headers:
error:
type: string
schemaValidation:
description: ErrorList provides a collection of errors for processing
schema:
type: array
items:
$ref: '#/definitions/ErrReport'
serviceUnavailable:
description: serviceUnavailable
statusOk:
description: statusOk