V8 log login events to logstash

From DreamFactory
Jump to: navigation, search
DreamFactoryTutorialsV8 log login events to logstash
(Created page with "Log each user login event to Logstash. This script can be triggered by each user login API call. <source lang="javascript"> // In the scripts tab, add this script to user ->...")
 
 
Line 2: Line 2:
  
 
<source lang="javascript">
 
<source lang="javascript">
// In the scripts tab, add this script to user -> user.session -> post -> user.session.post.post_process
+
// In the scripts tab, add this script to user -> user.session -> post -> user.session.post.post_process.
// Make sure you've correctly configured Logstash as a service in the Services tab of the DreamFactory admin console
+
// Make sure you've correctly configured Logstash as a service in the Services tab of the DreamFactory Admin Console.
  
 
if(event.response.status_code === 200) {
 
if(event.response.status_code === 200) {
Line 23: Line 23:
 
<source lang="javascript">
 
<source lang="javascript">
 
// In the scripts tab, add this script to user -> user.session -> delete -> user.session.delete.pre_process.
 
// In the scripts tab, add this script to user -> user.session -> delete -> user.session.delete.pre_process.
// Make sure you've correctly configured Logstash as a service in the Services tab of the DreamFactory admin console
+
// Make sure you've correctly configured Logstash as a service in the Services tab of the DreamFactory Admin Console.
  
 
var email = '';
 
var email = '';

Latest revision as of 21:26, 4 October 2016

Log each user login event to Logstash. This script can be triggered by each user login API call.

// In the scripts tab, add this script to user -> user.session -> post -> user.session.post.post_process.
// Make sure you've correctly configured Logstash as a service in the Services tab of the DreamFactory Admin Console.
 
if(event.response.status_code === 200) {
    var email = '';
    if (platform.session.user && platform.session.user.email){
    	email = platform.session.user.email;
    }
    var log = {
        "level":"alert", 
        "message":"Logging in [" + email + "]"
    };
    platform.api.post('logstash', log);
}

Log each user logout event to Logstash. This script can be triggered by each user logout API call.

// In the scripts tab, add this script to user -> user.session -> delete -> user.session.delete.pre_process.
// Make sure you've correctly configured Logstash as a service in the Services tab of the DreamFactory Admin Console.
 
var email = '';
if(platform.session.user && platform.session.user.email){
	email = platform.session.user.email;
}
var log = {
    "level":"alert", 
    "message":"Logging out [" + email + "]"
};
platform.api.post('logstash', log);