An open API service indexing awesome lists of open source software.

https://github.com/oscarotero/analogger

Deno library to consume access logs files and generate reports
https://github.com/oscarotero/analogger

analytics deno logs

Last synced: 2 months ago
JSON representation

Deno library to consume access logs files and generate reports

Awesome Lists containing this project

README

          

# Analogger

This is a simple [Deno](https://deno.land/) library to consume access logs
generated by nginx/apache and generate reports about visits, sessions, etc.

It's divided in two scopes:

- **Transformers:** to parse, transform and enrich the data from log files.
- **Reporters:** to generate reports of this data.

## Example

```ts
import {
read,
show,
reports,
transform,
transformers as t
} from "https://deno.land/x/analogger/mod.ts";

// Step 1: Read the log file.
const logs = read("./access.log");

// Step 2: Parse and transform the logs:
const result = await transform(
logs,
t.parse(), // Parse the data.
t.filterByExtensions([".html", ""]), // Filter by .html extensions or not extension at all.
t.filter((log) => log.status === 200), // Get only requests generating a 200 status code response.
t.isBot(), // Add the `isBot` property indicating if the request is from a bot (ex: Google).
t.filter((log) => !log.isBot), // Discard request from bots
t.parseUserAgent(), // Parse the user-agent info
t.sessionId(), // Add the `sessionId` property with an autogenerated session id
t.searchEngine(), // Add the `searchEngine` property (google, bing, yahoo...)
t.socialNetwork(), // Add the `socialNetwork` property (facebook, twitter, instagram...)
);

// Step 3: Generate reports with this data.
// For example, the number of sessions by month:
const report = reports.sessions(result, "monthly");

// Step 3: See the report in your browser
await show(report);
```