prometheus-splash 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f2d1cf627c0fd2371da011a6a97a24e82498b9a28b3d4d0485e185841bf7438
4
- data.tar.gz: e0982026ea749cad8366f420e88cd376bcc8bd0a45e0ec292cc1b9a8237764c2
3
+ metadata.gz: 4ae0ce3acc9966d9dc6bcc162a6691b01a97fa0368595dacbc4e12c36d830371
4
+ data.tar.gz: b236034c20105a79dd770ce10334aea80c67dc4f624d059b82f425e862b601e1
5
5
  SHA512:
6
- metadata.gz: b43dcf0493e86ac31da666c4a68c8f2f22f804231f1fd6c0bcc98e3235605e80a4c8e8def976a7c4bf1c54110bdbfe0e67d64040c9d857d23dc16a324cdd1826
7
- data.tar.gz: 18b7dea993feea9e1a276bf02b5542d98a772754eb68b113bde17ba5f69ec9c346eaa56520d8b960aa658ba1cc4b53a17dd5f7e4af256f8d07b404131573acd4
6
+ metadata.gz: 21daf35dfb3e696ef172cd678d7d2a644c2ef46aceef16cd32c889356f60a0403cd8cbfd1246944b0b7a84acbf8ea627ecd718ae830d48d839abdbd0d3ac5db9
7
+ data.tar.gz: 8e6cea17fcdf8fbd7facf65e34ca79e166cf3f26b517f454024fd46ef0b9d18aec7e103ff4ff4efdbf94531beeb6a1f490817e23e9b18bda395955d63cc34d0a
data/README.md CHANGED
@@ -1,27 +1,661 @@
1
1
  # Splash
2
2
 
3
- SPLASH is *Supervision with Prometheus of Logs and Asynchronous tasks for Services or Hosts*
3
+ ![Splash logo](assets/images/logo_splash_reduce.png) _Orchestration and Supervision made easy_
4
+
5
+ SPLASH is **Supervision with Prometheus of Logs and Asynchronous tasks orchestration for Services or Hosts**
4
6
 
5
7
 
6
8
  Prometheus Logs and Batchs supervision over PushGateway
7
9
 
8
- ## Installation
9
10
 
10
- Add this line to your application's Gemfile:
11
+ ## Preconfiguration
12
+
13
+ You need a Prometheus PushGateway operational, if the service not run on localhost:9091,
14
+ See Prometheus server Configuration chapter to precise it in the configuration
15
+
16
+ You need Ruby on the server you want to run Splash
17
+ Splash is succesfully tested with Ruby 2.7.0, but it should works correctly with all Ruby 2.X versions.
18
+
19
+ On Ubuntu :
20
+
21
+ # apt install ruby
22
+
23
+ In some use case, Splash also require some other components :
24
+
25
+ - Redis
26
+ - RabbitMQ
27
+
28
+ It's not strictly required, Redis is a real option for backend; you could configure backend to flat file, but
29
+ RabbitMQ is required by the Splash Daemon when using host2host sequence execution.
30
+
31
+ Redis, is usefull when you need a centralized Splash management.
32
+
33
+ On Ubuntu :
34
+
35
+ # apt install redis-server rabbimq-server
36
+
37
+ See Backends Configuration and Transports Configuration to specify this services configurations
11
38
 
12
- gem 'splash'
13
39
 
14
- And then execute:
40
+ ## Installation
15
41
 
16
- $ bundle
17
42
 
18
- Or install it yourself as:
43
+ Install with gem command :
19
44
 
20
45
  $ gem install splash
21
46
 
47
+
48
+ ## Configuration
49
+
50
+ As root or with rvmsudo, if you use RVM.
51
+
52
+ # splash config setup
53
+ Splash -> setup :
54
+ * Installing Configuration file : /etc/splash.yml : [OK]
55
+ * Installing template file : /etc/splash_execution_report.tpl : [OK]
56
+ * Creating/Checking pid file path : /var/lib/splash : [OK]
57
+ * Creating/Checking trace file path : /var/lib/splash : [OK]
58
+ Splash config successfully done.
59
+
60
+ *WARNING : if you have already configured Splash, running this command without --preserve flag, RESET the Splash Configuration.*
61
+
62
+
63
+ As root, edit /etc/splash.conf and adapt Prometheus Pushgateway Configuration :
64
+
65
+ # vi /etc/splash.yml
66
+ [..]
67
+ :prometheus:
68
+ :pushgateway:
69
+ :host: <SERVER>
70
+ :port: <PORT>
71
+ [..]
72
+
73
+ With :
74
+
75
+ - SERVER : IP or fqdn of the Gateway.
76
+ - PORT : the specific TCP port of the Gateway.
77
+
78
+
79
+ ### Sanitycheck
80
+
81
+ As root or with rvmsudo, if you use RVM.
82
+
83
+ # splash conf san
84
+ Splash -> sanitycheck :
85
+ * Config file : /etc/splash.yml : [OK]
86
+ * PID Path : /tmp : [OK]
87
+ * trace Path : /tmp/splash : [OK]
88
+ * Prometheus PushGateway Service running : [OK]
89
+ Sanitycheck finished with no errors
90
+
91
+ *WARNING* : setup or Sanitycheck could precises errors if path defined in configuration is *Symbolic links*, type :mode.
92
+ But it's not a problem for Splash to be operational.
93
+
94
+ For file/folders if problems is detected, it could be such as :
95
+
96
+ - :mode : UNIX rights errors
97
+ - :owner : UNIX file owner errors
98
+ - :group : UNIX file group errors
99
+ - :inexistant : file/folder is missing
100
+
101
+ ### getting current VERSION
102
+
103
+ run :
104
+
105
+ $ splash config version
106
+ Splash version : 0.0.3, Author : Romain GEORGES <gems@ultragreen.net>
107
+ Ultragreen (c) 2020 BSD-2-Clause
108
+
109
+
22
110
  ## Usage
23
111
 
24
- TODO: Write usage instructions here
112
+ ### Logs monitoring
113
+
114
+ #### Edit your configuration
115
+
116
+
117
+ In the /etc/splash.yml, you need to adapt default config to monitor your logs.
118
+
119
+ # vi /etc/splash.yml
120
+ [..]
121
+ ### configuration of monitored logs
122
+ :logs:
123
+ - :log: /a/log/path.log
124
+ :pattern: <regexp pattern>
125
+ - :log: /an/other/log/path.log
126
+ :pattern: <regexp pattern
127
+ - <etc...>
128
+ [..]
129
+
130
+ Config for log is a YAML list of Hash, with keys :
131
+
132
+ - :log : a log absolut paths
133
+ - :pattern : a regular expression splash need to detect
134
+
135
+
136
+ #### Prerequisite
137
+
138
+ To ensure you have the default configuration values run as root :
139
+
140
+ # splash conf set
141
+
142
+ *INFO* : comamnds must be reduce with the Thor completion facilities
143
+
144
+ To see all monitoring commands with Splash, run :
145
+
146
+ # splash logs
147
+
148
+ or
149
+
150
+ # slash logs help
151
+ Commands:
152
+ splash logs analyse # analyze logs in config
153
+ splash logs help [COMMAND] # Describe subcommands or one specific subcommand
154
+ splash logs list # Show configured logs monitoring
155
+ splash logs monitor # monitor logs in config
156
+ splash logs show LOG # show configured log monitoring for LOG
157
+
158
+ *Typicallly, the way work with all Splash commands or subcommands*
159
+
160
+
161
+
162
+ #### Run a first test
163
+
164
+ Verify /tmp/test and /tmp/test2 not existence
165
+
166
+ # rm /tmp/test /tmp/test2
167
+
168
+ Verify configured logs :
169
+
170
+ # splash logs list
171
+ Splash configured log monitoring :
172
+ * log monitor : /tmp/test
173
+ * log monitor : /tmp/test2
174
+
175
+ You could run list commands with --detail option , verify it with :
176
+
177
+ # splash command subcommand help
178
+
179
+ like :
180
+
181
+ # splash logs list --detail
182
+ Splash configured log monitoring :
183
+ * log monitor : /tmp/test
184
+ -> pattern : /ERROR/
185
+ * log monitor : /tmp/test2
186
+ -> pattern : /ERROR/
187
+
188
+ You cloud view a specific logs record detail with
189
+
190
+ # splash logs show /tmp/test2
191
+ Splash log monitor : /tmp/test2
192
+ -> pattern : /ERROR/
193
+
194
+ Run a first analyse, you would see :
195
+
196
+ # splash logs analyse
197
+ SPlash Configured logs status :
198
+ * Log : /tmp/test : [KO]
199
+ - Detected pattern : ERROR
200
+ - detailled Status : missing
201
+ * Log : /tmp/test2 : [KO]
202
+ - Detected pattern : ERROR
203
+ - detailled Status : missing
204
+ Global Status : [KO]
205
+
206
+ Create empty Files, or without ERROR string in.
207
+
208
+ # echo 'foo' > /tmp/test
209
+ # touch /tmp/test2
210
+
211
+ Re-run analyse :
212
+
213
+ # splash log an
214
+ SPlash Configured logs status :
215
+ * Log : /tmp/test : [OK]
216
+ - Detected pattern : ERROR
217
+ - detailled Status : clean
218
+ nb lines = 1
219
+ * Log : /tmp/test2 : [OK]
220
+ - Detected pattern : ERROR
221
+ - detailled Status : clean
222
+ nb lines = 0
223
+ Global Status : [OK]
224
+
225
+ It's alright, log monitoring work fine.
226
+
227
+ #### Send metrics to Prometheus gateway
228
+
229
+ Splash is made to run a specific daemon to do this job, but you could do one time, with :
230
+
231
+ # splash logs monitor
232
+ Sending metrics to Prometheus Pushgateway
233
+ * Sending metrics for /tmp/test
234
+ * Sending metrics for /tmp/test2
235
+ Sending done.
236
+
237
+ if Prometheus Gateway is not running or misconfigured, you could see :
238
+
239
+ Prometheus PushGateway Service IS NOT running
240
+ Exit without notification.
241
+
242
+ Otherwise Prometheus PushGateway have received the metrics :
243
+
244
+
245
+ - *logerrors*, Prometheus Gauge : with label: <the logname> and job: 'Splash'
246
+ => description : SPLASH metric log error'
247
+ => content :<nb match> the number of pattern matching for the log
248
+
249
+ - *logmissing*, Prometheus Gauge : with label: <the logname> and job: 'Splash'
250
+ => description : SPLASH metric log missing'
251
+ => content :0 if log exist, 1 if log missing
252
+
253
+ - *loglines*, Prometheus Gauge : with label: <the logname> and job: 'Splash'
254
+ => description : SPLASH metric log line numbers'
255
+ => content :0 if log missing, <nb lines in the log> the number of lines in the logs
256
+
257
+ #### See it in Prometheus PushGateway
258
+
259
+ visit http://<prometheus_pushgateway_host>:<prometheus_pushgateway_port>/
260
+
261
+ ![prom PG logs](assets/images/prom_pg_logs.png)
262
+
263
+ ![prom PG details logs](assets/images/detail_prom_splash.png)
264
+
265
+
266
+ ### Commands Orchestration, running and monitoring
267
+
268
+ #### List of commands
269
+
270
+ To see all the commands in the 'commands' submenu :
271
+
272
+ $ splash commands help
273
+
274
+ $ splash commands
275
+ Commands:
276
+ splash commands help [COMMAND] # Describe subcommands or one specific subcommand
277
+ splash commands lastrun COMMAND # Show last running result for specific configured command COMMAND
278
+ splash commands list # Show configured commands
279
+ splash commands run NAME # run for command/sequence or ack result
280
+ splash commands show COMMAND # Show specific configured command COMMAND
281
+ splash commands treeview # Show commands sequence tree
282
+
283
+ #### Prepare test with default configuration
284
+
285
+ Commands or Commands Sequences must be defined in the main configuration file '/etc/splash.yml'
286
+
287
+ *Exemple* in default configuration :
288
+
289
+ ### configuration of commands and scheduling
290
+ :commands:
291
+ :id_root:
292
+ :desc: run id command on root
293
+ :command: id root
294
+
295
+ :true_test:
296
+ :desc: "test command returning true : 0"
297
+ :command: "true"
298
+ :schedule:
299
+ :every: "1h"
300
+ :on_failure: :ls_slash_tmp
301
+ :on_success: :pwd
302
+
303
+ :false_test:
304
+ :desc: "test command returning false > 0"
305
+ :command: "false"
306
+ :schedule:
307
+ :every: "1h"
308
+ :on_failure: :ls_slash_tmp
309
+ :on_success: :pwd
310
+
311
+ :ls_slash_tmp:
312
+ :desc: list file in /tmp
313
+ :command: ls -al /tmp
314
+ :user: daemon
315
+ :on_success: :echo1
316
+
317
+ :pwd:
318
+ :desc: run pwd
319
+ :command: pwd
320
+ :on_success: :echo1
321
+ :on_failure: :echo2
322
+
323
+ :echo1:
324
+ :desc: echo 'foo'
325
+ :command: echo foo
326
+ :on_failure: :echo3
327
+
328
+ :echo2:
329
+ :desc: echo 'bar'
330
+ :command: echo bar
331
+
332
+ :echo3:
333
+ :desc: echo 'been'
334
+ :command: echo been
335
+
336
+ A configuration block for commands must include :
337
+
338
+ * *key* : a name as Symbol (:xxxxxx)
339
+ * *values* : (hash)
340
+ * :desc : a brief Description
341
+ * :command : the full command line
342
+
343
+ may include :
344
+
345
+ * :user: the userneme to use to run the command
346
+ * :on_failure: the name of an other defined command, to, execute if exit_code > 0
347
+ * :on_success: the name of an other defined command, to, execute if exit_code = 0
348
+ * :schedule: (hash) a scheduling for daemon, after in this documentation, it support :
349
+ * :every: "<timing>" ex: "1s", "3m", "2h"
350
+ * :at: "<date/time>" ex: "2030/12/12 23:30:00"
351
+ * :cron: * * * * * a cron format
352
+
353
+ [Rufus Scheduler Doc](https://github.com/jmettraux/rufus-scheduler)
354
+
355
+ if you want to inject default configuration, again as root :
356
+
357
+ # splash conf set
358
+
359
+
360
+ #### listing the defined Commands
361
+
362
+ You could list the defined commands, in your case :
363
+
364
+ $ splash commands list
365
+ Splash configured commands :
366
+ * id_root
367
+ * true_test
368
+ * false_test
369
+ * ls_slash_tmp
370
+ * pwd
371
+ * echo1
372
+ * echo2
373
+ * echo3
374
+
375
+ #### Show specific commands
376
+
377
+ You could show a specific command :
378
+
379
+ $ splash com show pwd
380
+ Splash command : pwd
381
+ - command line : 'pwd'
382
+ - command description : 'run pwd'
383
+ - command failure callback : 'echo2'
384
+ - command success callback : 'echo1'
385
+
386
+ #### View Sequence execution for commands
387
+
388
+ You could trace execution sequence for a commands as a tree, with :
389
+
390
+ # splash com treeview
391
+ Command : true_test
392
+ * on failure => ls_slash_tmp
393
+ * on success => echo1
394
+ * on failure => echo3
395
+ * on success => pwd
396
+ * on failure => echo2
397
+ * on success => echo1
398
+ * on failure => echo3
399
+
400
+ In your sample, in all case :
401
+ - :true_test return 0
402
+ - :pwd return 0
403
+ - :echo1 return 0
404
+
405
+ commands execution sequence will be :
406
+
407
+ :true_test => :pwd => :echo1
408
+
409
+ :ls_slash_tmp, :echo2 and :echo3 will be never executed.
410
+
411
+ #### Executing a standalone command :
412
+
413
+ Running a standalone command with ONLY as root
414
+
415
+ # splash com execute echo1
416
+ Executing command : 'echo1'
417
+ * Tracefull execution
418
+ => exitcode 0
419
+ * Prometheus Gateway notified.
420
+
421
+ This command :
422
+
423
+ 1. Execute command line defined in command 'echo1' defined in configurations
424
+ 2. Trace information in a execution report :
425
+ - :start_date the complete date time of execution start.
426
+ - :end_date the complete date time of execution end.
427
+ - :cmd_name the name of the command
428
+ - :cmd_line the complete command line executed
429
+ - :stdout STDOUT of the command
430
+ - :stderr STDERR of the command
431
+ - :desc the description of the command
432
+ - :status : PID and exit_code of the command
433
+ - :exec_time : the timing of the command
434
+ 3. Notify Prometheus
435
+
436
+ There is some usefull modifiers for this command :
437
+
438
+ --no-trace : prevent Splash to write report for this execution in configured backend
439
+ --no-notify : prevent Splash to nofify Prometheus PushGateway metric (see later in this documentation)
440
+ --no-callback : never execute callback (see it after)
441
+
442
+
443
+
444
+ #### Executing a sequence of callback Commands
445
+
446
+ Splash allow execution of callback (:on_failure, :on_success), you have already see it in config sample.
447
+ In our example, we have see :true_test have a execution sequence, we're going to test this, as root :
448
+
449
+ # splash com exe true_test
450
+ Executing command : 'true_test'
451
+ * Tracefull execution
452
+ => exitcode 0
453
+ * Prometheus Gateway notified.
454
+ * On success callback : pwd
455
+ Executing command : 'pwd'
456
+ * Tracefull execution
457
+ => exitcode 0
458
+ * Prometheus Gateway notified.
459
+ * On success callback : echo1
460
+ Executing command : 'echo1'
461
+ * Tracefull execution
462
+ => exitcode 0
463
+ * Prometheus Gateway notified.
464
+
465
+ We could verify the sequence determined with lastrun command.
466
+
467
+ If you want to prevent callback execution, as root :
468
+
469
+ # splash com exe true_test --no-callback
470
+ Executing command : 'true_test'
471
+ * Tracefull execution
472
+ => exitcode 0
473
+ * Prometheus Gateway notified.
474
+ * Without callbacks sequences
475
+
476
+ #### Display the last execution trace for a command
477
+
478
+ If you want to view the last execution trace for commande, (run with --trace : default)
479
+
480
+ # splash com lastrun
481
+ Splash command pwd previous execution report:
482
+
483
+ Command Execution report
484
+ ========================
485
+
486
+ Date START: 2020-04-07T18:25:22+02:00
487
+ Date END: 2020-04-07T18:25:22+02:00
488
+ Command : pwd
489
+ full command line : pwd
490
+ Description : run pwd
491
+ errorcode : pid 86782 exit 0
492
+ Execution time (sec) : 0.006568
493
+
494
+ STDOUT:
495
+ -------
496
+
497
+ /Users/ruydiaz/labo/prometheus-splash
498
+
499
+
500
+
501
+ STDERR:
502
+ -------
503
+ ### Advanced Configuration
504
+
505
+ #### Backend configuration
506
+
507
+ For the moment Splash come with two types of backend :
508
+ - :file if you would a standalone splash Usage
509
+ - :redis if you want a distributed Splash usage
510
+
511
+ backend are usable for :
512
+
513
+ - execution trace
514
+
515
+ ##### File backend
516
+
517
+ The file backend is very simple to use :
518
+
519
+ Edit /etc/splash.yml, as root :
520
+
521
+ # vi /etc/splash.yml
522
+ [...]
523
+ :backends:
524
+ :stores:
525
+ :execution_trace:
526
+ :type: :file
527
+ :path: /var/run/splash
528
+ [...]
529
+
530
+ - :type must be :file
531
+ - :path should be set to the dedicated executions traces files path (default : /var/run/splash )
532
+
533
+ ##### Redis backend
534
+
535
+ A little bit more complicated for Redis :
536
+
537
+ Edit /etc/splash.yml, as root :
538
+
539
+ # vi /etc/splash.yml
540
+ [...]
541
+ :backends:
542
+ :stores:
543
+ :execution_trace:
544
+ :type: :redis
545
+ :host: localhost
546
+ :port: 6379
547
+ #:auth: "mykey"
548
+ :base: 1
549
+ [...]
550
+
551
+ - :type must be :redis
552
+ - :host must be set as the Redis server hostname (default: localhost)
553
+ - :port must be set as the Redis server port (default: 6379)
554
+ - :base must be set as the Redis base number (default: 1)
555
+ - :auth should be set if Redis need an simple authentification key <mykey>
556
+
557
+ ##### Prometheus PushGateway configuration
558
+
559
+ Prometheus PushGateway could be configured in /etc/splash.yaml
560
+
561
+ # vi /etc/splash.yml
562
+ [...]
563
+ :prometheus:
564
+ :pushgateway:
565
+ :host: "localhost"
566
+ :port: 9091
567
+ [...]
568
+
569
+ - :host should be set as the Prometheus PushGateway hostname (default: localhost)
570
+ - :port should be set as the Prometheus PushGateway port (default: 9091)
571
+
572
+ ### The Splash daemon
573
+
574
+ #### Introduction
575
+
576
+ We're going to discover the Big part of Splash the Daemon, usefull to :
577
+
578
+ - orchestration
579
+ - scheduling
580
+ - Log monitoring (without CRON scheduling)
581
+ - host2host sequences execution (optionnal )
582
+
583
+ #### Controlling the daemon
584
+
585
+ TODO
586
+
587
+ #### Configuring the daemon
588
+
589
+ TODO
590
+
591
+
592
+ ### Ecosystem
593
+
594
+ #### Execution report Template adaptions
595
+
596
+ TODO
597
+
598
+ #### Ubuntu Ansible playbook
599
+
600
+ TODO
601
+
602
+ #### Systemd integration fo daemon
603
+
604
+ TODO
605
+
606
+ #### CRON usage with or without rvmsudo
607
+
608
+ TODO
609
+
610
+ #### Default values for configuration
611
+
612
+ defined in the lib/splash/constants.rb
613
+
614
+ ```ruby
615
+
616
+ # the only one non-overridable by the configuration
617
+ CONFIG_FILE = "/etc/splash.yml"
618
+
619
+
620
+ TRACE_PATH="/var/run/splash"
621
+
622
+ DAEMON_LOGMON_SCHEDULING={ :every => '20s'}
623
+ DAEMON_PROCESS_NAME="Splash : daemon."
624
+ DAEMON_PID_PATH="/var/run"
625
+ DAEMON_PID_FILE="splash.pid"
626
+ DAEMON_STDOUT_TRACE="stdout.txt"
627
+ DAEMON_STDERR_TRACE="stderr.txt"
628
+
629
+ AUTHOR="Romain GEORGES"
630
+ EMAIL = "gems@ultragreen.net"
631
+ COPYRIGHT="Ultragreen (c) 2020"
632
+ LICENSE="BSD-2-Clause"
633
+
634
+ PROMETHEUS_PUSHGATEWAY_HOST = "localhost"
635
+ PROMETHEUS_PUSHGATEWAY_PORT = "9091"
636
+
637
+ EXECUTION_TEMPLATE="/etc/splash_execution_report.tpl"
638
+ EXECUTION_TEMPLATE_TOKENS_LIST = [:end_date,:start_date,:cmd_name,:cmd_line,:stdout,:stderr,:desc,:status,:exec_time]
639
+
640
+ BACKENDS_STRUCT = { :list => [:file,:redis],
641
+ :stores => { :execution_trace => { :type => :file, :path => "/var/run/splash" }}}
642
+ TRANSPORTS_STRUCT = { :list => [:rabbitmq],
643
+ :active => :rabbitmq,
644
+ :rabbitmq => { :url => 'amqp://localhost/'} }
645
+
646
+ ```
647
+
648
+
649
+ #### Splash CLI return code significations
650
+
651
+ TODO
652
+
653
+ ### In the Futur ?
654
+
655
+ - IHM
656
+ - Webservice
657
+
658
+
25
659
 
26
660
  ## Contributing
27
661