Repository: https://github.com/flamingo-stack/osquery
Project Type: Cross-platform system instrumentation and SQL-based telemetry engine
osquery is a high-performance, cross-platform system instrumentation framework that exposes operating system state as a relational database. It allows operators to query system information using SQL, transforming low-level OS data (processes, files, users, sockets, events, etc.) into structured, queryable tables.
The repository implements:
- A secure embedded SQLite execution engine
- A virtual table framework for system data
- A pluggable configuration and logging system
- A distributed query execution model
- A publisher–subscriber eventing subsystem
- A robust extension and IPC framework
- A cross-platform filesystem abstraction layer
- A pluggable persistent database layer
Together, these modules form a telemetry agent capable of operating in standalone, scheduled, or centrally orchestrated modes.
The osquery architecture is modular and layered. Below is the complete high-level flow from configuration to data output.
flowchart TD
Config["Core Config And Flags"] --> Scheduler["Scheduler"]
Scheduler --> SQLCore["SQL Core And Virtual Tables"]
SQLCore --> SQLite["Embedded SQLite"]
SQLite --> VTables["Virtual Tables"]
VTables --> TablePlugins["Table Plugins / Extensions"]
SQLCore --> DiffEngine["Diff Engine"]
DiffEngine --> LogItem["QueryLogItem"]
LogItem --> Logging["Logging Module"]
LogItem --> Distributed["Distributed Querying"]
Distributed --> RemoteHTTP["Remote HTTP"]
SQLCore --> Database["Database"]
Eventing["Eventing Core"] --> Database
Eventing --> SQLCore
Extensions["Extensions And IPC"] --> TablePlugins
Extensions --> Config
Extensions --> Logging
Watcher["Init Shutdown And Watcher"] --> Scheduler
Watcher --> Extensions
Modules:
- Core Init Shutdown And Watcher
- Core Config And Flags
Responsibilities:
- Process lifecycle management
- Worker/watchdog supervision
- Dynamic configuration loading
- Scheduled query orchestration
- Flag and runtime option management
flowchart TD
Init["Initializer"] --> RoleCheck["Determine Role"]
RoleCheck --> WatcherProc["Watcher Process"]
RoleCheck --> WorkerProc["Worker Process"]
WatcherProc --> WorkerProc
WorkerProc --> Config
WorkerProc --> SQL
WorkerProc --> Events
WorkerProc --> Logging
The watcher enforces CPU/memory limits and restarts workers if necessary.
Module:
- SQL Core And Virtual Tables
Responsibilities:
- Embed and control SQLite
- Register osquery tables as SQLite virtual tables
- Execute ad-hoc and scheduled queries
- Compute differential results
- Produce structured logs
flowchart TD
ScheduledQuery["ScheduledQuery"] --> SQLInternal["SQLInternal"]
SQLInternal --> SQLite["SQLite Engine"]
SQLite --> VirtualTable["VirtualTable"]
VirtualTable --> TableRegistry["TablePlugin Registry"]
SQLInternal --> Results["QueryData"]
Results --> Diff["DiffResults"]
Diff --> LogItem["QueryLogItem"]
LogItem --> Logging
This layer enforces:
- SQLite opcode allowlisting
- PRAGMA restrictions
- Required constraint enforcement
- Controlled virtual table attachment
Module:
- Eventing Core
Implements a publisher–subscriber model where:
- Event Publishers monitor system activity
- Event Subscribers persist events and expose them as tables
- Scheduled queries determine expiration windows
flowchart TD
OS["Operating System Event"] --> Publisher["EventPublisher"]
Publisher --> Subscriber["EventSubscriber"]
Subscriber --> Database
Database --> SQLCore
This allows real-time OS activity to be queried via SQL.
Module:
- Database
Provides:
- Domain-scoped key–value storage
- RocksDB persistent backend
- Ephemeral in-memory fallback
- Schema versioning and migrations
- Thread-safe reset protection
Used for:
- Scheduled query state
- Event indexes
- Distributed execution tracking
- Performance metrics
- Configuration caching
Module:
- Logging
Provides pluggable logging backends via LoggerPlugin.
Data sources:
- Scheduled query results
- Distributed query results
- Event tables
- Internal status logs
flowchart LR
SQL --> Logger
Events --> Logger
Init --> Logger
Logger --> Filesystem["Filesystem Logger"]
Module:
- Distributed Querying
Enables central orchestration of SQL execution across nodes.
sequenceDiagram
participant Server
participant Agent
participant SQL
Agent->>Server: Request distributed work
Server-->>Agent: JSON queries
Agent->>SQL: Execute query
SQL-->>Agent: Results
Agent->>Server: Submit results
Features:
- TLS-based transport plugin
- SHA-256 query hashing
- Denylisting of unstable queries
- Performance recording
- Result serialization
Module:
- Extensions And IPC
Provides:
- Thrift-based RPC layer
- Extension Manager
- Registry broadcasting
- External table implementations
- Cross-process plugin support
flowchart LR
Core["osquery Core"] --> Manager["Extension Manager"]
Extension["Extension Process"] --> Manager
Core --> Extension
Extensions can implement:
- Tables
- Config plugins
- Logger plugins
- Distributed plugins
Module:
- Filesystem And Fileops
Provides:
- Cross-platform file abstraction
- Permission enforcement
- Safe executable validation
- Globbing and traversal
- Read size limits
- Windows ACL parity with POSIX modes
This module underpins:
- Logging
- Database storage
- Extension loading
- File-backed virtual tables
Module:
- Remote Http
Implements:
- HTTP/HTTPS client
- TLS handling
- Certificate verification
- Proxy support
- Timeout enforcement
Used by:
- Distributed querying
- TLS logging plugins
- Remote configuration retrieval
Module:
- Hashing
Provides:
- Streaming SHA256, SHA1, MD5
- Multi-algorithm hashing in single pass
- File and memory buffer hashing
Used by:
- File integrity tables
- Distributed validation
- Logging workflows
Top-level module directories:
osquery/core
osquery/config
osquery/sql
osquery/database
osquery/events
osquery/extensions
osquery/distributed
osquery/filesystem
osquery/hashing
osquery/remote
plugins/
Each directory corresponds to one of the major architectural subsystems described above.
Below are the primary internal module documentation entry points:
| Module | Documentation |
|---|---|
| Core Config And Flags | osquery/core, osquery/config, plugins/config |
| Core Init Shutdown And Watcher | osquery/core |
| SQL Core And Virtual Tables | osquery/core/sql, osquery/sql |
| Database | osquery/database |
| Logging | osquery/core/plugins, plugins/logger |
| Eventing Core | osquery/events |
| Extensions And IPC | osquery/extensions |
| Distributed Querying | osquery/distributed, plugins/distributed |
| Filesystem And Fileops | osquery/filesystem |
| Hashing | osquery/hashing |
| Remote HTTP | osquery/remote |
Complete data flow:
flowchart TD
Config --> Scheduler
Scheduler --> SQLCore
SQLCore --> VirtualTables
VirtualTables --> OSData["Operating System"]
SQLCore --> DiffEngine
DiffEngine --> LogItem
LogItem --> Logging
LogItem --> Distributed
Distributed --> RemoteHTTP
SQLCore --> Database
Events --> Database
Database --> SQLCore
In short:
- Configuration defines scheduled or distributed queries.
- The scheduler invokes the SQL engine.
- Virtual tables collect system data.
- Results are diffed against historical state.
- Structured logs are generated.
- Logs are written locally or sent remotely.
- Persistent state is stored in the database.
- The watchdog enforces runtime safety.
The flamingo-stack/osquery repository implements a production-grade, modular telemetry engine built around:
- Secure embedded SQL execution
- Virtualized system tables
- Pluggable architecture (config, logging, distributed, extensions)
- Real-time event ingestion
- Distributed orchestration
- Strong process isolation and watchdog enforcement
Its architecture cleanly separates:
- Control plane (init, config, scheduler)
- Execution engine (SQL + virtual tables)
- Data plane (events, database)
- Transport layer (logging, distributed, HTTP)
- Extensibility layer (extensions and IPC)
This modular design makes osquery adaptable to standalone, enterprise, and distributed fleet deployments while maintaining strong safety and performance guarantees.