This gem provides the analytics helpers that can be plugged into the SOAR architecture. The output is in the form of key value pairs that can easily be analyzed using queries on your auditing event logs.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install soar_analytics
Behavioural driven testing can be performed by testing so:
$ bundle exec rspec -cfd spec/*
Initialize and configure the analytics with the auditing provider so:
SoarAnalytics.auditing = myauditing
The Reporter class is the most basic reporting which simply reports a value in a key value pair using the specified auditing level. Not very useful for most applcations but forms the basis of other specialized reporters in this gem. The flow identifier parameter is optional.
flow_id = SoarFlow::ID::generate_flow_id reporter = SoarAnalytics::Reporter.new('my_reporter') value = 123 reporter.report(value,:warn,flow_id)
The ThresholdReporter class can be configured with various thresholds that determines the auditing level of the audit event when reported. This allows you to set levels at which you can define informational, warning and error conditions based on the value reported. Useful in examples such as where a database operation should take less than an certain amount of time. Anything above that value will then be reported as warnings or errors. The flow identifier parameter is optional.
flow_id = SoarFlow::ID::generate_flow_id threshold_reporter = SoarAnalytics::ThresholdReporter.new(name: 'my_threshold_reporter', info_threshold: 1, warn_threshold: 2, error_threshold: 3) value = 2 threshold_reporter.report(value,flow_id)
Probably the most useful reporter in this gem is the TimeDeltaReporter which calculates and reports on the time difference since the initialization of the object. This is a specialization of the ThresholdReporter. Only the parameter 'name' is required during the initialization. The rest are optional and defaults to info level for all time deltas greater or equal to zero. The flow identifier parameter is also optional.
flow_id = SoarFlow::ID::generate_flow_id timer = SoarAnalytics::TimeDeltaReporter.new(name: "db_access_time", info_threshold: 1, warn_threshold: 2, error_threshold: 3) sleep(1) timer.report(flow_id)
Bug reports and feature requests are welcome by email to barney dot de dot villiers at hetzner dot co dot za. This gem is sponsored by Hetzner (Pty) Ltd (http://hetzner.co.za)
The gem is available as open source under the terms of the MIT License.