project project-management-only / Scraper Snitch Bot avatar

project-management-only/scraper-snitch-bot#3: Log-Agent Dry Run Mode



Issue Information

Issue Type: issue
Status: closed
Reported By: btasker
Assigned To: btasker

Milestone: v0.12
Created: 19-Jan-23 18:00



Description

When first building the agent, I was able to manually review the logs and assess how each line should be scored.

That's going to be infeasible as the scoring gets more complex (and/or logs get busier).

What I'd like, is a dry-run mode to pass log lines through - it should then output the logline with the calculated score attached



Toggle State Changes

Activity


assigned to @btasker

verified

mentioned in commit misc/python-mastodon-bot-detection@c777c668072b30449e3729c8d7876ce13816c6c4

Commit: misc/python-mastodon-bot-detection@c777c668072b30449e3729c8d7876ce13816c6c4 
Author: B Tasker                            
                            
Date: 2023-01-19T18:09:52.000+00:00 

Message

Add support for a dry run mode for project-management-only/scraper-snitch-bot#3

This allows the log-agent to be run without writing data to the TSDB - it'll just output loglines that it's considered with an associated score.

Currently, lines that are skipped won't be output - it's probably worth expanding to support those too

+21 -1 (22 lines changed)

The initial implementation is in place and working, it can be used as follows

cat ~/tmp/access.log  | docker run --rm -e DRY_RUN="Y" -i <other opts> devtest

The important bit is the -i being passed to docker, otherwise it'll process but won't print to stdout.

verified

mentioned in commit misc/python-mastodon-bot-detection@28ee3c1203208da53be08fff5a59d312e25c7fd8

Commit: misc/python-mastodon-bot-detection@28ee3c1203208da53be08fff5a59d312e25c7fd8 
Author: B Tasker                            
                            
Date: 2023-01-19T18:24:43.000+00:00 

Message

Dry-run output includes flags to help identify why a score has been assigned (project-management-only/scraper-snitch-bot#3)

Each check now appends a debug flag, these are squashed into a CSV and printed as the 2nd column of the dry run output

+35 -13 (48 lines changed)

There are 3 ways to trigger dry run:

Env Variables

  • DRY_RUN: set to Y

Command line options

  • -n
  • --dry-run

The environment variable is currently more convenient when using the docker image - the bot's dockerfile uses CMD rather than ENTRYPOINT so adding commandline args means respecifying the command at the same time.

I likely will change that in future, but it's currently quite useful for testing/debugging.