Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

auth0/logs-processor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

auth0-logs-processor

A small module that simplifies the processing of Auth0 logs.

The amount of days logs are available depends on your Auth0 plan.

Installing

npm install auth0-logs-processor

Usage

If you want to count how many logs you have

var processor = require('auth0-logs-processor').create({
    domain: 'MY_AUTH0_DOMAIN',
    clientId: 'MY_AUTH0_CLIENT',
    clientSecret: 'MY_AUTH0_SECRET',
});

var count = 0;

processor.each(function(log){
    count++;
});

processor.done(function(){
    console.log(count);
});

processor.start();

Available in the samples folder, monthly signup per app:

var processor = require('auth0-logs-processor').create({
  domain: 'MY_AUTH0_DOMAIN',
  clientId: 'MY_AUTH0_CLIENT',
  clientSecret: 'MY_AUTH0_SECRET',
});

var months = {};

processor.each(function(entry){
  // discard non signup events
  if (entry.type !== 'ss') { return; }

  var date = new Date(entry.date);

  var monthKey = date.getUTCFullYear() + '-' + date.getUTCMonth();

  if (!months[monthKey]){
    months[monthKey] = {};
  }

  if (!months[monthKey][entry.client_id]){
    months[monthKey][entry.client_id] = 0;
  }

  months[monthKey][entry.client_id]++;
});

processor.done(function(){
  Object.keys(months).forEach(function(m){
    console.log('Month:' + m);
    Object.keys(months[m]).forEach(function(c){
      console.log('Client ' + c + ':' + months[m][c]);
    });
  })
});

processor.start();

And the same as above assuming your logs fit into memory (dedicated to @woloski):

var _ = require('lodash');

var processor = require('auth0-logs-processor').create({
  domain: 'MY_AUTH0_DOMAIN',
  clientId: 'MY_AUTH0_CLIENT',
  clientSecret: 'MY_AUTH0_SECRET',
});

var entries = [];

processor.each(function(entry){
  entries.push(entry);
});

processor.done(function(){
  var groups = _.chain(entries)
    .filter(function(e){
      return e.type === 'ss'
    })
    .groupBy(function(e){
      var date = new Date(e.date);

      return date.getUTCFullYear() + '-' + date.getUTCMonth() + ' ' + e.client_id;
    })
    .value();

  _.forOwn(groups, function(value, key) {
    console.log(key + ': ' + value.length);
  });
});

processor.start();

Charts

Charts are cool, and you can use the data to create your own 😃.

See samples/charts for a pie chart displaying logins per identity provider. It looks like this:

Shoutout to d3pie.

Put some of these together and create custom dashboards 🎆 💥 ⚡.

Contributing

Feel free to add new samples by sending PRs.

Issue Reporting

If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.

Author

Auth0

License

This project is licensed under the MIT license. See the LICENSE file for more info.

About

A small module that simplifies the processing of Auth0 logs

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published