Merge ~peppepetra/charm-graylog:graylog-dashboard into charm-graylog:master
- Git
- lp:~peppepetra/charm-graylog
- graylog-dashboard
- Merge into master
Status: | Merged |
---|---|
Approved by: | James Troup |
Approved revision: | 06ad4db144a8998dded82f441cf06bed4eda0d41 |
Merged at revision: | fbdfd95fe6aa6bf4af920ed0c2db2cf8c1005292 |
Proposed branch: | ~peppepetra/charm-graylog:graylog-dashboard |
Merge into: | charm-graylog:master |
Diff against target: |
710 lines (+642/-0) 5 files modified
src/README.md (+18/-0) src/files/content_packs/messages_sources_dashboard.json (+589/-0) src/lib/charms/layer/graylog/api.py (+17/-0) src/lib/charms/layer/graylog/constants.py (+1/-0) src/reactive/graylog.py (+17/-0) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
🤖 prod-jenkaas-bootstack (community) | continuous-integration | Approve | |
BootStack Reviewers | Pending | ||
BootStack Reviewers | Pending | ||
Review via email: mp+415076@code.launchpad.net |
Commit message
Add Top messages sources dashboard.
Description of the change
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote : | # |
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote : | # |
FAILED: Continuous integration, rev:4e475357617
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want jenkins to rebuild you need to trigger it yourself):
https:/
https:/
Executed test runs:
FAILURE: https:/
None: https:/
Click here to trigger a rebuild:
https:/
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote : | # |
This merge proposal is being monitored by mergebot. Change the status to Approved to merge.
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote : | # |
A CI job is currently in progress. A follow up comment will be added when it completes.
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote : | # |
PASSED: Continuous integration, rev:0b620148cba
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote : | # |
A CI job is currently in progress. A follow up comment will be added when it completes.
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote : | # |
FAILED: Continuous integration, rev:72da69a1880
https:/
Executed test runs:
FAILURE: https:/
None: https:/
Click here to trigger a rebuild:
https:/
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote : | # |
FAILED: Continuous integration, rev:72da69a1880
https:/
Executed test runs:
FAILURE: https:/
None: https:/
Click here to trigger a rebuild:
https:/
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote : | # |
A CI job is currently in progress. A follow up comment will be added when it completes.
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote : | # |
FAILED: Continuous integration, rev:06ad4db144a
https:/
Executed test runs:
FAILURE: https:/
None: https:/
Click here to trigger a rebuild:
https:/
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote : | # |
FAILED: Continuous integration, rev:06ad4db144a
https:/
Executed test runs:
FAILURE: https:/
None: https:/
Click here to trigger a rebuild:
https:/
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote : | # |
PASSED: Continuous integration, rev:06ad4db144a
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote : | # |
Change successfully merged at revision fbdfd95fe6aa6bf
Preview Diff
1 | diff --git a/src/README.md b/src/README.md |
2 | index 87c2072..9eb6f52 100644 |
3 | --- a/src/README.md |
4 | +++ b/src/README.md |
5 | @@ -98,6 +98,24 @@ look like this: |
6 | bind_port: 514 |
7 | ``` |
8 | |
9 | +## Dashboards |
10 | + |
11 | +All dashboards stored in `files/content_packs` as [Graylog content packs](https://docs.graylog.org/docs/content-packs) are installed by |
12 | +default in Graylog. Dashboards are only supported from Graylog snap 3/stable. |
13 | + |
14 | +### Contributing |
15 | + |
16 | +* to create a new dashboard, from a Graylog development instance remove all |
17 | +dashboards except the one to be exported, create a [Graylog content pack](https://docs.graylog.org/docs/content-packs) |
18 | +selecting only Dashboards from the entities list to be exported, download the json and remove |
19 | +any occurrence of the keys `streams` and relative values to workaround [bug 10008](https://github.com/Graylog2/graylog2-server/issues/10008) |
20 | +then push it to `files/content_packs`. |
21 | + |
22 | +* to update an existing dashboard, import in a Graylog development instance (with no existing dashboards) |
23 | +the existing content_pack for the dashboard, do the updates and save it, |
24 | +create a new content pack version and download it. Remove `streams` keys again and replace |
25 | +the existing json file in `files/content_packs` with the new one. |
26 | + |
27 | ## Upgrade |
28 | |
29 | ### Pre-upgrade notes |
30 | diff --git a/src/files/content_packs/messages_sources_dashboard.json b/src/files/content_packs/messages_sources_dashboard.json |
31 | new file mode 100644 |
32 | index 0000000..c4bc152 |
33 | --- /dev/null |
34 | +++ b/src/files/content_packs/messages_sources_dashboard.json |
35 | @@ -0,0 +1,589 @@ |
36 | +{ |
37 | + "v": "1", |
38 | + "id": "6a8e2cb1-33c3-49fc-aaa9-9ba8310cd8f1", |
39 | + "rev": 2, |
40 | + "name": "Messages Sources Dashboard", |
41 | + "summary": "This content pack ships a dashboard showing Messages Sources statistics", |
42 | + "description": "This content pack ships a dashboard that shows messages count from sources. It is useful when you receive alerts about graylog journal backlogs and helps identifying the hosts/services/log files that are contributing to the current influx of log data.", |
43 | + "vendor": "canonical-bootstack", |
44 | + "url": "", |
45 | + "parameters": [], |
46 | + "entities": [ |
47 | + { |
48 | + "v": "1", |
49 | + "type": { |
50 | + "name": "dashboard", |
51 | + "version": "2" |
52 | + }, |
53 | + "id": "330dc106-8def-43de-abcc-7989880109b7", |
54 | + "data": { |
55 | + "summary": { |
56 | + "@type": "string", |
57 | + "@value": "This dashboard shows messages count from sources" |
58 | + }, |
59 | + "search": { |
60 | + "queries": [ |
61 | + { |
62 | + "id": "09592074-0e28-47ee-83b5-8f1b705c6940", |
63 | + "timerange": { |
64 | + "type": "relative", |
65 | + "range": 300 |
66 | + }, |
67 | + "query": { |
68 | + "type": "elasticsearch", |
69 | + "query_string": "" |
70 | + }, |
71 | + "search_types": [ |
72 | + { |
73 | + "query": { |
74 | + "type": "elasticsearch", |
75 | + "query_string": "*" |
76 | + }, |
77 | + "name": "chart", |
78 | + "timerange": { |
79 | + "type": "relative", |
80 | + "range": 3600 |
81 | + }, |
82 | + "series": [ |
83 | + { |
84 | + "type": "count", |
85 | + "id": "Messages", |
86 | + "field": "source" |
87 | + } |
88 | + ], |
89 | + "filter": null, |
90 | + "rollup": true, |
91 | + "row_groups": [ |
92 | + { |
93 | + "type": "values", |
94 | + "field": "source", |
95 | + "limit": 20 |
96 | + } |
97 | + ], |
98 | + "type": "pivot", |
99 | + "id": "7d05d4fe-cfaa-4690-9260-619736666294", |
100 | + "column_groups": [], |
101 | + "sort": [] |
102 | + }, |
103 | + { |
104 | + "query": { |
105 | + "type": "elasticsearch", |
106 | + "query_string": "*" |
107 | + }, |
108 | + "name": "chart", |
109 | + "timerange": { |
110 | + "type": "relative", |
111 | + "range": 3600 |
112 | + }, |
113 | + "series": [ |
114 | + { |
115 | + "type": "count", |
116 | + "id": "Messages", |
117 | + "field": "filebeat_source" |
118 | + } |
119 | + ], |
120 | + "filter": null, |
121 | + "rollup": true, |
122 | + "row_groups": [ |
123 | + { |
124 | + "type": "values", |
125 | + "field": "source", |
126 | + "limit": 20 |
127 | + }, |
128 | + { |
129 | + "type": "values", |
130 | + "field": "filebeat_source", |
131 | + "limit": 6 |
132 | + } |
133 | + ], |
134 | + "type": "pivot", |
135 | + "id": "24ccc12a-ef4f-4fbf-baac-ae6e074b20be", |
136 | + "column_groups": [], |
137 | + "sort": [] |
138 | + } |
139 | + ] |
140 | + }, |
141 | + { |
142 | + "id": "2e8e59bf-9015-49bf-9121-683a31a0f079", |
143 | + "timerange": { |
144 | + "type": "relative", |
145 | + "range": 300 |
146 | + }, |
147 | + "query": { |
148 | + "type": "elasticsearch", |
149 | + "query_string": "" |
150 | + }, |
151 | + "search_types": [ |
152 | + { |
153 | + "query": { |
154 | + "type": "elasticsearch", |
155 | + "query_string": "*" |
156 | + }, |
157 | + "name": "chart", |
158 | + "timerange": { |
159 | + "type": "relative", |
160 | + "range": 1800 |
161 | + }, |
162 | + "series": [ |
163 | + { |
164 | + "type": "count", |
165 | + "id": "Messages", |
166 | + "field": "source" |
167 | + } |
168 | + ], |
169 | + "filter": null, |
170 | + "rollup": true, |
171 | + "row_groups": [ |
172 | + { |
173 | + "type": "values", |
174 | + "field": "source", |
175 | + "limit": 15 |
176 | + } |
177 | + ], |
178 | + "type": "pivot", |
179 | + "id": "7a5485f4-70ee-4ee7-9acf-9ae94b00c4eb", |
180 | + "column_groups": [], |
181 | + "sort": [ |
182 | + { |
183 | + "type": "series", |
184 | + "field": "count(source)", |
185 | + "direction": "Descending" |
186 | + } |
187 | + ] |
188 | + }, |
189 | + { |
190 | + "query": { |
191 | + "type": "elasticsearch", |
192 | + "query_string": "*" |
193 | + }, |
194 | + "name": "chart", |
195 | + "timerange": { |
196 | + "type": "relative", |
197 | + "range": 3600 |
198 | + }, |
199 | + "series": [ |
200 | + { |
201 | + "type": "count", |
202 | + "id": "Messages", |
203 | + "field": "source" |
204 | + } |
205 | + ], |
206 | + "filter": null, |
207 | + "rollup": true, |
208 | + "row_groups": [ |
209 | + { |
210 | + "type": "values", |
211 | + "field": "source", |
212 | + "limit": 15 |
213 | + } |
214 | + ], |
215 | + "type": "pivot", |
216 | + "id": "bf405ab5-e540-4cb1-8756-22e788c2eb10", |
217 | + "column_groups": [], |
218 | + "sort": [ |
219 | + { |
220 | + "type": "series", |
221 | + "field": "count(source)", |
222 | + "direction": "Descending" |
223 | + } |
224 | + ] |
225 | + }, |
226 | + { |
227 | + "query": { |
228 | + "type": "elasticsearch", |
229 | + "query_string": "*" |
230 | + }, |
231 | + "name": "chart", |
232 | + "timerange": { |
233 | + "type": "relative", |
234 | + "range": 7200 |
235 | + }, |
236 | + "series": [ |
237 | + { |
238 | + "type": "count", |
239 | + "id": "Messages", |
240 | + "field": "source" |
241 | + } |
242 | + ], |
243 | + "filter": null, |
244 | + "rollup": true, |
245 | + "row_groups": [ |
246 | + { |
247 | + "type": "values", |
248 | + "field": "source", |
249 | + "limit": 15 |
250 | + } |
251 | + ], |
252 | + "type": "pivot", |
253 | + "id": "5c6df0b7-dab7-4f89-be0a-8995123ebfc2", |
254 | + "column_groups": [], |
255 | + "sort": [ |
256 | + { |
257 | + "type": "series", |
258 | + "field": "count(source)", |
259 | + "direction": "Descending" |
260 | + } |
261 | + ] |
262 | + } |
263 | + ] |
264 | + } |
265 | + ], |
266 | + "parameters": [], |
267 | + "requires": {}, |
268 | + "owner": "admin", |
269 | + "created_at": "2022-02-04T09:11:29.644Z" |
270 | + }, |
271 | + "created_at": "2022-02-04T08:29:44.557Z", |
272 | + "requires": {}, |
273 | + "state": { |
274 | + "2e8e59bf-9015-49bf-9121-683a31a0f079": { |
275 | + "selected_fields": null, |
276 | + "static_message_list_id": null, |
277 | + "titles": { |
278 | + "tab": { |
279 | + "title": "Trend" |
280 | + }, |
281 | + "widget": { |
282 | + "4bdc6daa-6e85-4051-b9b4-da51a26341b3": "Top 15 Messages Sources in the last 30 minutes", |
283 | + "3556604e-aabe-4a98-a237-d13b278b9070": "Top 15 Messages Sources in the last 60 minutes", |
284 | + "4848eb5b-7dcb-4631-a965-01324d0446ba": "Top 15 Messages Sources in the last 120 minutes" |
285 | + } |
286 | + }, |
287 | + "widgets": [ |
288 | + { |
289 | + "id": "4bdc6daa-6e85-4051-b9b4-da51a26341b3", |
290 | + "type": "aggregation", |
291 | + "filter": null, |
292 | + "timerange": { |
293 | + "type": "relative", |
294 | + "range": 1800 |
295 | + }, |
296 | + "query": { |
297 | + "type": "elasticsearch", |
298 | + "query_string": "*" |
299 | + }, |
300 | + "config": { |
301 | + "visualization": "bar", |
302 | + "event_annotation": false, |
303 | + "row_pivots": [ |
304 | + { |
305 | + "field": "source", |
306 | + "type": "values", |
307 | + "config": { |
308 | + "limit": 15 |
309 | + } |
310 | + } |
311 | + ], |
312 | + "series": [ |
313 | + { |
314 | + "config": { |
315 | + "name": "Messages" |
316 | + }, |
317 | + "function": "count(source)" |
318 | + } |
319 | + ], |
320 | + "rollup": true, |
321 | + "column_pivots": [], |
322 | + "visualization_config": null, |
323 | + "formatting_settings": null, |
324 | + "sort": [ |
325 | + { |
326 | + "type": "series", |
327 | + "field": "count(source)", |
328 | + "direction": "Descending" |
329 | + } |
330 | + ] |
331 | + } |
332 | + }, |
333 | + { |
334 | + "id": "3556604e-aabe-4a98-a237-d13b278b9070", |
335 | + "type": "aggregation", |
336 | + "filter": null, |
337 | + "timerange": { |
338 | + "type": "relative", |
339 | + "range": 3600 |
340 | + }, |
341 | + "query": { |
342 | + "type": "elasticsearch", |
343 | + "query_string": "*" |
344 | + }, |
345 | + "config": { |
346 | + "visualization": "bar", |
347 | + "event_annotation": false, |
348 | + "row_pivots": [ |
349 | + { |
350 | + "field": "source", |
351 | + "type": "values", |
352 | + "config": { |
353 | + "limit": 15 |
354 | + } |
355 | + } |
356 | + ], |
357 | + "series": [ |
358 | + { |
359 | + "config": { |
360 | + "name": "Messages" |
361 | + }, |
362 | + "function": "count(source)" |
363 | + } |
364 | + ], |
365 | + "rollup": true, |
366 | + "column_pivots": [], |
367 | + "visualization_config": null, |
368 | + "formatting_settings": { |
369 | + "chart_colors": [ |
370 | + { |
371 | + "field_name": "Message Count", |
372 | + "chart_color": "#b71c1c" |
373 | + }, |
374 | + { |
375 | + "field_name": "Messages", |
376 | + "chart_color": "#f44336" |
377 | + } |
378 | + ] |
379 | + }, |
380 | + "sort": [ |
381 | + { |
382 | + "type": "series", |
383 | + "field": "count(source)", |
384 | + "direction": "Descending" |
385 | + } |
386 | + ] |
387 | + } |
388 | + }, |
389 | + { |
390 | + "id": "4848eb5b-7dcb-4631-a965-01324d0446ba", |
391 | + "type": "aggregation", |
392 | + "filter": null, |
393 | + "timerange": { |
394 | + "type": "relative", |
395 | + "range": 7200 |
396 | + }, |
397 | + "query": { |
398 | + "type": "elasticsearch", |
399 | + "query_string": "*" |
400 | + }, |
401 | + "config": { |
402 | + "visualization": "bar", |
403 | + "event_annotation": false, |
404 | + "row_pivots": [ |
405 | + { |
406 | + "field": "source", |
407 | + "type": "values", |
408 | + "config": { |
409 | + "limit": 15 |
410 | + } |
411 | + } |
412 | + ], |
413 | + "series": [ |
414 | + { |
415 | + "config": { |
416 | + "name": "Messages" |
417 | + }, |
418 | + "function": "count(source)" |
419 | + } |
420 | + ], |
421 | + "rollup": true, |
422 | + "column_pivots": [], |
423 | + "visualization_config": null, |
424 | + "formatting_settings": null, |
425 | + "sort": [ |
426 | + { |
427 | + "type": "series", |
428 | + "field": "count(source)", |
429 | + "direction": "Descending" |
430 | + } |
431 | + ] |
432 | + } |
433 | + } |
434 | + ], |
435 | + "widget_mapping": { |
436 | + "4bdc6daa-6e85-4051-b9b4-da51a26341b3": [ |
437 | + "7a5485f4-70ee-4ee7-9acf-9ae94b00c4eb" |
438 | + ], |
439 | + "3556604e-aabe-4a98-a237-d13b278b9070": [ |
440 | + "bf405ab5-e540-4cb1-8756-22e788c2eb10" |
441 | + ], |
442 | + "4848eb5b-7dcb-4631-a965-01324d0446ba": [ |
443 | + "5c6df0b7-dab7-4f89-be0a-8995123ebfc2" |
444 | + ] |
445 | + }, |
446 | + "positions": { |
447 | + "4bdc6daa-6e85-4051-b9b4-da51a26341b3": { |
448 | + "col": 1, |
449 | + "row": 1, |
450 | + "height": 4, |
451 | + "width": "Infinity" |
452 | + }, |
453 | + "3556604e-aabe-4a98-a237-d13b278b9070": { |
454 | + "col": 1, |
455 | + "row": 5, |
456 | + "height": 4, |
457 | + "width": "Infinity" |
458 | + }, |
459 | + "4848eb5b-7dcb-4631-a965-01324d0446ba": { |
460 | + "col": 1, |
461 | + "row": 9, |
462 | + "height": 4, |
463 | + "width": "Infinity" |
464 | + } |
465 | + }, |
466 | + "formatting": { |
467 | + "highlighting": [] |
468 | + }, |
469 | + "display_mode_settings": { |
470 | + "positions": {} |
471 | + } |
472 | + }, |
473 | + "09592074-0e28-47ee-83b5-8f1b705c6940": { |
474 | + "selected_fields": null, |
475 | + "static_message_list_id": null, |
476 | + "titles": { |
477 | + "widget": { |
478 | + "04a34930-4dc2-4139-a492-1a0b1cab4cea": "Top 20 Messages Sources by log file in the last 60 minutes", |
479 | + "27a74226-2564-45af-be52-fd43ad3e0ceb": "Top 20 Messages Sources in the last 60 minutes", |
480 | + "0439ab6a-7ef7-4763-905b-19a34372428a": "Field Statistics for filebeat_source", |
481 | + "e97e26d3-9bbe-41bf-86a5-ae13ec12b22f": "Field Statistics for filebeat_source" |
482 | + }, |
483 | + "tab": { |
484 | + "title": "Top Sources" |
485 | + } |
486 | + }, |
487 | + "widgets": [ |
488 | + { |
489 | + "id": "27a74226-2564-45af-be52-fd43ad3e0ceb", |
490 | + "type": "aggregation", |
491 | + "filter": null, |
492 | + "timerange": { |
493 | + "type": "relative", |
494 | + "range": 3600 |
495 | + }, |
496 | + "query": { |
497 | + "type": "elasticsearch", |
498 | + "query_string": "*" |
499 | + }, |
500 | + "config": { |
501 | + "visualization": "table", |
502 | + "event_annotation": false, |
503 | + "row_pivots": [ |
504 | + { |
505 | + "field": "source", |
506 | + "type": "values", |
507 | + "config": { |
508 | + "limit": 20 |
509 | + } |
510 | + } |
511 | + ], |
512 | + "series": [ |
513 | + { |
514 | + "config": { |
515 | + "name": "Messages" |
516 | + }, |
517 | + "function": "count(source)" |
518 | + } |
519 | + ], |
520 | + "rollup": true, |
521 | + "column_pivots": [], |
522 | + "visualization_config": null, |
523 | + "formatting_settings": null, |
524 | + "sort": [] |
525 | + } |
526 | + }, |
527 | + { |
528 | + "id": "04a34930-4dc2-4139-a492-1a0b1cab4cea", |
529 | + "type": "aggregation", |
530 | + "filter": null, |
531 | + "timerange": { |
532 | + "type": "relative", |
533 | + "range": 3600 |
534 | + }, |
535 | + "query": { |
536 | + "type": "elasticsearch", |
537 | + "query_string": "*" |
538 | + }, |
539 | + "config": { |
540 | + "visualization": "table", |
541 | + "event_annotation": false, |
542 | + "row_pivots": [ |
543 | + { |
544 | + "field": "source", |
545 | + "type": "values", |
546 | + "config": { |
547 | + "limit": 20 |
548 | + } |
549 | + }, |
550 | + { |
551 | + "field": "filebeat_source", |
552 | + "type": "values", |
553 | + "config": { |
554 | + "limit": 6 |
555 | + } |
556 | + } |
557 | + ], |
558 | + "series": [ |
559 | + { |
560 | + "config": { |
561 | + "name": "Messages" |
562 | + }, |
563 | + "function": "count(filebeat_source)" |
564 | + } |
565 | + ], |
566 | + "rollup": true, |
567 | + "column_pivots": [], |
568 | + "visualization_config": null, |
569 | + "formatting_settings": null, |
570 | + "sort": [] |
571 | + } |
572 | + } |
573 | + ], |
574 | + "widget_mapping": { |
575 | + "04a34930-4dc2-4139-a492-1a0b1cab4cea": [ |
576 | + "24ccc12a-ef4f-4fbf-baac-ae6e074b20be" |
577 | + ], |
578 | + "27a74226-2564-45af-be52-fd43ad3e0ceb": [ |
579 | + "7d05d4fe-cfaa-4690-9260-619736666294" |
580 | + ] |
581 | + }, |
582 | + "positions": { |
583 | + "27a74226-2564-45af-be52-fd43ad3e0ceb": { |
584 | + "col": 1, |
585 | + "row": 5, |
586 | + "height": 5, |
587 | + "width": "Infinity" |
588 | + }, |
589 | + "04a34930-4dc2-4139-a492-1a0b1cab4cea": { |
590 | + "col": 1, |
591 | + "row": 10, |
592 | + "height": 10, |
593 | + "width": "Infinity" |
594 | + } |
595 | + }, |
596 | + "formatting": { |
597 | + "highlighting": [] |
598 | + }, |
599 | + "display_mode_settings": { |
600 | + "positions": {} |
601 | + } |
602 | + } |
603 | + }, |
604 | + "properties": [], |
605 | + "owner": "admin", |
606 | + "title": { |
607 | + "@type": "string", |
608 | + "@value": "Messages Sources Statistics" |
609 | + }, |
610 | + "type": "DASHBOARD", |
611 | + "description": { |
612 | + "@type": "string", |
613 | + "@value": "This dashboard shows messages count from sources. It is useful when you receive alerts about graylog journal backlogs and helps identifying the hosts/services/log files that are contributing to the current influx of log data." |
614 | + } |
615 | + }, |
616 | + "constraints": [ |
617 | + { |
618 | + "type": "server-version", |
619 | + "version": ">=3.3.16+f766a24" |
620 | + } |
621 | + ] |
622 | + } |
623 | + ] |
624 | +} |
625 | diff --git a/src/lib/charms/layer/graylog/api.py b/src/lib/charms/layer/graylog/api.py |
626 | index 3d9bf93..5aa9fea 100644 |
627 | --- a/src/lib/charms/layer/graylog/api.py |
628 | +++ b/src/lib/charms/layer/graylog/api.py |
629 | @@ -266,3 +266,20 @@ class GraylogApi: |
630 | if not self.token: |
631 | self.token_get() |
632 | return self.request("system/notifications") |
633 | + |
634 | + def upload_content_pack(self, content_pack_dict): |
635 | + """Upload a content pack.""" |
636 | + if not self.token: |
637 | + self.token_get() |
638 | + return self.request( |
639 | + "system/content_packs", method="POST", data=content_pack_dict |
640 | + ) |
641 | + |
642 | + def install_content_pack(self, cp_uuid, cp_version, parameters={}, comments=""): |
643 | + """Install a content pack.""" |
644 | + if not self.token: |
645 | + self.token_get() |
646 | + |
647 | + d = {"parameters": parameters, "comment": comments} |
648 | + url = "system/content_packs/{}/{}/installations".format(cp_uuid, cp_version) |
649 | + return self.request(url, method="POST", data=d) |
650 | diff --git a/src/lib/charms/layer/graylog/constants.py b/src/lib/charms/layer/graylog/constants.py |
651 | index ce2bc59..4340dc8 100644 |
652 | --- a/src/lib/charms/layer/graylog/constants.py |
653 | +++ b/src/lib/charms/layer/graylog/constants.py |
654 | @@ -18,3 +18,4 @@ DEFAULT_REST_API_TIMEOUT = 120 |
655 | NAGIOS_USERNAME = "nagios" |
656 | CERT_PATH = os.path.join(SNAP_COMMON_DIR, "server.crt") |
657 | CERT_KEY_PATH = os.path.join(SNAP_COMMON_DIR, "server.key") |
658 | +CONTENT_PACKS_PATH = "files/content_packs" |
659 | diff --git a/src/reactive/graylog.py b/src/reactive/graylog.py |
660 | index b2babce..9808aa6 100644 |
661 | --- a/src/reactive/graylog.py |
662 | +++ b/src/reactive/graylog.py |
663 | @@ -1,10 +1,12 @@ |
664 | """Graylog reactive script.""" |
665 | import hashlib |
666 | +import json |
667 | import os |
668 | import re |
669 | import socket |
670 | import subprocess |
671 | import time |
672 | +from pathlib import Path |
673 | from urllib.parse import urlparse |
674 | |
675 | from charmhelpers.contrib.charmsupport import nrpe |
676 | @@ -27,6 +29,7 @@ from charms.layer.graylog.constants import ( |
677 | CERT_KEY_PATH, |
678 | CERT_PATH, |
679 | CONF_FILE, |
680 | + CONTENT_PACKS_PATH, |
681 | DEFAULT_REST_API_TIMEOUT, |
682 | ELASTICSEARCH_DISCOVERY_PORT, |
683 | NAGIOS_USERNAME, |
684 | @@ -418,6 +421,7 @@ def configure_graylog_api(*discard): |
685 | # Just wait (status already set in report_status()) and try again next time. |
686 | pass |
687 | else: |
688 | + install_content_packs() |
689 | remove_state("beat.setup") |
690 | remove_state("graylog_index_sets.configured") |
691 | remove_state("graylog_inputs.configured") |
692 | @@ -1139,6 +1143,19 @@ def set_jvm_heap_size(heap_size="1G", conf_path=SERVER_DEFAULT_CONF_FILE): # no |
693 | return False |
694 | |
695 | |
696 | +def install_content_packs(): |
697 | + """Install content packs from default folder.""" |
698 | + g = get_default_graylog_client() |
699 | + cp_dir = Path(CONTENT_PACKS_PATH) |
700 | + for cp in cp_dir.glob("*.json"): |
701 | + cp_text = cp.read_text() |
702 | + cp_dict = json.loads(cp_text) |
703 | + cp_uuid = cp_dict["id"] |
704 | + cp_version = cp_dict["rev"] |
705 | + g.upload_content_pack(cp_dict) |
706 | + g.install_content_pack(cp_uuid, cp_version) |
707 | + |
708 | + |
709 | def flag_restart_and_api_reconfigure_needed(): # noqa: D103 |
710 | set_state("graylog.needs_restart") |
711 |
A CI job is currently in progress. A follow up comment will be added when it completes.