The Readsb-MongoDB project is a tool designed to process the output of the JSON port from either readsb
or docker-adsb-ultrafeeder
and store this data in MongoDB for long-term storage. This document serves as a guide for setting up and utilizing this solution.
You can find help on discord for this project, https://discord.com/channels/734090820684349521/935340681902309376
To use Readsb-MongoDB, you will need either a running instance of
Ensure that Readsb is accepting JSONSocket connections by running it with --net-json-port=30047
or update the environment section of docker-compose.yaml
file of ultrafeeder
with - READSB_CMD+=("--net-json-port=30047")
.
Create a .env
file based on the env.example.yaml
example, including the location of your readsb instance as follows:
READSB_JSONPORT_URL: 'readsbjsonport://hostname_of_readsb:30047'
Execute docker compose up --build -d
in your terminal. This command will build and run:
-
A Python container with
app/readsb2mongo.py
. -
A MongoDB instance.
The application collects data from the socket of readsb, transforms it by
- Renaming keys
- Modifying types, like converting timestamp to date
Then it organizes (or groups) the data into "flights".
A unique database record is created for each flight (identified by the ICAO hex identifier). This record either appends data to an existing record or creates a new one, depending on the incoming data. If no data is received for ten minutes, a new flight is recognized.
Fields of the flight record in the MongoDB database include:
flight_id
: A unique identifier composed of the ICAOhex
identifier and a timestamp of the first data received.adsb_data_start
andadsb_data_stop
: Start and end timestamps for the data collection.adsb_data_count
: The count of data points collected.callsign
: The callsign of the aircraft, stored as an empty array if not available.adsb_data
: An array with raw ADS-B data, each item representing a snapshot of the flight's state at a specific time.
You may wish to use mongo-express for database operations. Uncomment the container part in docker-compose.yaml
Some examples of simple request are shown:
- Get the last flight in database
- Get the 10 last flights without adbs_data (locations) field.
- Get the last 10 records, outputing "callsign", "hex", and counting the amount of "adsb_data".
- Get the flights, within a user defined fence.
Follow the steps below to run Readsb-MongoDB as a standalone Python application.
You must have a mongodb and adsb running.
Set up the following environment variables correctly:
-
MONGODB_URL
: This designates the URL of your MongoDB instance (For example,'mongodb://root:examplerootroot@hostname:port'
) -
READSB_JSONPORT_URL
: This signifies the URL of your readsb JSON port (For example,'readsbjsonport://hostname:port'
)
To add necessary dependencies, run the following command in your Python environment:
python pip install -r requirements.txt
With the environment ready, you can now execute Readsb-MongoDB using the following command:
python python3 app/readsb2mongo.py