For a developer who has just cloned the repository: the four programs, what every folder holds, and the classes in the library. How data moves and where to change things are on the next two pages. It stays high level on purpose; SPEC.md in the repository goes deeper.
Loghound is open source and contributions are welcome. To become a contributor to this or any other Opensolr open source project, write to support@opensolr.com and tell us what you would like to work on.
Loghound is plain PHP 8.1+ with no Composer packages, no npm and no build step. It is really four programs sharing one library in src/:
The ingest daemon
bin/loghound-tail runs all the time, reads your access logs as they grow, and writes one document per request into the hits index.
The scorer
bin/loghound-score runs every minute, closes finished visits, merges beacon data, scores each visit and writes it into the sessions index.
The beacon
public/b.js runs in visitors' browsers and posts to public/collect.php, which only stages the data locally.
The panel
public/index.php serves the web interface; every card on a page loads its own data from the two indexes.
Everything Loghound learns lives in two Opensolr indexes it provisions for you; small working state (file positions, open visits, staged beacon rows) lives in a local SQLite file.
bin/The command-line programs: the daemon, the scorer, retention, the schema check and the setup wizard.
src/All PHP classes, namespace Loghound\, loaded by src/autoload.php.
public/The web root: the panel, the beacon collector, the beacon script, CSS, JavaScript and vendored assets.
solr/The configuration of the two indexes, hits/conf and sessions/conf.
config/loghound.example.php, the documented template. The live loghound.php is written by setup and never committed.
install/install.sh, uninstall.sh, the systemd units and timers, web server and PHP-FPM examples.
tests/A dependency-free test runner, the tests, anonymised log fixtures and the secret scanner.
tools/panel-preview.php, for looking at the panel with demo data while developing.
var/Runtime state, never committed: the SQLite database, status files, setup jobs.
docs/Operator and developer documentation in Markdown: install, beacon, detection, panel, schema, privacy, security, attacks.
SPEC.mdThe binding technical specification. Field names, paths and signatures in it are contracts.
README.md, CONTRIBUTING.md, CHANGELOG.md, LICENSEThe front page, the rules for contributions, the release history (Keep a Changelog, semantic versions), and the MIT licence.
bin/loghound-tailTail, parse, enrich, group into visits, and write batches into the hits index.
loghound-scoreClose idle visits, merge beacon data, apply the scoring rules, write visits into the sessions index, rebuild daily rollups.
loghound-retentionDelete what is older than the retention period, keep the indexes within the plan, purge old local state.
loghound-schemaCompare the live schemas with this release; --apply uploads them.
loghound-setupThe interactive setup wizard; it shares its logic with the browser installer.
Every command and option is on the command reference; the services and timers on running it.
src/Top-level classes
Load, validate and save the configuration (every default is in Config::defaults()); the local SQLite store for file positions, open visits, caches, staged beacon rows and rate limits.
Follow files across rotation; compile an Apache or nginx log format; find the logs and their format; turn a line into a normalised request.
Group requests into visits; skip traffic that is never recorded; the operator's own attack patterns; where a visit really came from.
The only way code talks to Solr, with its query safety checks; the Opensolr account API; the Opensolr request log; query shapes; plan quota and size-based retention.
Validates beacon data and merges it into visits.
Escaping, safe paths, CSRF and authentication; the panel's read cache; asset versions; safe CSV export; the failure report.
Subfolders
src/Enrich/— adds context to a request:Geo(country and timezone),Asn(network, netname, reverse DNS),Ua(browser and declared bots).src/Score/— detection:Signalsextracts the evidence,Rulesholds the weighted rules and the verdict,Attacksspots hostile requests.src/Panel/— the web interface: one controller class per view (Overview,Bots,Fingerprints,Sessions,Seo...), plusLayout(routes, navigation, page chrome),Gateway(the panel's only route to Solr),Query,Facets,Sorting,Pagingand the long-runningJobs.src/Setup/— installing: the browserInstaller, detection and requirement checks, index provisioning and schema sync, resumable jobs, reset and teardown.src/Auth/— panel sign-in extras: two-factor codes, the QR code for the authenticator, “stay signed in”.src/Live/— the live view, reading logs as they are written without touching ingest.src/Geo/Countries.phpandsrc/Beacon/Doc.php— the one country table, and the one description of the beacon shown wherever it is documented.
How a log line, a visit, a beacon report and a panel page travel through the code: How data moves. Where to change something, the tests and the contribution rules: Changing the code.
For developers
- Project structure
- How data moves
- Changing the code