diff --git a/.gitignore b/.gitignore index 6b22b59..cce2e7c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ release dump1090prom +docs diff --git a/Makefile b/Makefile index bdbed47..4f16cf0 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ SHELL := /bin/bash GO := GO111MODULE=on go GO_PATH = $(shell $(GO) env GOPATH) -APP_VERSION_DOT = "1.0.3" +APP_VERSION_DOT = "1.0.4" .PHONY: all all: help diff --git a/README.md b/README.md index dc7d527..5b3bc5e 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,30 @@ # Dump1090Prom – Aircraft data exporter for Prometheus A Prometheus exporter for `readsb`/`dump1090` aircraft data. -This exporter converts dump1090 data into [prometheus](https://prometheus.io/) metrics, allowing to monitor and visualizing collected aircraft data in detail. -This repository contains a [Grafana dashboard](dashboards/dump1090prom-grafana-dashboard.json) for visualizing the collected data. +This exporter converts dump1090 data into [Prometheus](https://prometheus.io/) metrics, allowing you to monitor and visualize collected aircraft data in detail. +The repository includes a [Grafana dashboard](dashboards/dump1090prom-grafana-dashboard.json) for visualizing the metrics. Tested with: - [flightaware/dump1090](https://github.com/flightaware/dump1090) - [wiedehopf/readsb](https://github.com/wiedehopf/readsb) -Version: 1.0.3 +Version: 1.0.4 ## Features -- Exports aircraft data as Prometheus metrics for each aircraft -- Supports multiple data sources via a base path: - - Local directory containing `aircraft.json` and `receiver.json` - - HTTP/HTTPS base URL exposing `aircraft.json` and `receiver.json` -- Enriches aircraft data with airline information (embedded from Wikipedia data) -- Calculates distance between receiver and aircraft when the receiver position is known (from receiver.json or -lat/-lon override) -- Includes a ready-to-use Grafana dashboard +- Exports aircraft data as Prometheus metrics. +- Supports multiple data sources: + - Local directory containing `aircraft.json` and `receiver.json`. + - HTTP/HTTPS base URL exposing `aircraft.json` and `receiver.json`. +- Enriches aircraft data with airline information (embedded from Wikipedia). +- Calculates the distance between the receiver and aircraft when the receiver position is known (from `receiver.json` or `-lat`/`-lon` override). +- Includes a ready-to-use Grafana dashboard. ## Installation ### Prerequisites -- *readsb* or *dump1090* with *rtlsdr* or compatible software generating `aircraft.json` and `receiver.json` +- `readsb` or `dump1090` (with `rtlsdr` or compatible hardware) generating `aircraft.json` and `receiver.json`. ### Option 1: Download a release file @@ -46,7 +46,7 @@ go build ### Running permanently (Linux) -If you use Linux, you can use [this systemd unit file](./dev/dump1090prom.service) and copy it +If you use Linux with systemd, you can use [this systemd unit file](./dev/dump1090prom.service) and copy it to `/etc/systemd/system/dump1090prom.service`. You may want to adjust the `port` and add custom parameters in `ExecStart`. Look for the Configuration and CLI section below for more information. @@ -69,28 +69,32 @@ env GOOS=linux GOARCH=arm go build -o dump1090prom The exporter is configured via command-line flags: -- `-base-url` string +- `-base-url` `string` Base URL to the directory where aircraft.json and receiver.json are available -- `-base-path` string +- `-base-path` `string` Local filesystem directory containing aircraft.json and receiver.json, e.g. /var/www/html/data -- `-lat` float +- `-lat` `float` Override receiver latitude (used for distance calculation) -- `-lon` float +- `-lon` `float` Override receiver longitude (used for distance calculation) -- `-host` host (default: `127.0.0.1`) +- `-host` `host` (default: `127.0.0.1`) Override host where /metrics is exposed -- `-port` port (default: `8080`) +- `-port` `port` (default: `8080`) Override port where /metrics is exposed -- `-verbose` bool (default: `false`) +- `-verbose` `bool` (default: `false`) Enable verbose logging -- `-distance-calc` bool (default: `true`) +- `-distance-calc` `bool` (default: `true`) Enable distance calculation to aircraft -- `-airline-label` bool (default: `true`) +- `-airline-label` `bool` (default: `true`) Enable airline labelling -- `-expose-files` bool (default: `true`) +- `-expose-files` `bool` (default: `true`) Expose original aircraft.json and receiver.json files at /aircraft.json and /receiver.json -- `-rolling-map-size` int (default: `1000`) +- `-rolling-map-size` `int` (default: `1000`) Default size of the rolling map for caching +- `-collector` `string` (default: `dump1090prom`) + Constant 'collector' label value of this instance +- `-labels` `string` + Global labels to add to all metrics (e.g., 'location=home,environment=testing') Notes: - When `-lat` and `-lon` are not provided, the exporter will try to read receiver position from `receiver.json`. @@ -126,8 +130,12 @@ Expose metrics on a different port: ./dump1090prom -base-url http://your-dump1090-server:8080/data -port 9091 ``` -Typically `dump1090prom` uses `` and `` as defined in your `receiver.json`, -if you want to overwrite the receiver position, you can use the `-lat` and `-lon` flags. +Add global labels to all metrics: +```bash +./dump1090prom -base-url http://your-dump1090-server:8080/data -labels "environment=home" +``` + +Typically, `dump1090prom` uses the `` and `` values defined in your `receiver.json`. To override the receiver position, use the `-lat` and `-lon` flags. ```bash ./dump1090prom -base-url http://your-dump1090-server:8080/data -lat -lon @@ -135,7 +143,7 @@ if you want to overwrite the receiver position, you can use the `-lat` and `-lon ## Prometheus Configuration -Note: You have to replace `` (and port) with the IP address of your `dump1090prom` server. +Note: Replace `` and port with the IP address of your `dump1090prom` server. ```yaml scrape_configs: @@ -169,50 +177,16 @@ http://localhost:8080/receiver.json All metrics are prefixed with `dump1090prom_`. -``` -dump1090prom_aircraft_adsb_version, Type: GAUGE, Description: Version of the ADS-B protocol in use -dump1090prom_aircraft_altitude_baro_feet, Type: GAUGE, Description: Barometric altitude in feet -dump1090prom_aircraft_altitude_geom_feet, Type: GAUGE, Description: Geometric altitude in feet -dump1090prom_aircraft_barometric_vertical_rate_feet_per_minute, Type: GAUGE, Description: Barometric vertical rate in feet per minute -dump1090prom_aircraft_count, Type: GAUGE, Description: Number of different aircraft currently seen -dump1090prom_aircraft_distance_from_position_meters, Type: GAUGE, Description: Distance in meters from the recording position -dump1090prom_aircraft_flight_info, Type: GAUGE, Description: Metadata about the flight and aircraft -dump1090prom_aircraft_geometric_vertical_rate_feet_per_minute, Type: GAUGE, Description: Geometric vertical rate in feet per minute -dump1090prom_aircraft_ground_speed_knots, Type: GAUGE, Description: Ground speed in knots -dump1090prom_aircraft_gva, Type: GAUGE, Description: Geometric Vertical Accuracy -dump1090prom_aircraft_indicated_airspeed_knots, Type: GAUGE, Description: Indicated airspeed in knots -dump1090prom_aircraft_latitude, Type: GAUGE, Description: Latitude of aircraft -dump1090prom_aircraft_longitude, Type: GAUGE, Description: Longitude of aircraft -dump1090prom_aircraft_mach_number, Type: GAUGE, Description: Mach number -dump1090prom_aircraft_magnetic_heading_degrees, Type: GAUGE, Description: Magnetic heading in degrees -dump1090prom_aircraft_mode_a, Type: GAUGE, Description: Mode A (ident) capability (1 if present) -dump1090prom_aircraft_mode_c, Type: GAUGE, Description: Mode C (altitude) capability (1 if present) -dump1090prom_aircraft_nac_p, Type: GAUGE, Description: Navigation Accuracy Category for Position -dump1090prom_aircraft_nac_v, Type: GAUGE, Description: Navigation Accuracy Category for Velocity -dump1090prom_aircraft_nav_altitude_mcp_feet, Type: GAUGE, Description: MCP/FCU selected altitude in feet -dump1090prom_aircraft_nav_heading_degrees, Type: GAUGE, Description: Selected heading in degrees -dump1090prom_aircraft_nav_qnh_millibar, Type: GAUGE, Description: QNH setting in millibars -dump1090prom_aircraft_nic, Type: GAUGE, Description: Navigation Integrity Category -dump1090prom_aircraft_nic_baro, Type: GAUGE, Description: Navigation Integrity Category for barometric altitude -dump1090prom_aircraft_oat, Type: GAUGE, Description: Outside Air Temperature in Celsius -dump1090prom_aircraft_rc, Type: GAUGE, Description: Radius of containment -dump1090prom_aircraft_roll_degrees, Type: GAUGE, Description: Roll angle in degrees -dump1090prom_aircraft_rssi_dbm, Type: GAUGE, Description: Received Signal Strength Indicator in dBm -dump1090prom_aircraft_sda, Type: GAUGE, Description: System Design Assurance -dump1090prom_aircraft_seen_pos_seconds, Type: GAUGE, Description: Seconds since position was last updated -dump1090prom_aircraft_seen_seconds, Type: GAUGE, Description: Seconds since this aircraft was last seen -dump1090prom_aircraft_sil, Type: GAUGE, Description: Surveillance Integrity Level -dump1090prom_aircraft_spi, Type: GAUGE, Description: Special Position Identification (IDENT) -dump1090prom_aircraft_tat, Type: GAUGE, Description: Total Air Temperature in Celsius -dump1090prom_aircraft_track_degrees, Type: GAUGE, Description: Track angle in degrees (0-359) -dump1090prom_aircraft_track_rate_degrees_per_second, Type: GAUGE, Description: Rate of change of track angle in degrees per second -dump1090prom_aircraft_true_airspeed_knots, Type: GAUGE, Description: True airspeed in knots -dump1090prom_aircraft_true_heading_degrees, Type: GAUGE, Description: Selected true heading in degrees -dump1090prom_now_timestamp, Type: GAUGE, Description: Current timestamp in seconds since the epoch -dump1090prom_total_messages, Type: COUNTER, Description: Total number of messages received -``` +| Metric Name | Type | Description | +| ----------- | ---- | ----------- | +| `aircraft_flight_info` | Gauge | Metadata about the flight and aircraft (includes airline, country, squawk, etc.). | +| `aircraft_altitude_baro_feet` | Gauge | Barometric altitude in feet. | +| `aircraft_ground_speed_knots` | Gauge | Ground speed in knots. | +| `aircraft_distance_from_position_meters` | Gauge | Distance from the receiver in meters. | +| `aircraft_count` | Gauge | Total number of aircraft currently seen. | +| `total_messages` | Counter | Total number of messages received. | -Additional metrics are available (see [metric.go](./metric.go) for the full list), including heading, vertical rates, ADS-B version, NAV data, and more. +Additional metrics are available for ADS-B version, vertical rates, navigation data, and more. See [metric.go](./metric.go) for a full list or visit the `/metrics` endpoint. ## Development @@ -228,14 +202,5 @@ The `dev` directory contains resources for setting up a development environment: - `dev/prometheus`: Prometheus configuration and Podman Compose setup -## License -``` - GNU AFFERO GENERAL PUBLIC LICENSE - Version 3, 19 November 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. -``` - -This project is licensed under the terms of the license included in the [`LICENSE`](./LICENSE) file. \ No newline at end of file +This project is licensed under the terms of the [GNU Affero General Public License v3.0](./LICENSE). +Wikipedia airline data is licensed under [CC-BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/). diff --git a/aircraft.go b/aircraft.go index 3b49aa6..0a9f557 100644 --- a/aircraft.go +++ b/aircraft.go @@ -37,13 +37,29 @@ type airline struct { Comments string } -// readAirlinesData reads the airlines data from the .dat file +// countryData represents a country entry from the countries.csv file +type countryData struct { + Country string + CountryHexPrefixes []string + CountryICAOCode string + HexRangeStart string + HexRangeEnd string + PossibleRegistry string +} + +// readAirlinesData reads the airlines data from the .csv file // and returns a slice of airline structs func readAirlinesData(fileContent string) ([]airline, error) { reader := csv.NewReader(bufio.NewReader(strings.NewReader(fileContent))) reader.Comma = ';' reader.LazyQuotes = true + // skip first line + _, err := reader.Read() + if err == io.EOF { + log.Fatal("airlines.csv content is empty") + } + var airlines []airline for { record, err := reader.Read() @@ -85,16 +101,101 @@ func readAirlinesData(fileContent string) ([]airline, error) { return airlines, nil } +// readCountryData reads the country data from the countries.csv file +// and returns a slice of countryData structs +func readCountryData(fileContent string) ([]countryData, error) { + reader := csv.NewReader(bufio.NewReader(strings.NewReader(fileContent))) + reader.Comma = ';' + reader.LazyQuotes = true + + var countries []countryData + // skip header + _, err := reader.Read() + if err != nil { + return nil, fmt.Errorf("error reading header: %w", err) + } + + for { + record, err := reader.Read() + if err == io.EOF { + break + } + if err != nil { + return nil, fmt.Errorf("error reading CSV: %w", err) + } + + if len(record) < 6 { + log.Printf("Invalid line in countries.csv detected: %v", record) + continue + } + + var prefixes []string + for _, p := range strings.Split(strings.TrimSpace(record[1]), ",") { + p = strings.ToUpper(strings.TrimSpace(p)) + if p != "" { + prefixes = append(prefixes, p) + } + } + + country := countryData{ + Country: strings.TrimSpace(record[0]), + CountryHexPrefixes: prefixes, + CountryICAOCode: strings.TrimSpace(record[2]), + HexRangeStart: strings.TrimSpace(record[3]), + HexRangeEnd: strings.TrimSpace(record[4]), + PossibleRegistry: strings.TrimSpace(record[5]), + } + countries = append(countries, country) + } + + return countries, nil +} + var icaoToFilter []string // global variable to store airlines known var airlines []airline +var icaoCountries []countryData + +// the following mapping is used to enable full mapping of airline countries to ICAO country names +var airlineCountryMapping map[string]string = map[string]string{ + "Brunei": "Brunei Darussalam", + "Burma": "Myanmar", + "Côte d'Ivoire": "Côte d Ivoire", + "Democratic People's Republic of Korea": "North Korea", + "Democratic Republic of Congo": "Democratic Republic of the Congo", + "Greenland": "Denmark", + "Hong Kong": "Hong Kong SAR of China", + "Iran": "Iran, Islamic Republic of", + "Iraqi Kurdistan": "Iraq", + "Ivory Coast": "Côte d Ivoire", + "Laos": "Lao People's Democratic Republic", + "Libya": "Libyan Arab Jamahiriya", + "Macedonia": "North Macedonia", + "Moldova": "Republic of Moldova", + "Netherlands": "Netherlands, Kingdom of the", + "North Korea": "Democratic People's Republic of Korea", + "Palau": "United States", + "Republic of the Congo": "Congo, Republic of the", + "Russia": "Russian Federation", + "Serbia": "Yugoslavia", + "Somali Republic": "Somalia", + "South Korea": "Republic of Korea", + "Syria": "Syrian Arab Republic", + "São Tomé and Príncipe": "Sao Tome and Principe", + "THAILAND": "Thailand", + "Taiwan": "China", + "Tanzania": "United Republic of Tanzania", + "The Gambia": "Gambia", + "Turkiye": "Turkey", + "UAE": "United Arab Emirates", + "Vietnam": "Viet Nam", +} -func getAirlineLabel(flight string) *string { +func getAirlineLabel(flight string, hex string) *string { if flight == "" { return nil } - // TODO make nice airlineLabel, exists := flightAirLineLabelMap.Get(flight) if exists { return &airlineLabel @@ -113,18 +214,95 @@ func getAirlineLabel(flight string) *string { } } - if len(prefixes) == 0 || len(matchingAirlines) == 0 { + var countryOfAirlineAndIcaoMatches = false + countries := getIcaoCountries(hex) + for _, match := range matchingAirlines { + airlineCountry := match.Country + // consider that wikipedia airlines have not consistent exactly icao conforming country names + if mapped, ok := airlineCountryMapping[airlineCountry]; ok { + airlineCountry = mapped + } + for _, country := range countries { + if airlineCountry == country.Country { + countryOfAirlineAndIcaoMatches = true + break + } + } + } + + if len(matchingAirlines) == 0 { // no match return nil } if CONFIG.IsVerbose && len(matchingAirlines) > 1 { log.Printf("multiple matches for %s: %#v", flight, matchingAirlines) } - for _, airline := range matchingAirlines { - flightAirLineMap.Set(flight, airline) - label := fmt.Sprintf("%s - %s/%s %s", airline.ICAO, airline.Name, airline.Callsign, airline.Country) - flightAirLineLabelMap.Set(flight, label) - return &label + + var ignoreAirlineMatch = false + airline := matchingAirlines[0] + + if !countryOfAirlineAndIcaoMatches { + countries := getIcaoCountries(hex) + for _, country := range countries { + if strings.HasPrefix(strings.ToUpper(flight), strings.ToUpper(country.CountryICAOCode)) && + strings.HasPrefix(strings.ToUpper(airline.ICAO), strings.ToUpper(country.CountryICAOCode)) { + if CONFIG.IsVerbose { + log.Printf("skipped airline detection. no country match (%s) for %s with hex %s: %#v", country.Country, flight, hex, matchingAirlines) + } + ignoreAirlineMatch = true + break + } else { + countryLabels := getIcaoCountryLabel(hex) + if CONFIG.IsVerbose { + log.Printf("no country match (%s) for %s with hex %s: %#v", countryLabels, flight, hex, matchingAirlines) + } + } + } + } + + if ignoreAirlineMatch { + flightAirLineLabelMap.Set(flight, "") + return nil + } + + flightAirLineMap.Set(flight, airline) + label := fmt.Sprintf("%s - %s/%s %s", airline.ICAO, airline.Name, airline.Callsign, airline.Country) + flightAirLineLabelMap.Set(flight, label) + return &label +} + +func getIcaoCountryLabel(hex string) string { + if hex == "" { + return "" + } + countries := getIcaoCountries(hex) + if len(countries) == 0 || countries == nil { + return "" + } + var countryLabels []string + for _, country := range countries { + countryLabels = append(countryLabels, country.Country) + } + return strings.Join(countryLabels, ", ") +} + +func getIcaoCountries(hex string) []countryData { + if hex == "" { + return nil + } + if countries, exists := flightIcaoCountryMap.Get(hex); exists { + return countries + } + hex = strings.ToUpper(hex) + var matches []countryData + for _, country := range icaoCountries { + for _, prefix := range country.CountryHexPrefixes { + if strings.HasPrefix(strings.ToUpper(hex), strings.ToUpper(prefix)) { + matches = append(matches, country) + break + } + } } - return nil + flightIcaoCountryMap.Set(hex, matches) + return matches } diff --git a/aircraft_test.go b/aircraft_test.go index 14324cf..c108826 100644 --- a/aircraft_test.go +++ b/aircraft_test.go @@ -27,25 +27,26 @@ func TestGetAirlineLabel_MatchAndNoMatch(t *testing.T) { // Ensure rolling maps are initialized with sane size flightAirLineMap = NewRollingAirLineMap(10) flightAirLineLabelMap = NewRollingAirLineLabelMap(10) + flightIcaoCountryMap = NewRollingAirLineCountryMap(10) // Matching prefix - if lbl := getAirlineLabel("TST1234"); lbl == nil { + if lbl := getAirlineLabel("TST1234", ""); lbl == nil { t.Fatalf("expected label for matching ICAO prefix") } else if got := *lbl; got == "" { t.Fatalf("expected non-empty label") } // No match - if lbl := getAirlineLabel("ABC1234"); lbl != nil { + if lbl := getAirlineLabel("ABC1234", ""); lbl != nil { t.Fatalf("expected nil for non-matching prefix, got %v", *lbl) } // Empty flight code - if lbl := getAirlineLabel(""); lbl != nil { + if lbl := getAirlineLabel("", ""); lbl != nil { t.Fatalf("expected nil for empty flight code") } - label := getAirlineLabel("DMIRO") + label := getAirlineLabel("ABCDE", "") if label != nil { t.Fatalf("Expected no airline match on 5-letter code, got %v", *label) } diff --git a/airlinedata_test.go b/airlinedata_test.go new file mode 100644 index 0000000..01739f6 --- /dev/null +++ b/airlinedata_test.go @@ -0,0 +1,210 @@ +// dump1090prom +// Copyright (C) 2025 emschu[aet]mailbox.org +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public +// License along with this program. +// If not, see . + +package main + +import ( + "log" + "maps" + "os" + "slices" + "testing" +) + +func TestReadCountryData(t *testing.T) { + content, err := os.ReadFile("data/countries.csv") + if err != nil { + t.Fatalf("failed to read data/countries.csv: %v", err) + } + + countries, err := readCountryData(string(content)) + if err != nil { + t.Fatalf("readCountryData failed: %v", err) + } + + if len(countries) == 0 { + t.Error("expected at least one country, got zero") + } + + // Verify the first entry (Afghanistan) + if len(countries) > 0 { + first := countries[0] + if first.Country != "Afghanistan" { + t.Errorf("expected Afghanistan, got %s", first.Country) + } + if !slices.Contains(first.CountryHexPrefixes, "700") { + t.Errorf("expected 700 to be in %v", first.CountryHexPrefixes) + } + } +} + +func TestGetAirlineCountry(t *testing.T) { + // Setup icaoCountries if not already populated (it should be via main's init or read in tests) + if len(icaoCountries) == 0 { + var err error + icaoCountries, err = readCountryData(countriesCsvFileContent) + if err != nil { + t.Fatalf("failed to read country data: %v", err) + } + } + initRollingMaps() + + tests := []struct { + icao string + expected []string // names of matching countries + }{ + {"0a0123", []string{"Algeria"}}, + {"a00001", []string{"United States"}}, + {"afffff", []string{"United States"}}, + {"FFFFFF", nil}, + {"", nil}, + } + + for _, tt := range tests { + got := getIcaoCountries(tt.icao) + if tt.expected == nil { + if got != nil { + t.Errorf("getAirlineCountry(%s) = %v; want nil", tt.icao, got) + } + } else { + if got == nil { + t.Errorf("getAirlineCountry(%s) = nil; want %v", tt.icao, tt.expected) + continue + } + var gotNames []string + for _, c := range got { + gotNames = append(gotNames, c.Country) + } + for _, wantName := range tt.expected { + if !slices.Contains(gotNames, wantName) { + t.Errorf("getAirlineCountry(%s) = %v; want to contain %s", tt.icao, gotNames, wantName) + } + } + } + } +} + +func TestCountriesDoNotOverlap(t *testing.T) { + countries, err := readCountryData(countriesCsvFileContent) + if err != nil { + t.Fatalf("readCountryData failed: %v", err) + } + + for i, c1 := range countries { + for j, c2 := range countries { + if i == j { + continue + } + // Check if ranges overlap + if c1.HexRangeStart <= c2.HexRangeEnd && c2.HexRangeStart <= c1.HexRangeEnd { + log.Fatalf("Countries %s and %s overlap", c1.Country, c2.Country) + } + } + } +} + +func TestAirLineDataCountries(t *testing.T) { + countries, err := readCountryData(countriesCsvFileContent) + if err != nil { + t.Fatalf("readCountryData failed: %v", err) + } + + airlines, err := readAirlinesData(wikipediaAirlinesCsvFileContent) + if err != nil { + t.Fatalf("readAirlinesData failed: %v", err) + } + + validCountries := make(map[string]bool) + for _, country := range countries { + var countryKey = country.Country + validCountries[countryKey] = true + } + for v, _ := range airlineCountryMapping { + validCountries[v] = true + } + + // data is missing atm + knownLabelsToSkip := []string{ + "Aruba", + "Bermuda", + "British Virgin Islands", + "Cayman Islands", + "Faroe Islands", + "French Guiana", + "French Polynesia", + "Hong Kong SAR of China", + "Jersey", + "Macao", + "Montenegro", + "Montserrat", + "Netherlands Antilles", + "North Macedonia", + "Saint Kitts and Nevis", + "Turks and Caicos Islands", + "Norway, Sweden and San Diego", + "Sweden, Denmark and Norway", + } + + missingCountries := make(map[string]bool) + for _, airline := range airlines { + if len(airline.Country) > 0 && !validCountries[airline.Country] && !slices.Contains(knownLabelsToSkip, airline.Country) { + missingCountries[airline.Country] = true + } + } + + if len(missingCountries) > 0 { + t.Errorf("The following countries from wikipedia-airlines.csv are missing in countries.csv:") + if len(missingCountries) == 0 { + return + } + + sorted := slices.Sorted(maps.Keys(missingCountries)) + for _, v := range sorted { + t.Errorf(" - %v", v) + } + } +} + +func TestAirlineMissmatch(t *testing.T) { + initRollingMaps() + var err error + airlines, err = readAirlinesData(wikipediaAirlinesCsvFileContent) + if err != nil { + t.Fatalf("readAirlinesData failed: %v", err) + } + icaoCountries, err = readCountryData(countriesCsvFileContent) + if err != nil { + t.Fatalf("readCountryData failed: %v", err) + } + + falsePositiveFlights := []string{ + "DEA99", + "DMD99", + "DKG99", + "DCO99", + "DEL99", + "DFA99", + "DGO99", + } + + for _, falsePositive := range falsePositiveFlights { + result := getAirlineLabel(falsePositive, "3c123") + if result != nil { + t.Fatalf("expected nil for non-matching airline '%s', got %v", falsePositive, *result) + } + } +} diff --git a/config.go b/config.go index dd875ef..47f0c8c 100644 --- a/config.go +++ b/config.go @@ -29,6 +29,8 @@ type dump1090MetricCollectorConfig struct { ReceiverPositionLon *float64 IsVerbose bool RollingMapDefaultSize int + Collector string + GlobalLabels map[string]string } func newDump1090MetricCollectorConfig(source MetricSource) *dump1090MetricCollectorConfig { @@ -43,5 +45,7 @@ func newDump1090MetricCollectorConfig(source MetricSource) *dump1090MetricCollec ReceiverPositionLon: nil, IsVerbose: false, RollingMapDefaultSize: 1000, + Collector: "dump1090prom", + GlobalLabels: make(map[string]string), } } diff --git a/dashboards/dump1090prom-grafana-dashboard.json b/dashboards/dump1090prom-grafana-dashboard.json index 32f9a0a..e0eb8dd 100644 --- a/dashboards/dump1090prom-grafana-dashboard.json +++ b/dashboards/dump1090prom-grafana-dashboard.json @@ -1,65 +1,4 @@ { - "__inputs": [ - { - "name": "DS_PROMETHEUS", - "label": "prometheus", - "description": "", - "type": "datasource", - "pluginId": "prometheus", - "pluginName": "Prometheus" - } - ], - "__elements": {}, - "__requires": [ - { - "type": "panel", - "id": "gauge", - "name": "Gauge", - "version": "" - }, - { - "type": "grafana", - "id": "grafana", - "name": "Grafana", - "version": "12.0.2" - }, - { - "type": "panel", - "id": "piechart", - "name": "Pie chart", - "version": "" - }, - { - "type": "datasource", - "id": "prometheus", - "name": "Prometheus", - "version": "1.0.0" - }, - { - "type": "panel", - "id": "stat", - "name": "Stat", - "version": "" - }, - { - "type": "panel", - "id": "state-timeline", - "name": "State timeline", - "version": "" - }, - { - "type": "panel", - "id": "table", - "name": "Table", - "version": "" - }, - { - "type": "panel", - "id": "timeseries", - "name": "Time series", - "version": "" - } - ], "annotations": { "list": [ { @@ -80,12 +19,11 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, - "id": null, + "id": 1, "links": [], "panels": [ { "datasource": { - "type": "prometheus", "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { @@ -114,7 +52,20 @@ ] } }, - "overrides": [] + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "hex" + }, + "properties": [ + { + "id": "custom.width", + "value": 141 + } + ] + } + ] }, "gridPos": { "h": 11, @@ -135,25 +86,26 @@ "show": false }, "showHeader": true, - "sortBy": [] + "sortBy": [ + { + "desc": false, + "displayName": "flight" + } + ] }, "pluginVersion": "12.0.2", "targets": [ { "disableTextWrap": false, "editorMode": "builder", - "expr": "count by (hex, flight, category, direction, squawk, airline) (dump1090prom_aircraft_flight_info)", + "expr": "count by(hex, flight, category, direction, squawk, airline, country) (dump1090prom_aircraft_flight_info)", "format": "table", "fullMetaSearch": false, "includeNullMetadata": true, "legendFormat": "__auto", "range": true, "refId": "A", - "useBackend": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - } + "useBackend": false } ], "title": "Aircraft Record List", @@ -186,6 +138,12 @@ ], "operation": "aggregate" }, + "country": { + "aggregations": [ + "lastNotNull" + ], + "operation": "aggregate" + }, "direction": { "aggregations": [ "uniqueValues" @@ -231,7 +189,13 @@ "squawk (uniqueValues)": 3 }, "renameByName": { - "hex": "" + "airline (lastNotNull)": "airline", + "category (uniqueValues)": "category", + "country (lastNotNull)": "country", + "direction (uniqueValues)": "direction", + "flight (lastNotNull)": "flight", + "hex": "", + "squawk (uniqueValues)": "squawk" } } } @@ -240,7 +204,6 @@ }, { "datasource": { - "type": "prometheus", "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { @@ -299,11 +262,7 @@ "legendFormat": "{{hex}} {{flight}}", "range": true, "refId": "A", - "useBackend": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - } + "useBackend": false } ], "title": "Aircraft Count", @@ -446,11 +405,7 @@ "legendFormat": "{{category}}", "range": true, "refId": "A", - "useBackend": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - } + "useBackend": false }, { "datasource": { @@ -608,8 +563,8 @@ "options": { "legend": { "calcs": [ - "max", - "min" + "min", + "max" ], "displayMode": "table", "placement": "right", @@ -638,11 +593,7 @@ "legendFormat": "{{hex}}", "range": true, "refId": "A", - "useBackend": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - } + "useBackend": false } ], "title": "Aircraft Distance Panel", @@ -710,11 +661,7 @@ "legendFormat": "__auto", "range": true, "refId": "A", - "useBackend": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - } + "useBackend": false }, { "datasource": { @@ -930,11 +877,7 @@ "legendFormat": "__auto", "range": true, "refId": "A", - "useBackend": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - } + "useBackend": false } ], "title": "Squawks", @@ -1017,89 +960,96 @@ "fieldConfig": { "defaults": { "color": { - "mode": "fixed" + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } }, - "fieldMinMax": true, "mappings": [], - "noValue": "-", "thresholds": { "mode": "absolute", "steps": [ { "color": "green" + }, + { + "color": "red", + "value": 80 } ] - }, - "unit": "degree" + } }, "overrides": [] }, "gridPos": { - "h": 9, - "w": 24, + "h": 8, + "w": 12, "x": 0, "y": 28 }, - "id": 12, + "id": 14, "options": { - "minVizHeight": 75, - "minVizWidth": 75, - "orientation": "auto", - "reduceOptions": { + "legend": { "calcs": [ - "lastNotNull" + "min", + "max" ], - "fields": "", - "limit": 500, - "values": true + "displayMode": "table", + "placement": "right", + "showLegend": true }, - "showThresholdLabels": false, - "showThresholdMarkers": true, - "sizing": "auto" + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } }, "pluginVersion": "12.0.2", "targets": [ { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, "disableTextWrap": false, - "editorMode": "code", - "exemplar": false, - "expr": "sum by(hex) (dump1090prom_aircraft_track_degrees)", + "editorMode": "builder", + "expr": "dump1090prom_aircraft_mach_number", "fullMetaSearch": false, - "hide": false, "includeNullMetadata": true, - "instant": false, "legendFormat": "{{hex}}", "range": true, "refId": "A", "useBackend": false } ], - "title": "Aircraft Track in Degree", - "transformations": [ - { - "id": "labelsToFields", - "options": { - "valueLabel": "hex" - } - }, - { - "id": "reduce", - "options": { - "reducers": [ - "lastNotNull" - ] - } - }, - { - "id": "sortBy", - "options": {} - } - ], - "type": "gauge" + "title": "Aircraft Mach Number", + "type": "timeseries" }, { "datasource": { @@ -1109,246 +1059,90 @@ "fieldConfig": { "defaults": { "color": { - "mode": "fixed" + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } }, - "fieldMinMax": true, "mappings": [], - "noValue": "-", "thresholds": { "mode": "absolute", "steps": [ { "color": "green" + }, + { + "color": "red", + "value": 80 } ] }, - "unit": "none" + "unit": "velocityknot" }, "overrides": [] }, "gridPos": { - "h": 9, - "w": 24, - "x": 0, - "y": 37 + "h": 8, + "w": 12, + "x": 12, + "y": 28 }, - "id": 26, + "id": 8, "options": { - "minVizHeight": 75, - "minVizWidth": 75, - "orientation": "auto", - "reduceOptions": { + "legend": { "calcs": [ - "lastNotNull" + "min", + "max" ], - "fields": "", - "limit": 500, - "values": true + "displayMode": "table", + "placement": "right", + "showLegend": true }, - "showThresholdLabels": false, - "showThresholdMarkers": true, - "sizing": "auto" + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } }, "pluginVersion": "12.0.2", "targets": [ { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "disableTextWrap": false, - "editorMode": "code", - "exemplar": false, - "expr": "sum by(hex) (dump1090prom_aircraft_track_degrees)", - "fullMetaSearch": false, - "hide": false, - "includeNullMetadata": true, - "instant": false, - "legendFormat": "{{hex}}", - "range": true, - "refId": "A", - "useBackend": false - } - ], - "title": "Aircraft Track Std Deviation", - "transformations": [ - { - "id": "labelsToFields", - "options": { - "valueLabel": "hex" - } - }, - { - "id": "reduce", - "options": { - "reducers": [ - "stdDev" - ] - } - }, - { - "id": "sortBy", - "options": {} - } - ], - "type": "gauge" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "fixed" - }, - "fieldMinMax": true, - "mappings": [], - "noValue": "-", - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - } - ] - }, - "unit": "degree" - }, - "overrides": [] - }, - "gridPos": { - "h": 9, - "w": 24, - "x": 0, - "y": 46 - }, - "id": 25, - "options": { - "minVizHeight": 75, - "minVizWidth": 75, - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "limit": 500, - "values": true - }, - "showThresholdLabels": false, - "showThresholdMarkers": false, - "sizing": "auto" - }, - "pluginVersion": "12.0.2", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "disableTextWrap": false, - "editorMode": "code", - "exemplar": false, - "expr": "sum by(hex) (dump1090prom_aircraft_nav_heading_degrees)", - "format": "time_series", - "fullMetaSearch": false, - "hide": false, - "includeNullMetadata": true, - "instant": false, - "legendFormat": "{{hex}}", - "range": true, - "refId": "A", - "useBackend": false - } - ], - "title": "Aircraft Heading in Degree", - "transformations": [ - { - "id": "labelsToFields", - "options": { - "valueLabel": "hex" - } - }, - { - "id": "reduce", - "options": { - "reducers": [ - "lastNotNull" - ] - } - }, - { - "id": "sortBy", - "options": {} - } - ], - "type": "gauge" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "fixed" - }, - "fieldMinMax": true, - "mappings": [], - "noValue": "-", - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - } - ] - }, - "unit": "degree" - }, - "overrides": [] - }, - "gridPos": { - "h": 9, - "w": 24, - "x": 0, - "y": 55 - }, - "id": 30, - "options": { - "minVizHeight": 75, - "minVizWidth": 75, - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "limit": 500, - "values": true - }, - "showThresholdLabels": false, - "showThresholdMarkers": false, - "sizing": "auto" - }, - "pluginVersion": "12.0.2", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, "disableTextWrap": false, - "editorMode": "code", + "editorMode": "builder", "exemplar": false, - "expr": "sum by(hex) (dump1090prom_aircraft_magnetic_heading_degrees)", - "format": "time_series", + "expr": "sum by(hex, flight) (dump1090prom_aircraft_ground_speed_knots)", "fullMetaSearch": false, - "hide": false, - "includeNullMetadata": true, + "includeNullMetadata": false, "instant": false, "legendFormat": "{{hex}}", "range": true, @@ -1356,28 +1150,8 @@ "useBackend": false } ], - "title": "Aircraft Heading Magnetic in Degree", - "transformations": [ - { - "id": "labelsToFields", - "options": { - "valueLabel": "hex" - } - }, - { - "id": "reduce", - "options": { - "reducers": [ - "lastNotNull" - ] - } - }, - { - "id": "sortBy", - "options": {} - } - ], - "type": "gauge" + "title": "Aircraft Ground Speed in Knots", + "type": "timeseries" }, { "datasource": { @@ -1422,19 +1196,17 @@ "mode": "off" } }, + "fieldMinMax": true, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green" - }, - { - "color": "red", - "value": 80 } ] - } + }, + "unit": "celsius" }, "overrides": [] }, @@ -1442,14 +1214,17 @@ "h": 8, "w": 12, "x": 0, - "y": 64 + "y": 36 }, - "id": 14, + "id": 31, "options": { "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", + "calcs": [ + "min", + "max" + ], + "displayMode": "table", + "placement": "right", "showLegend": true }, "tooltip": { @@ -1463,20 +1238,16 @@ { "disableTextWrap": false, "editorMode": "builder", - "expr": "dump1090prom_aircraft_mach_number", + "expr": "dump1090prom_aircraft_tat", "fullMetaSearch": false, "includeNullMetadata": true, "legendFormat": "{{hex}}", "range": true, "refId": "A", - "useBackend": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - } + "useBackend": false } ], - "title": "Aircraft Mach Number", + "title": "Aircraft Total Air Temperature (TAT)", "type": "timeseries" }, { @@ -1499,7 +1270,7 @@ "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, - "gradientMode": "none", + "gradientMode": "opacity", "hideFrom": { "legend": false, "tooltip": false, @@ -1508,7 +1279,7 @@ "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 1, - "pointSize": 5, + "pointSize": 6, "scaleDistribution": { "type": "linear" }, @@ -1522,6 +1293,7 @@ "mode": "off" } }, + "fieldMinMax": true, "mappings": [], "thresholds": { "mode": "absolute", @@ -1535,7 +1307,7 @@ } ] }, - "unit": "velocityknot" + "unit": "rotdegs" }, "overrides": [] }, @@ -1543,43 +1315,42 @@ "h": 8, "w": 12, "x": 12, - "y": 64 + "y": 36 }, - "id": 8, + "id": 27, "options": { "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", - "showLegend": true - }, - "tooltip": { - "hideZeros": false, - "mode": "single", + "calcs": [ + "min", + "max" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", "sort": "none" } }, "pluginVersion": "12.0.2", "targets": [ { - "disableTextWrap": false, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, "editorMode": "builder", - "exemplar": false, - "expr": "sum by(hex, flight) (dump1090prom_aircraft_ground_speed_knots)", - "fullMetaSearch": false, - "includeNullMetadata": false, + "expr": "sum(dump1090prom_aircraft_track_rate_degrees_per_second) by (hex)", + "hide": false, "instant": false, "legendFormat": "{{hex}}", "range": true, - "refId": "A", - "useBackend": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - } + "refId": "B" } ], - "title": "Aircraft Ground Speed in Knots", + "title": "Rotational Speed (Degree/second)", "type": "timeseries" }, { @@ -1613,7 +1384,7 @@ "h": 5, "w": 3, "x": 0, - "y": 72 + "y": 44 }, "id": 24, "options": { @@ -1644,11 +1415,7 @@ "legendFormat": "__auto", "range": true, "refId": "A", - "useBackend": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - } + "useBackend": false } ], "title": "Bundespolizei", @@ -1674,7 +1441,7 @@ "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 0, - "gradientMode": "opacity", + "gradientMode": "none", "hideFrom": { "legend": false, "tooltip": false, @@ -1683,7 +1450,7 @@ "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 1, - "pointSize": 6, + "pointSize": 5, "scaleDistribution": { "type": "linear" }, @@ -1697,7 +1464,6 @@ "mode": "off" } }, - "fieldMinMax": true, "mappings": [], "thresholds": { "mode": "absolute", @@ -1711,7 +1477,7 @@ } ] }, - "unit": "rotdegs" + "unit": "lengthft" }, "overrides": [] }, @@ -1719,13 +1485,16 @@ "h": 8, "w": 12, "x": 12, - "y": 72 + "y": 44 }, - "id": 27, + "id": 5, "options": { "legend": { - "calcs": [], - "displayMode": "list", + "calcs": [ + "min", + "max" + ], + "displayMode": "table", "placement": "right", "showLegend": true }, @@ -1738,25 +1507,22 @@ "pluginVersion": "12.0.2", "targets": [ { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, + "disableTextWrap": false, "editorMode": "builder", - "expr": "sum(dump1090prom_aircraft_track_rate_degrees_per_second) by (hex)", - "hide": false, - "instant": false, + "expr": "dump1090prom_aircraft_barometric_vertical_rate_feet_per_minute", + "fullMetaSearch": false, + "includeNullMetadata": true, "legendFormat": "{{hex}}", "range": true, - "refId": "B" + "refId": "A", + "useBackend": false } ], - "title": "Rotational Speed (Degree/second)", + "title": "Aircraft Vertical Rate Feet per Minute", "type": "timeseries" }, { "datasource": { - "type": "prometheus", "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { @@ -1818,14 +1584,17 @@ "h": 8, "w": 12, "x": 0, - "y": 77 + "y": 49 }, "id": 18, "options": { "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", + "calcs": [ + "min", + "max" + ], + "displayMode": "table", + "placement": "right", "showLegend": true }, "tooltip": { @@ -1845,11 +1614,7 @@ "legendFormat": "{{hex}}", "range": true, "refId": "A", - "useBackend": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - } + "useBackend": false } ], "title": "Aircraft Indicated Air Speed in knots", @@ -1919,14 +1684,17 @@ "h": 8, "w": 12, "x": 12, - "y": 80 + "y": 52 }, - "id": 5, + "id": 4, "options": { "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", + "calcs": [ + "min", + "max" + ], + "displayMode": "table", + "placement": "right", "showLegend": true }, "tooltip": { @@ -1940,20 +1708,16 @@ { "disableTextWrap": false, "editorMode": "builder", - "expr": "dump1090prom_aircraft_barometric_vertical_rate_feet_per_minute", + "expr": "dump1090prom_aircraft_altitude_geom_feet", "fullMetaSearch": false, "includeNullMetadata": true, "legendFormat": "{{hex}}", "range": true, "refId": "A", - "useBackend": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - } + "useBackend": false } ], - "title": "Aircraft Vertical Rate Feet per Minute", + "title": "Aircraft Geom Height Feet", "type": "timeseries" }, { @@ -2023,7 +1787,7 @@ "h": 8, "w": 12, "x": 0, - "y": 85 + "y": 57 }, "id": 17, "options": { @@ -2032,7 +1796,7 @@ "min", "max" ], - "displayMode": "list", + "displayMode": "table", "placement": "right", "showLegend": true }, @@ -2056,11 +1820,7 @@ "legendFormat": "{{hex}}", "range": true, "refId": "A", - "useBackend": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - } + "useBackend": false } ], "title": "Aircraft RSSI dBm", @@ -2116,6 +1876,7 @@ "mode": "off" } }, + "fieldMinMax": false, "mappings": [], "thresholds": { "mode": "absolute", @@ -2137,14 +1898,17 @@ "h": 8, "w": 12, "x": 12, - "y": 88 + "y": 60 }, - "id": 4, + "id": 3, "options": { "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", + "calcs": [ + "min", + "max" + ], + "displayMode": "table", + "placement": "right", "showLegend": true }, "tooltip": { @@ -2158,25 +1922,20 @@ { "disableTextWrap": false, "editorMode": "builder", - "expr": "dump1090prom_aircraft_altitude_geom_feet", + "expr": "dump1090prom_aircraft_altitude_baro_feet", "fullMetaSearch": false, "includeNullMetadata": true, "legendFormat": "{{hex}}", "range": true, "refId": "A", - "useBackend": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - } + "useBackend": false } ], - "title": "Aircraft Geom Height Feet", + "title": "Aircraft Baro Height Feet", "type": "timeseries" }, { "datasource": { - "type": "prometheus", "uid": "${DS_PROMETHEUS}" }, "fieldConfig": { @@ -2212,7 +1971,7 @@ "h": 8, "w": 12, "x": 0, - "y": 93 + "y": 65 }, "id": 7, "options": { @@ -2245,11 +2004,7 @@ "legendFormat": "{{hex}}", "range": true, "refId": "A", - "useBackend": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - } + "useBackend": false } ], "title": "Aircraft Flight Info", @@ -2298,7 +2053,6 @@ "mode": "off" } }, - "fieldMinMax": false, "mappings": [], "thresholds": { "mode": "absolute", @@ -2312,7 +2066,7 @@ } ] }, - "unit": "lengthft" + "unit": "s" }, "overrides": [] }, @@ -2320,14 +2074,17 @@ "h": 8, "w": 12, "x": 12, - "y": 96 + "y": 68 }, - "id": 3, + "id": 6, "options": { "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", + "calcs": [ + "min", + "max" + ], + "displayMode": "table", + "placement": "right", "showLegend": true }, "tooltip": { @@ -2341,20 +2098,16 @@ { "disableTextWrap": false, "editorMode": "builder", - "expr": "dump1090prom_aircraft_altitude_baro_feet", + "expr": "dump1090prom_aircraft_seen_seconds", "fullMetaSearch": false, "includeNullMetadata": true, "legendFormat": "{{hex}}", "range": true, "refId": "A", - "useBackend": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - } + "useBackend": false } ], - "title": "Aircraft Baro Height Feet", + "title": "Aircraft Seen Seconds", "type": "timeseries" }, { @@ -2421,7 +2174,7 @@ "h": 8, "w": 12, "x": 0, - "y": 101 + "y": 73 }, "id": 15, "options": { @@ -2448,11 +2201,7 @@ "legendFormat": "{{hex}}", "range": true, "refId": "A", - "useBackend": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - } + "useBackend": false } ], "title": "Aircraft Mode A", @@ -2472,11 +2221,12 @@ "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", + "axisGridShow": false, "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, "barWidthFactor": 0.6, - "drawStyle": "line", + "drawStyle": "bars", "fillOpacity": 0, "gradientMode": "none", "hideFrom": { @@ -2491,11 +2241,11 @@ "scaleDistribution": { "type": "linear" }, - "showPoints": "auto", + "showPoints": "never", "spanNulls": false, "stacking": { "group": "A", - "mode": "none" + "mode": "normal" }, "thresholdsStyle": { "mode": "off" @@ -2513,23 +2263,22 @@ "value": 80 } ] - }, - "unit": "s" + } }, "overrides": [] }, "gridPos": { "h": 8, "w": 12, - "x": 12, - "y": 104 + "x": 0, + "y": 81 }, - "id": 6, + "id": 16, "options": { "legend": { "calcs": [], - "displayMode": "list", - "placement": "bottom", + "displayMode": "table", + "placement": "right", "showLegend": true }, "tooltip": { @@ -2543,20 +2292,16 @@ { "disableTextWrap": false, "editorMode": "builder", - "expr": "dump1090prom_aircraft_seen_seconds", + "expr": "dump1090prom_aircraft_mode_c", "fullMetaSearch": false, "includeNullMetadata": true, "legendFormat": "{{hex}}", "range": true, "refId": "A", - "useBackend": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - } + "useBackend": false } ], - "title": "Aircraft Seen Seconds", + "title": "Aircraft Mode C", "type": "timeseries" }, { @@ -2567,100 +2312,370 @@ "fieldConfig": { "defaults": { "color": { - "mode": "palette-classic" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisGridShow": false, - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "bars", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } + "mode": "fixed" }, + "fieldMinMax": true, "mappings": [], + "noValue": "-", "thresholds": { "mode": "absolute", "steps": [ { "color": "green" - }, - { - "color": "red", - "value": 80 } ] - } + }, + "unit": "degree" }, "overrides": [] }, "gridPos": { - "h": 8, - "w": 12, + "h": 9, + "w": 24, "x": 0, - "y": 109 + "y": 89 }, - "id": 16, + "id": 12, "options": { - "legend": { - "calcs": [], - "displayMode": "table", - "placement": "right", - "showLegend": true + "minVizHeight": 75, + "minVizWidth": 75, + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "limit": 100, + "values": true }, - "tooltip": { - "hideZeros": false, - "mode": "single", - "sort": "none" + "showThresholdLabels": false, + "showThresholdMarkers": true, + "sizing": "auto" + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "code", + "exemplar": false, + "expr": "sum by(hex) (dump1090prom_aircraft_track_degrees)", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{hex}}", + "range": true, + "refId": "A", + "useBackend": false } + ], + "title": "Aircraft Track in Degree", + "transformations": [ + { + "id": "labelsToFields", + "options": { + "valueLabel": "hex" + } + }, + { + "id": "reduce", + "options": { + "reducers": [ + "lastNotNull" + ] + } + }, + { + "id": "sortBy", + "options": {} + } + ], + "type": "gauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "fixed" + }, + "fieldMinMax": true, + "mappings": [], + "noValue": "-", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "degree" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 98 + }, + "id": 30, + "options": { + "minVizHeight": 75, + "minVizWidth": 75, + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "limit": 100, + "values": true + }, + "showThresholdLabels": false, + "showThresholdMarkers": false, + "sizing": "auto" }, "pluginVersion": "12.0.2", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, "disableTextWrap": false, - "editorMode": "builder", - "expr": "dump1090prom_aircraft_mode_c", + "editorMode": "code", + "exemplar": false, + "expr": "sum by(hex) (dump1090prom_aircraft_magnetic_heading_degrees)", + "format": "time_series", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{hex}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Aircraft Heading Magnetic in Degree", + "transformations": [ + { + "id": "labelsToFields", + "options": { + "valueLabel": "hex" + } + }, + { + "id": "reduce", + "options": { + "reducers": [ + "lastNotNull" + ] + } + }, + { + "id": "sortBy", + "options": {} + } + ], + "type": "gauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "fixed" + }, + "fieldMinMax": true, + "mappings": [], + "noValue": "-", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "degree" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 107 + }, + "id": 25, + "options": { + "minVizHeight": 75, + "minVizWidth": 75, + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "limit": 100, + "values": true + }, + "showThresholdLabels": false, + "showThresholdMarkers": false, + "sizing": "auto" + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "code", + "exemplar": false, + "expr": "sum by(hex) (dump1090prom_aircraft_nav_heading_degrees)", + "format": "time_series", "fullMetaSearch": false, + "hide": false, "includeNullMetadata": true, + "instant": false, "legendFormat": "{{hex}}", "range": true, "refId": "A", - "useBackend": false, + "useBackend": false + } + ], + "title": "Aircraft Heading in Degree", + "transformations": [ + { + "id": "labelsToFields", + "options": { + "valueLabel": "hex" + } + }, + { + "id": "reduce", + "options": { + "reducers": [ + "lastNotNull" + ] + } + }, + { + "id": "sortBy", + "options": {} + } + ], + "type": "gauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "fixed" + }, + "fieldMinMax": true, + "mappings": [], + "noValue": "-", + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "none" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 116 + }, + "id": 26, + "options": { + "minVizHeight": 75, + "minVizWidth": 75, + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "limit": 100, + "values": true + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "sizing": "auto" + }, + "pluginVersion": "12.0.2", + "targets": [ + { "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "code", + "exemplar": false, + "expr": "sum by(hex) (dump1090prom_aircraft_track_degrees)", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{hex}}", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Aircraft Track Std Deviation", + "transformations": [ + { + "id": "labelsToFields", + "options": { + "valueLabel": "hex" } + }, + { + "id": "reduce", + "options": { + "reducers": [ + "stdDev" + ] + } + }, + { + "id": "sortBy", + "options": {} } ], - "title": "Aircraft Mode C", - "type": "timeseries" + "type": "gauge" } ], + "preload": false, "refresh": "5s", "schemaVersion": 41, "tags": [ @@ -2674,11 +2689,33 @@ { "baseFilters": [], "datasource": { - "uid": "aesf5t232znk0b" + "uid": "${DS_PROMETHEUS}" }, "filters": [], "name": "Filters", "type": "adhoc" + }, + { + "description": "", + "name": "DS_PROMETHEUS", + "options": [], + "query": "prometheus", + "refresh": 1, + "regex": "", + "type": "datasource" + }, + { + "definition": "label_values(dump1090prom_aircraft_adsb_version,collector)", + "name": "collector", + "options": [], + "query": { + "qryType": 1, + "query": "label_values(dump1090prom_aircraft_adsb_version,collector)", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 1, + "regex": "", + "type": "query" } ] }, @@ -2689,7 +2726,6 @@ "timepicker": {}, "timezone": "browser", "title": "Aircraft Dashboard Dump1090", - "uid": "9dac4837-b94d-48d0-a036-0e2876e084fb", - "version": 80, + "version": 5, "weekStart": "monday" } \ No newline at end of file diff --git a/data/countries.csv b/data/countries.csv new file mode 100644 index 0000000..325f87c --- /dev/null +++ b/data/countries.csv @@ -0,0 +1,189 @@ +country;country hex prefixes;country icao code;hex range start;hex range end;possible registry items +Afghanistan;700;YA;700000;700FFF;4096 +Albania;5010,5011,5012,5013;ZA;501000;5013FF;1024 +Algeria;0A0,0A1,0A2,0A3,0A4,0A5,0A6,0A7;7T;0A0000;0A7FFF;32768 +Angola;090;D2;090000;090FFF;4096 +Antigua and Barbuda;0CA0,0CA1,0CA2,0CA3;V2;0CA000;0CA3FF;1024 +Argentina;E0,E1,E2,E3;LQ;E00000;E3FFFF;262144 +Armenia;6000,6001,6002,6003;EK;600000;6003FF;1024 +Australia;7C,7D,7E,7F;VH;7C0000;7FFFFF;262144 +Austria;440,441,442,443,444,445,446,447;OE;440000;447FFF;32768 +Azerbaijan;6008,6009,600A,600B;4K;600800;600BFF;1024 +Bahamas;0A8;C6;0A8000;0A8FFF;4096 +Bahrain;894;A9C;894000;894FFF;4096 +Bangladesh;702;S2;702000;702FFF;4096 +Barbados;0AA0,0AA1,0AA2,0AA3;8P;0AA000;0AA3FF;1024 +Belarus;5100,5101,5102,5103;EW;510000;5103FF;1024 +Belgium;448,449,44A,44B,44C,44D,44E,44F;OO;448000;44FFFF;32768 +Belize;0AB0,0AB1,0AB2,0AB3;V3;0AB000;0AB3FF;1024 +Benin;0940,0941,0942,0943;TY;094000;0943FF;1024 +Bhutan;6800,6801,6802,6803;A5;680000;6803FF;1024 +Bolivia;E94;CP;E94000;E94FFF;4096 +Bosnia and Herzegovina;5130,5131,5132,5133;E7;513000;5133FF;1024 +Botswana;0300,0301,0302,0303;A2;030000;0303FF;1024 +Brazil;E4,E5,E6,E7;PS;E40000;E7FFFF;262144 +Brunei Darussalam;8950,8951,8952,8953;V8;895000;8953FF;1024 +Bulgaria;450,451,452,453,454,455,456,457;LZ;450000;457FFF;32768 +Burkina Faso;09C;XT;09C000;09CFFF;4096 +Burundi;032;9U;032000;032FFF;4096 +Cambodia;70E;XU;70E000;70EFFF;4096 +Cameroon;034;TJ;034000;034FFF;4096 +Canada;C0,C1,C2,C3;C;C00000;C3FFFF;262144 +Cape Verde;0960,0961,0962,0963;D4;096000;0963FF;1024 +Central African Republic;06C;TL;06C000;06CFFF;4096 +Chad;084;TT;084000;084FFF;4096 +Chile;E80;CC;E80000;E80FFF;4096 +China;78,79,7A,7B;B;780000;7BFFFF;262144 +Colombia;0AC;HK;0AC000;0ACFFF;4096 +Comoros;0350,0351,0352,0353;D6;035000;0353FF;1024 +Congo;036;TN;036000;036FFF;4096 +Cook Islands;9010,9011,9012,9013;E5;901000;9013FF;1024 +Costa Rica;0AE;TI;0AE000;0AEFFF;4096 +Croatia;501C,501D,501E,501F;9A;501C00;501FFF;1024 +Cuba;0B0;CU;0B0000;0B0FFF;4096 +Cyprus;4C80,4C81,4C82,4C83;5B;4C8000;4C83FF;1024 +Czech Republic;498,499,49A,49B,49C,49D,49E,49F;OK;498000;49FFFF;32768 +Côte d Ivoire;038;;038000;038FFF;4096 +Democratic People's Republic of Korea;720,721,722,723,724,725,726,727;;720000;727FFF;32768 +Democratic Republic of the Congo;08C;OO-C;08C000;08CFFF;4096 +Denmark;458,459,45A,45B,45C,45D,45E,45F;OY;458000;45FFFF;32768 +Djibouti;0980,0981,0982,0983;J2;098000;0983FF;1024 +Dominican Republic;0C4;HI;0C4000;0C4FFF;4096 +Ecuador;E84;HC;E84000;E84FFF;4096 +Egypt;010,011,012,013,014,015,016,017;SU;010000;017FFF;32768 +El Salvador;0B2;YS;0B2000;0B2FFF;4096 +Equatorial Guinea;042;3C;042000;042FFF;4096 +Eritrea;2020,2021,2022,2023;E3;202000;2023FF;1024 +Estonia;5110,5111,5112,5113;ES;511000;5113FF;1024 +Ethiopia;040;ET;040000;040FFF;4096 +Fiji;C88;DQ;C88000;C88FFF;4096 +Finland;460,461,462,463,464,465,466,467;OH;460000;467FFF;32768 +France;38,39,3A,3B;F;380000;3BFFFF;262144 +Gabon;03E;TR;03E000;03EFFF;4096 +Gambia;09A;C5;09A000;09AFFF;4096 +Georgia;5140,5141,5142,5143;4L;514000;5143FF;1024 +Germany;3C,3D,3E,3F;D;3C0000;3FFFFF;262144 +Ghana;044;9GR;044000;044FFF;4096 +Greece;468,469,46A,46B,46C,46D,46E,46F;SX;468000;46FFFF;32768 +Grenada;0CC0,0CC1,0CC2,0CC3;J3;0CC000;0CC3FF;1024 +Guatemala;0B4;TG;0B4000;0B4FFF;4096 +Guinea;046;3X;046000;046FFF;4096 +Guinea-Bissau;0480,0481,0482,0483;J5;048000;0483FF;1024 +Guyana;0B6;8R;0B6000;0B6FFF;4096 +Haiti;0B8;HH;0B8000;0B8FFF;4096 +Honduras;0BA;HR;0BA000;0BAFFF;4096 +Hungary;470,471,472,473,474,475,476,477;HA;470000;477FFF;32768 +ICAO (2);8990,8991,8992,8993;;899000;8993FF;1024 +Iceland;4CC;TF;4CC000;4CCFFF;4096 +India;80,81,82,83;VT;800000;83FFFF;262144 +Indonesia;8A0,8A1,8A2,8A3,8A4,8A5,8A6,8A7;PK;8A0000;8A7FFF;32768 +Iran, Islamic Republic of;730,731,732,733,734,735,736,737;EP;730000;737FFF;32768 +Iraq;728,729,72A,72B,72C,72D,72E,72F;YI;728000;72FFFF;32768 +Ireland;4CA;EI;4CA000;4CAFFF;4096 +Israel;738,739,73A,73B,73C,73D,73E,73F;4Z;738000;73FFFF;32768 +Italy;30,31,32,33;I;300000;33FFFF;262144 +Jamaica;0BE;6Y;0BE000;0BEFFF;4096 +Japan;84,85,86,87;JR;840000;87FFFF;262144 +Jordan;740,741,742,743,744,745,746,747;JY;740000;747FFF;32768 +Kazakhstan;6830,6831,6832,6833;UP;683000;6833FF;1024 +Kenya;04C;5Y;04C000;04CFFF;4096 +Kiribati;C8E0,C8E1,C8E2,C8E3;T3;C8E000;C8E3FF;1024 +Kuwait;706;9K;706000;706FFF;4096 +Kyrgyzstan;6010,6011,6012,6013;EX;601000;6013FF;1024 +Lao People's Democratic Republic;708;;708000;708FFF;4096 +Latvia;502C,502D,502E,502F;LV;502C00;502FFF;1024 +Lebanon;748,749,74A,74B,74C,74D,74E,74F;OD;748000;74FFFF;32768 +Lesotho;04A0,04A1,04A2,04A3;7P;04A000;04A3FF;1024 +Liberia;050;A8;050000;050FFF;4096 +Libyan Arab Jamahiriya;018,019,01A,01B,01C,01D,01E,01F;5A;018000;01FFFF;32768 +Lithuania;503C,503D,503E,503F;LY;503C00;503FFF;1024 +Luxembourg;4D00,4D01,4D02,4D03;LX;4D0000;4D03FF;1024 +Madagascar;054;5R;054000;054FFF;4096 +Malawi;058;7Q;058000;058FFF;4096 +Malaysia;750,751,752,753,754,755,756,757;9M;750000;757FFF;32768 +Maldives;05A0,05A1,05A2,05A3;8Q;05A000;05A3FF;1024 +Mali;05C;TZ;05C000;05CFFF;4096 +Malta;4D2;9H;4D2000;4D2FFF;4096 +Marshall Islands;9000,9001,9002,9003;V7;900000;9003FF;1024 +Mauritania;05E0,05E1,05E2,05E3;5T;05E000;05E3FF;1024 +Mauritius;0600,0601,0602,0603;3B;060000;0603FF;1024 +Mexico;0D0,0D1,0D2,0D3,0D4,0D5,0D6,0D7;XC plus national emblem;0D0000;0D7FFF;32768 +Micronesia, Federated States of;6810,6811,6812,6813;V6;681000;6813FF;1024 +Monaco;4D40,4D41,4D42,4D43;3A-M;4D4000;4D43FF;1024 +Mongolia;6820,6821,6822,6823;JU;682000;6823FF;1024 +Morocco;020,021,022,023,024,025,026,027;CN;020000;027FFF;32768 +Mozambique;006;C9;006000;006FFF;4096 +Myanmar;704;XZ;704000;704FFF;4096 +Namibia;2010,2011,2012,2013;V5;201000;2013FF;1024 +Nauru;C8A0,C8A1,C8A2,C8A3;C2;C8A000;C8A3FF;1024 +Nepal;70A;9N;70A000;70AFFF;4096 +Netherlands, Kingdom of the;480,481,482,483,484,485,486,487;PH;480000;487FFF;32768 +New Zealand;C80,C81,C82,C83,C84,C85,C86,C87;ZM;C80000;C87FFF;32768 +Nicaragua;0C0;YN;0C0000;0C0FFF;4096 +Niger;062;5U;062000;062FFF;4096 +Nigeria;064;5N;064000;064FFF;4096 +Non-Contracting States Yugoslavia;4C0,4C1,4C2,4C3,4C4,4C5,4C6,4C7;UN;4C0000;4C7FFF;32768 +Norway;478,479,47A,47B,47C,47D,47E,47F;LN;478000;47FFFF;32768 +Oman;70C0,70C1,70C2,70C3;A4O;70C000;70C3FF;1024 +Other allocations ICAO (1);F00,F01,F02,F03,F04,F05,F06,F07;;F00000;F07FFF;32768 +Pakistan;760,761,762,763,764,765,766,767;AP;760000;767FFF;32768 +Palau;6840,6841,6842,6843;;684000;6843FF;1024 +Panama;0C2;HP;0C2000;0C2FFF;4096 +Papua New Guinea;898;P2;898000;898FFF;4096 +Paraguay;E88;ZP;E88000;E88FFF;4096 +Peru;E8C;OB;E8C000;E8CFFF;4096 +Philippines;758,759,75A,75B,75C,75D,75E,75F;RP;758000;75FFFF;32768 +Poland;488,489,48A,48B,48C,48D,48E,48F;SN;488000;48FFFF;32768 +Portugal;490,491,492,493,494,495,496,497;CS;490000;497FFF;32768 +Qatar;06A0,06A1,06A2,06A3;A7;06A000;06A3FF;1024 +Republic of Korea;718,719,71A,71B,71C,71D,71E,71F;;718000;71FFFF;32768 +Republic of Moldova;504C,504D,504E,504F;ER;504C00;504FFF;1024 +Romania;4A0,4A1,4A2,4A3,4A4,4A5,4A6,4A7;YR;4A0000;4A7FFF;32768 +Russian Federation;10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F;RF;100000;1FFFFF;1048576 +Rwanda;06E;9XR;06E000;06EFFF;4096 +Saint Lucia;C8C0,C8C1,C8C2,C8C3;J6;C8C000;C8C3FF;1024 +Saint Vincent and the Grenadines;0BC0,0BC1,0BC2,0BC3;J8;0BC000;0BC3FF;1024 +Samoa;9020,9021,9022,9023;5W;902000;9023FF;1024 +San Marino;5000,5001,5002,5003;T7;500000;5003FF;1024 +Sao Tome and Principe;09E0,09E1,09E2,09E3;;09E000;09E3FF;1024 +Saudi Arabia;710,711,712,713,714,715,716,717;HZ;710000;717FFF;32768 +Senegal;070;6W;070000;070FFF;4096 +Seychelles;0740,0741,0742,0743;S7;074000;0743FF;1024 +Sierra Leone;0760,0761,0762,0763;9L;076000;0763FF;1024 +Singapore;768,769,76A,76B,76C,76D,76E,76F;9V;768000;76FFFF;32768 +Slovakia;505C,505D,505E,505F;OM;505C00;505FFF;1024 +Slovenia;506C,506D,506E,506F;S5;506C00;506FFF;1024 +Solomon Islands;8970,8971,8972,8973;H4;897000;8973FF;1024 +Somalia;078;6O;078000;078FFF;4096 +South Africa;008,009,00A,00B,00C,00D,00E,00F;ZU;008000;00FFFF;32768 +Spain;34,35,36,37;EM;340000;37FFFF;262144 +Sri Lanka;770,771,772,773,774,775,776,777;4R;770000;777FFF;32768 +Sudan;07C;ST;07C000;07CFFF;4096 +Suriname;0C8;PZ;0C8000;0C8FFF;4096 +Swaziland;07A0,07A1,07A2,07A3;VQ-ZI;07A000;07A3FF;1024 +Sweden;4A8,4A9,4AA,4AB,4AC,4AD,4AE,4AF;SE;4A8000;4AFFFF;32768 +Switzerland;4B0,4B1,4B2,4B3,4B4,4B5,4B6,4B7;HB plus national emblem;4B0000;4B7FFF;32768 +Syrian Arab Republic;778,779,77A,77B,77C,77D,77E,77F;YK;778000;77FFFF;32768 +Tajikistan;5150,5151,5152,5153;EY;515000;5153FF;1024 +Thailand;880,881,882,883,884,885,886,887;U;880000;887FFF;32768 +The former Yugoslav Republic of Macedonia;5120,5121,5122,5123;;512000;5123FF;1024 +Togo;088;5V;088000;088FFF;4096 +Tonga;C8D0,C8D1,C8D2,C8D3;A3;C8D000;C8D3FF;1024 +Trinidad and Tobago;0C6;9Y;0C6000;0C6FFF;4096 +Tunisia;028,029,02A,02B,02C,02D,02E,02F;TS;028000;02FFFF;32768 +Turkey;4B8,4B9,4BA,4BB,4BC,4BD,4BE,4BF;TC;4B8000;4BFFFF;32768 +Turkmenistan;6018,6019,601A,601B;EZ;601800;601BFF;1024 +Uganda;068;5X;068000;068FFF;4096 +Ukraine;508,509,50A,50B,50C,50D,50E,50F;UR;508000;50FFFF;32768 +United Arab Emirates;896;DU;896000;896FFF;4096 +United Kingdom;40,41,42,43;G;400000;43FFFF;262144 +United Republic of Tanzania;080;5H;080000;080FFF;4096 +United States;A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF;N;A00000;AFFFFF;1048576 +Uruguay;E90;CX;E90000;E90FFF;4096 +Uzbekistan;507C,507D,507E,507F;UK;507C00;507FFF;1024 +Vanuatu;C900,C901,C902,C903;YJ;C90000;C903FF;1024 +Venezuela;0D8,0D9,0DA,0DB,0DC,0DD,0DE,0DF;YV;0D8000;0DFFFF;32768 +Viet Nam;888,889,88A,88B,88C,88D,88E,88F;VN;888000;88FFFF;32768 +Yemen;890;7O;890000;890FFF;4096 +Zambia;08A;9J;08A000;08AFFF;4096 +Zimbabwe;0040,0041,0042,0043;Z;004000;0043FF;1024 diff --git a/data/wikipedia-airlines.csv b/data/wikipedia-airlines.csv index aca602a..ae50ea3 100644 --- a/data/wikipedia-airlines.csv +++ b/data/wikipedia-airlines.csv @@ -805,7 +805,7 @@ EN;DLA;Air Dolomiti;DOLOMITI;Italy; 6R;DRU;Alrosa Air Company;MIRNY;Russia; ;DSK;Aero Algarve;SKYBANNER;Portugal;ICAO code no longer allocated ;DST;Aex Air;DESERT;United States; -;EAT;Air Transport;TRANS EUROPE;Slovakia; +;EAT;Air – Transport Europe;TRANS EUROPE;Slovakia; ;EBC;Aero Ejecutivo De Baja California;CALIXJET;Mexico; 4F;ECE;Air City;AIRCITY;Germany; ;ECG;Aero Ejecutivos RCG;EJECTUIVOS RCG;Mexico; @@ -1020,7 +1020,7 @@ LK;LXR;Air Luxor;AIRLUXOR;Portugal;ICAO code no longer allocated MK;MAU;Air Mauritius;AIRMAURITIUS;Mauritius; ;MBA;Avag Air;AVAG AIR;Austria; ;MBB;Air Manas;AIR MANAS;Kyrgyzstan; -;MBC;Airjet Exploracao Aerea de Carga;MABECO;Angola; +;MBC;Airjet Exploração Aérea de Carga;MABECO;Angola; ;MCB;Air Mercia;WESTMID;United Kingdom; ;MCD;Air Medical;AIR MED;United Kingdom; ;MCO;Aerolíneas Marcos;MARCOS;Mexico; @@ -1796,7 +1796,7 @@ XO;CXH;China Xinhua Airlines;XINHUA;China; X7;CHF;Chitaavia;CHITA;Russia; OQ;CQN;Chongqing Airlines;CHONG QING;China; ;CAS;Christman Air System;CHRISTMAN;United States; -;OEC;Christophorus Flugrettungsverein;CHRISTOPHORUS;Austria; +;OEC;Christophorus Flugrettungsverein [de];CHRISTOPHORUS;Austria; ;CHO;Chrome Air Services;CHROME AIR;United States; ;CHU;Church Aircraft;CHURCHAIR;United States; A2;CIU;Cielos Airlines;CIELOS;Peru; @@ -2235,11 +2235,12 @@ UZ;BRQ;El-Buraq Air Transport;BURAQAIR;Libya; ;EFT;Embassy Freight Company;EMBASSY FREIGHT;United States; ;EMB;Empresa Brasileira De Aeronáutica;EMBRAER;Brazil; ;XSL;Embry-Riddle Aeronautical University;SATSLAB;United States;Sesatlab Proof-of-Concept Flight +;ERU;Embry-Riddle Aeronautical University;RIDDLE;United States; EA;EAI;Emerald Airlines;GEMSTONE;Ireland; ;JEM;Emerald Airways;GEMSTONE;United Kingdom; ;EWW;Emery Worldwide Airlines;EMERY;United States; ;EMT;Emetebe;EMETEBE;Ecuador; -EK;UAE;Emirates Airlines;EMIRATES;United Arab Emirates; +EK;UAE;Emirates;EMIRATES;United Arab Emirates; ;SBC;Emoyeni Air Charter;SABIAN AIR;South Africa;Mount Air ;EMP;Empire Air Service;EMPIRE;United States; EM;CFS;Empire Airlines;EMPIRE AIR;United States; @@ -2258,13 +2259,14 @@ EU;EEA;Empresa Ecuatoriana De Aviación;ECUATORIANA;Ecuador; G8;ENK;Enkor JSC;ENKOR;Russia; ;EGV;Enrique Gleisner Vivanco;GLEISNER;Chile; ;ESE;Ensenada Vuelos Especiales;ENSENADA ESPECIAL;Mexico; -OF;ENT;Enter Air;ENTER;Poland; +E4;ENT;Enter Air;ENTER;Poland; ;ENS;Entergy Services;ENTERGY SHUTTLE;United States; ;EWS;Enterprise World Airways;WORLD ENTERPRISE;Democratic Republic of the Congo; E0;ESS;Eos Airlines;NEW DAWN;United States; ;EKA;Equaflight Service;EQUAFLIGHT;Republic of the Congo; ;EQZ;Equatair Air Services (Zambia);ZAMBIA CARGO;Zambia; ;EQT;Equatorial Airlines;;Equatorial Guinea; +EJ;EQR;Equatorial Congo Airlines;ECAIR;Republic of the Congo;2024 ;ERH;Era Helicopters;ERAH;United States; ;IRY;Eram Air;ERAM AIR;Iran; ;ERF;Erfoto;ERFOTO;Portugal; @@ -2930,6 +2932,7 @@ MR;MML;Hunnu Air;TRANS MONGOLIA;Mongolia; ;SRD;HM Coastguard;COASTGUARD;United Kingdom; ;SRG;HM Coastguard;RESCUE;United Kingdom;Search and Rescue ;WHR;Hummingbird Helicopter Service;WHIRLEYBIRD;United States; +E2;HFA;Air Haifa;AIR HAIFA;Israel; I4;EXP;Island Air Express;ISLAND EXPRESS;United States;2014[28] ;IWL;Island Wings;;Bahamas;2014[28] IK;KAR;Ikar;IKAR;Russian Federation; @@ -3237,6 +3240,7 @@ HO;DKH;Juneyao Airlines;AIR JUNEYAO;China;2023[32] ;JSY;Jung Sky;;Croatia; ;MEY;Justair Scandinavia;MELODY;Sweden; ;DOJ;Justice Prisoner and Alien Transportation System;JUSTICE;United States; +OH;JIA;PSA Airlines;BLUE STREAK;United States; ;KTA;K2 Airways;;Pakistan; ;KSA;K S Avia;SKY CAMEL;Latvia; ;KCR;Kolob Canyons Air Services;KOLOB;United States; @@ -3494,7 +3498,7 @@ GJ;CDC;Loong Air;LOONG AIR;China; ;LSC;Los Cedros Aviación;CEDROS;Chile; ;TAS;Lotus Air;LOTUS FLOWER;Egypt; ;LTW;Luchtvaartmaatschappij Twente;TWENTAIR;Netherlands; -;LKE;Lucky Air;LUCKY AIR;China; +8L[35];LKE;Lucky Air;LUCKY AIR;China; ;LUT;Luft Carago;LUGO;South Africa; ;LVD;Luftfahrt-Vermietungs-Dienst;AIR SANTE;Austria; LH;DLH;Lufthansa;LUFTHANSA;Germany; @@ -3526,12 +3530,12 @@ Z8;AZN;Línea Aérea Amaszonas;;Bolivia; LT;SNG;LongJiang Airlines;SNOW EAGLE;China; ;LYB;Lynden Air Cargo;HIGHLANDS;Papua New Guinea; Q2;DQA;Maldivian;ISLAND AVIATION;Maldives; -;MMH;McMahon Helicopter;NIGHT RIDER;United States;2015[35] -;HOG;Mahogany Air Charters;HOGAN AIR;Zambia;2014[36] -;MTS;Med Jets;MED SERVICE;Mexico;2014[36] -;MSF;Minsheng International Jet;MEINSHENG;China;2014[36] -;MXS;Millon Express;MILLON EXPRESS;United States;Trading name for Sunrise Airlines allocated in 2014[37] -;MHF;Maritime Helicopters;AIR MARITIME;United States;Allocated 2014[38] +;MMH;McMahon Helicopter;NIGHT RIDER;United States;2015[36] +;HOG;Mahogany Air Charters;HOGAN AIR;Zambia;2014[37] +;MTS;Med Jets;MED SERVICE;Mexico;2014[37] +;MSF;Minsheng International Jet;MEINSHENG;China;2014[37] +;MXS;Millon Express;MILLON EXPRESS;United States;Trading name for Sunrise Airlines allocated in 2014[38] +;MHF;Maritime Helicopters;AIR MARITIME;United States;Allocated 2014[39] BF;MRK;MarkAir;MARKAIR;United States;1984-1995 WD;MWM;Modern Transporte Aereo De Carga;MODERNAIR;Brazil; ;MSJ;Magnum Air;MAGNUM AIR;Philippines; @@ -3777,7 +3781,7 @@ UB;UBA;Myanma Airways;UNIONAIR;Myanmar; ;MYA;Myflug;MYFLUG;Iceland; ;AAD;Mann Air Ltd;Ambassador;United Kingdom;t/a Ambassador M2;MHV;MHS Aviation GmbH;SNOWCAP;Germany; -;MTU;Middle Tennessee State University;BLUE RAIDER;United States;2019[39] +;MTU;Middle Tennessee State University;BLUE RAIDER;United States;2019[40] NP;NIA;Nile Air;NILE BIRD;Egypt; ;SIQ;National Center for Atmospheric Research;SCIENCE QUEST;United States; ;NEJ;Netjets Business Aviation;NET BUSINESS;China; @@ -3880,7 +3884,7 @@ HG;NLY;Niki;FLYNIKI;Austria; ;NSA;Nile Safaris Aviation;NILE SAFARIS;Sudan; ;NLW;Nile Wings Aviation Services;NILE WINGS;Sudan; ;NBS;Nimbus Aviation;NIMBUS;United Kingdom; -;NSR;Nine Star Airways;AIR STAR;Thailand;2014[40] +;NSR;Nine Star Airways;AIR STAR;Thailand;2014[41] KZ;NCA;Nippon Cargo Airlines;NIPPON CARGO;Japan; ;NVK;Nizhnevartovskavia;VARTOSKAVIA;Russia; ;NOH;No. 32 (The Royal) Squadron;NORTHOLT;United Kingdom; @@ -3936,7 +3940,7 @@ HW;NWL;North-Wright Airways;NORTHWRIGHT;Canada; ;NCE;Northcoast Executive Airlines;TOP HAT;United States; NE;NEE;Northeast Airlines;NORTHEAST;United States; ;NPX;Northeast Aviation;NORTHEAST EXPRESS;United States; -;NEW;Northeastern Aviation;MEADOW FLIGHT;United States;2014[40] +;NEW;Northeastern Aviation;MEADOW FLIGHT;United States;2014[41] NC*;NAC;Northern Air Cargo;YUKON;United States; ;BYC;Northern Airlines Sanya;BEIYA;China; ;NDA;Northern Airways;NORTHERN DAKOTA;United States; @@ -3959,10 +3963,10 @@ J3;PLR;Northwestern Air;POLARIS;Canada; ;NAM;Nortland Air Manitoba;MANITOBA;Canada; D8*;IBK;Norwegian Air International;NORTRANS;Ireland;subsidiary of Norwegian Air Shuttle (Ceased operations 2021) DY;NOZ;Norwegian Air Shuttle;NORDIC;Norway; -DI;NRS;Norwegian Air UK;REDNOSE*;United Kingdom;subsidiary of Norwegian Air Shuttle (Ceased operations 2021)[41] +DI;NRS;Norwegian Air UK;REDNOSE*;United Kingdom;subsidiary of Norwegian Air Shuttle (Ceased operations 2021)[42] DN;NAA;Norwegian Air Argentina;NORUEGA;Argentina;subsidiary of Norwegian Air Shuttle (Ceased operations 2019) DU;NLH;Norwegian Long Haul;NORSTAR;Norway;subsidiary of Norwegian Air Shuttle (Ceased operations 2021)[42] -DH;NAN;Norwegian Air Norway;NORSHIP;Norway;subsidiary of Norwegian Air Shuttle (transferred sole aircraft back to Norwegian Air Shuttle AOC in 2023)[43] +DH;NAN;Norwegian Air Norway;NORSHIP;Norway;subsidiary of Norwegian Air Shuttle (transferred sole aircraft back to Norwegian Air Shuttle AOC in 2023)[citation needed] D8;NSZ;Norwegian Air Sweden;REDNOSE;Sweden;subsidiary of Norwegian Air Shuttle ;TFN;Norwegian Aviation College;SPIRIT;Norway; ;XNT;Notams International;;United States; @@ -3982,7 +3986,7 @@ N6;ACQ;Nuevo Continente;AERO CONTINENTE;Peru;"Operating license revoked by Chile ;NIN;Nurman Avia Indopura;NURVINDO;Indonesia; ;NYS;Nyasa Express;NYASA;Malawi; 1I;NJE;NetJets Europe;FRACTION;Portugal; -;ORN;Orange Air;ORANGE JET;United States;Allocated in 2014[44] +;ORN;Orange Air;ORANGE JET;United States;Allocated in 2014[43] IP;ONS;One Airlines;AIR DREAMS;Chile; ;FET;Old Dominion Freight Lines;FREIGHT LINE;United States; ;DRL;Omni Air Transport;DRILLER;United States; @@ -4066,10 +4070,10 @@ OB;AAN;Oasis International Airlines Now assigned to Boliviana de Aviacion (BoA); ;ORT;Ortac;SKYWALKER;Jersey; PB;PVL;PAL Airlines;PAL Airlines;Canada; ;PIP;Pilot Flight Academy;PILOT;Norway; -;HRS;Pursuit Aviation;HORSEMAN;United States;2016[45] -;NCT;Pete Air;PETE AIR;Thailand;2014[46] -;PRT;Prime Service Italia;PRIME ITALIA;Italy;2014[46] -;PXT;Pacific Coast Jet;PACK COAST;United States;Allocated in 2014[47] +;HRS;Pursuit Aviation;HORSEMAN;United States;2016[44] +;NCT;Pete Air;PETE AIR;Thailand;2014[45] +;PRT;Prime Service Italia;PRIME ITALIA;Italy;2014[45] +;PXT;Pacific Coast Jet;PACK COAST;United States;Allocated in 2014[46] ;BPH;Phoenix Helicopter Academy;BLACK PHOENIX;United Kingdom; ;PFY;Pel-Air Aviation;PELFLIGHT;Australia; ;PXR;Pixair Survey;PIXAIR;France; @@ -4118,7 +4122,7 @@ PK;PIA;Pakistan International Airlines;PAKISTAN;Pakistan; ;PKR;Pakker Avio;PAKKER AVIO;Estonia; ;LPA;Pal Aerolíneas;LINEASPAL;Mexico; ;PPC;Palau Asia Pacific Airlines;PALAU ASIAPAC;Palau; -;PNA;Palau National Airlines;SEBUS;Palau;2014[46] +;PNA;Palau National Airlines;SEBUS;Palau;2014[45] GP;PTP;Palau Trans Pacific Airlines;TRANS PACIFIC;Palau; PF;PNW;Palestinian Airlines;PALESTINIAN;Egypt; ;JSP;Palmer Aviation;PALMER;United Kingdom; @@ -4133,7 +4137,7 @@ NR;PIR;Pamir Airways;PAMIR;Afghanistan; ;PMA;Pan Malaysian Air Transport;PAN MALAYSIA;Malaysia; ;PNC;Pan-Air;PANAIRSA;Mexico; ;PGI;Panagra Airways;PANAGRA;United States; -;RSL;Panama Aircraft Rental and Sales;PANAMA RENTAL;Panama;2014[46] +;RSL;Panama Aircraft Rental and Sales;PANAMA RENTAL;Panama;2014[45] ;PEI;Panamedia;PANAMEDIA;Spain; ;PVI;Panavia;;Panama; ;PNH;Panh;KUBAN LIK;Russia; @@ -4149,6 +4153,7 @@ P8;PTN;Pantanal Linhas Aéreas;PANTANAL;Brazil; ;PGF;Paragon Global Flight Support;;United Kingdom; ;PRR;Paramount Airlines;PARAMOUNT;Sierra Leone; I7;PMW;Paramount Airways;PARAWAY;India; +WE;PTA;Parata Air;PARATA AIR;Republic of Korea; ;APE;Parcel Express;AIR PARCEL;United States; ;IRE;Pariz Air;PARIZAIR;Iran; ;PRA;Pars Aviation Service;PARSAVIA;Iran; @@ -4336,8 +4341,8 @@ PB;SPR;Provincial Airlines;SPEEDAIR;Canada; ;PYR;Pyramid Air Lines;PYAIR;Egypt; ;PRI;Primera Air Scandinavia;PRIMERA;Denmark; ;PRW;Primera Air Nordic;JETBIRD;Latvia; -;FQA;Quikjet Airlines;QUIK LIFT;India;2014[48] -;QQE;Qatar Executive;;Qatar; +;FQA;Quikjet Airlines;QUIK LIFT;India;2014[47] +;QQE;Qatar Executive;QREX;Qatar; ;QNT;Qanot Sharq;QANAT SHARQ;Uzbekistan; QF;QFA;Qantas;QANTAS;Australia; QF;QLK;QantasLink;QLINK;Australia; @@ -4397,7 +4402,7 @@ R6;;RACSA;;Guatemala; ;CSM;Ratkhan Air;LORRY;Kazakhstan; ;RVR;Raven Air;RAVEN;United Kingdom; ;RVN;Raven Air;RAVEN U-S;United States;Qualiflight Training -7H;RVF;Ravn Alaska;RAVEN FLIGHT;United States;2014[49] +7H;RVF;Ravn Alaska;RAVEN FLIGHT;United States;2014[48] ;REI;Ray Aviation;RAY AVIATION;Israel; ;RYT;Raya Jet;;Jordan; ;RTN;Raytheon Aircraft Company;RAYTHEON;United States; @@ -4419,7 +4424,7 @@ REB;Rebus;REBUS;Bulgaria;; ;RDV;Red Sea Aviation;RED AVIATION;Egypt; ;RSV;Red Sky Ventures;RED SKY;Namibia; ;STR;Red Star;STARLINE;United Arab Emirates; -8L;RHC;Redhill Aviation;REDAIR;United Kingdom; +;RHC;Redhill Aviation;REDAIR;United Kingdom; ;VRD;Virgin America;REDWOOD;United States; ;RAV;Reed Aviation;REED AVIATION;United Kingdom; ;REF;Reef Air;REEF AIR;New Zealand; @@ -4448,14 +4453,14 @@ RH;RPH;Republic Express Airlines;PUBLIC EXPRESS;Indonesia; ;RBC;Republicair;REPUBLICAIR;Mexico; ;RST;Resort Air;RESORT AIR;United States; ;RUT;Reut Airways;YADID;Israel; -;RGV;RG Aviation;;Venezuela;2014[49] +;RGV;RG Aviation;;Venezuela;2014[48] ;RDS;Rhoades Aviation;RHOADES EXPRESS;United States; ;RIU;Riau Airlines;RIAU AIR;Indonesia; ;RIA;Rich International Airways;RICHAIR;United States; ;RVC;Richards Aviation;RIVER CITY;United States; ;RIC;Richardson's Airway;RICHARDSON;United States; ;RCA;Richland Aviation;RICHLAND;United States; -;WHH;Richy Skylark;;Sri Lanka;2014[49] +;WHH;Richy Skylark;;Sri Lanka;2014[48] ;HPR;Rick Lucas Helicopters;HELIPRO;New Zealand; C7;RLE;Rico Linhas Aéreas;RICO;Brazil; ;RID;Ridder Avia;AKRID;Kazakhstan; @@ -4487,7 +4492,7 @@ V2;RBY;Vision Airlines;RUBY;United States;Charter Airline and Las Vegas Tours ;RMV;Romavia;AEROMAVIA;Romania; ;RNS;Ronso;RONSO;Mexico; ;ROR;Roraima Airways;RORAIMA;Guyana; -;KRS;Rosen Aviation;;Japan;2014[49] +;KRS;Rosen Aviation;;Japan;2014[48] ;RNB;Rosneft-Baltika;ROSBALT;Russia; ;NRG;Ross Aviation;ENERGY;United States; ;RFS;Rossair;;Australia; @@ -4523,7 +4528,7 @@ BI;RBA;Royal Brunei Airlines;BRUNEI;Brunei; ;ROJ;Royal Jet;ROYALJET;United Arab Emirates; RJ;RJA;Royal Jordanian;JORDANIAN;Jordan; ;RJZ;Royal Jordanian Air Force;JORDAN AIR FORCE;Jordan; -RK;RCT;Skyview Airways;GREENSKY;THAILAND;2014[49] +RK;RCT;Skyview Airways;GREENSKY;THAILAND;2014[48] RK;RKH;Royal Khmer Airlines;KHMER AIR;Cambodia; ;RMF;Royal Malaysian Air Force;ANGKASA;Malaysia; ;NVY;Royal Navy;NAVY;United Kingdom; @@ -4535,7 +4540,7 @@ RK;RKH;Royal Khmer Airlines;KHMER AIR;Cambodia; RL;PPW;Royal Phnom Penh Airways;PHNOM-PENH AIR;Cambodia; ;RRA;Royal Rwanda Airlines;ROYAL RWANDA;Rwanda; ;RSF;Royal Saudi Air Force;ARSAF;Saudi Arabia; -RR;RYS;Buzz (Ryanair);MAGIC SUN;Poland; +RR;RYS;Buzz (Polish airline);MAGIC SUN;Poland; ;RSN;Royal Swazi National Airways;SWAZI NATIONAL;Swaziland; WR;HRH;Royal Tongan Airlines;TONGA ROYAL;Tonga; ;RWE;Royal West Airlines;ROYAL WEST;United States; @@ -4564,17 +4569,18 @@ RK;RUK;Ryanair UK;BLUEMAX;United Kingdom; ;RAA;Rynes Aviation;RYNES AVIATION;United States; ;REV;RVL Group;ENDURANCE;United Kingdom; RT;BUG;UVT Aero;;Russia; -;OMN;Servicios Aereos Ominia;SERVIOMNIA;Mexico;2014[50] -;SEN;Servicios de Aviacion Sierra;SERVISIERRA;Mexico;2014[50] -;SGC;SGC Aviation;SAINT GEORGE;Austria;2014[50] -;SCJ;Siamjet Aviation;SIAMJET;Thailand;2014[50] -;SIX;Sixt Rent A Car;DRIVE ORANGE;United States;2014[50] -;SOG;Solenta Aviation Ghana;;Ghana;2014[50] -;QSR;SR Jet;SPARKLE ROLL;China;2014[50] -;KBN;Spiracha Aviation;KABIN;Thailand;2014[50] -;CBN;"Southern Illinois University as ""Aviation Flight""";CARBONDALE;United States;Allocated in 2014[51] -;IBG;Springfield Air;ICE BRIDGE;United States;Allocated 2014[52] -;BZQ;Seneca Polytechnic;STING;Canada;Operates as part of the Bachelor of Aviation program. Allocated 2014[53] +WJ;JES;Jetsmart Argentina;SMARTBIRD;Argentina; +;OMN;Servicios Aereos Ominia;SERVIOMNIA;Mexico;2014[49] +;SEN;Servicios de Aviacion Sierra;SERVISIERRA;Mexico;2014[49] +;SGC;SGC Aviation;SAINT GEORGE;Austria;2014[49] +;SCJ;Siamjet Aviation;SIAMJET;Thailand;2014[49] +;SIX;Sixt Rent A Car;DRIVE ORANGE;United States;2014[49] +;SOG;Solenta Aviation Ghana;;Ghana;2014[49] +;QSR;SR Jet;SPARKLE ROLL;China;2014[49] +;KBN;Spiracha Aviation;KABIN;Thailand;2014[49] +;CBN;"Southern Illinois University as ""Aviation Flight""";CARBONDALE;United States;Allocated in 2014[50] +;IBG;Springfield Air;ICE BRIDGE;United States;Allocated 2014[51] +;BZQ;Seneca Polytechnic;STING;Canada;Operates as part of the Bachelor of Aviation program. Allocated 2014[52] ;BVV;Spark+;SPARC;Russia; ;SJM;Sino Jet Management;SINO SKY;China; ;SCH;Seychelles Airlines;OCEAN BIRD;Seychelles; @@ -4627,7 +4633,7 @@ SK;SAS;Scandinavian Airlines;SCANDINAVIAN;Sweden, Denmark and Norway; ;SAV;Samal Air;;Kazakhstan; ;SAW;Cham Wing Airlines;SHAMWING;Syrian Arab Republic; SA;SAX;Sabah Air;SABAH AIR;Malaysia; -;SAZ;Swiss Air-Ambulance;SWISS AMBULANCE;Switzerland; +;SAZ;Swiss Air-Ambulance;SWISS AMBULANCE;Switzerland;A subsidiary of Swiss Air-Rescue Rega ;SBA;SOL Linhas Aéreas;SOL;Brazil; ;SBB;Steinman Aviation;SABER EXPRESS;United States; UG;TUX;Tunisair Express;TUNEXPRESS;Tunisia; @@ -4656,7 +4662,7 @@ W3;SCL;Switfair Cargo;SWIFTAIR;Canada; ;SCB;Saigon Capital Aircraft Management;SAIGON;Netherlands; ;SCN;South American Airlines;SOUTH AMERICAN;Peru; ;AHI;Servicios Aéreos de Chihuahua Aerochisa;AEROCHISA;Mexico; -FP;AND;Servicios Aéreos de los Andes;SERVI ANDES;Peru;2014[50] +FP;AND;Servicios Aéreos de los Andes;SERVI ANDES;Peru;2014[49] ;SCP;Scorpio Aviation;SCORPIO;Egypt; ;SCQ;OSM Aviation Academy;SCAVAC;Norway, Sweden and San Diego; ;SIC;SFS Aviation;SICHART;Thailand; @@ -4961,7 +4967,7 @@ TE;IGA;Skytaxi;IGUANA;Poland; ;LLA;Servico Leo Lopex;LEO LOPOZ;Mexico; ;LLS;Servicios Aéreos Estrella;SERVIESTRELLA;Mexico; ;LMG;South African Air Force;SOUTH AFRICAN;South Africa; -;LMO;Sky One Holdings as Privaira;SKY HOLDINGS;United States;"Callsign and company name changed from Sky Limo Corporation ""SKY LIMO"" in 2015.[55]" +;LMO;Sky One Holdings as Privaira;SKY HOLDINGS;United States;"Callsign and company name changed from Sky Limo Corporation ""SKY LIMO"" in 2015.[54]" RZ*;LRS;Sansa;;Costa Rica; ;LSP;Spectrum Aviation Incorporated;AIR TONY;United Kingdom; ;MCG;SOS Helikoptern Gotland;MEDICOPTER;Sweden; @@ -5093,7 +5099,7 @@ ZS;SOP;Solinair;SOLINAIR;Slovenia; ;SOT;Southeast Correct Craft;SOUTH COURIER;United States; 9X;SOU;Southern Airways;SOUTHERN EXPRESS;United States; 6W;SOV;Saratov Airlines Joint Stock Company;SARATOV AIR;Russia; -;SOW;White Sparrow GmbH;SPARROW;Austria;[58] +;SOW;White Sparrow GmbH;SPARROW;Austria;[57] ;SOX;Solid Air;SOLIDAIR;Netherlands; HZ;SOZ;Sat Airlines;SATCO;Kazakhstan; ;SPA;Sierra Pacific Airlines;SIERRA PACIFIC;United States; @@ -5109,7 +5115,7 @@ HZ;SOZ;Sat Airlines;SATCO;Kazakhstan; ;SPP;Sapphire Aviation;SAPPHIRE;United States; ;SPQ;Servicios Aéreos Palenque;SERVICOS PALENQUE;Mexico; ;TBS;Servicios Aéreos Tribasa;TRIBASA;Mexico; -;SVV;SALTAVIATION;SALT;Poland;[59] +;SVV;SALTAVIATION;SALT;Poland;[58] ;TGT;SAAB Nyge Aero;TARGET;Sweden; ;THB;Spark Air;THAI SABAI;Thailand; ;TIH;S C Ion Tiriac;TIRIAC AIR;Romania; @@ -5260,7 +5266,7 @@ TXZ;;Thai Express Air;EXPRESS AIR;Thailand; ;TFT;Thai Flying Service;THAI FLYING;Thailand; ;THG;Thai Global Airline;THAI GLOBAL;Thailand; ;THJ;Thai Jet Intergroup;THAI JET;Thailand; -SL;TLM;Thai Lion Mentari;MENTARI;Thailand; +SL;TLM;Thai Lion Mentari;MENTARI;Thailand;Associate of Lion Air ;TPV;Thai Pacific Airlines Business;THAI PACIFIC;Thailand; 9I;LLR;Thai Sky Airlines;THAI SKY AIR;Thailand; WE;THD;Thai Smile Airways;THAI SMILE;Thailand; @@ -5508,9 +5514,9 @@ VO;TYR;Tyrolean Airways;TYROLEAN;Austria;Renamed from Austrian Arrows ;TJS;Tyrolean Jet Services;TYROLJET;Austria; ;TUM;Tyumenspecavia;TUMTEL;Russia; VNX;TKK;flyADVANCED;TARKA;United States;Aero Ways Inc. flyADVANCED -;UEU;United European Airlines;UNITED EUROPEAN;Romania;2014[60] -;UCG;Uniworld Air Cargo;UNIWORLD;Panama;2014[60] -;CUH;Urumqi Airlines;LOULAN;China;2014[60] +;UEU;United European Airlines;UNITED EUROPEAN;Romania;2014[59] +;UCG;Uniworld Air Cargo;UNIWORLD;Panama;2014[59] +;CUH;Urumqi Airlines;LOULAN;China;2014[59] ;DOD;USAF Air Mobility Operations Control Center;;United States; ;DOI;U.S. Department of the Interior;INTERIOR;United States;Office of Aircraft Services ;CNV;U.S. Navy Reserve Logistic Air Forces;CONVOY;United States;U.S. Navy Reserve Logistic Air Forces, New Orleans, LA, USA @@ -5585,7 +5591,7 @@ UH;USH;US Helicopter;US-HELI;United States; ;USJ;US Jet;USJET;United States; ;USX;US Express;AIR EXPRESS;United States; QU;UTN;Skyline Express;Skyline Express Airline;Ukraine; -;TUM;UTAir;UTAIR-CARGO;Russian Federation;2014[60] +;TUM;UTAir;UTAIR-CARGO;Russian Federation;2014[59] UT;UTA;UTair Aviation;UTAIR;Russia;WAS P2 till 2006 ;UTR;Utair South Africa;AIRUT;South Africa; ;UTS;Ukrainian State Air Traffic Service Enterprise;AIRRUH;Ukraine; @@ -5676,7 +5682,7 @@ VK;VGN;Virgin Nigeria Airways;VIRGIN NIGERIA;Nigeria; VS;VIR;Virgin Atlantic;VIRGIN;United Kingdom; ;VJM;Viajes Ejecutivos Mexicanos;VIAJES MEXICANOS;Mexico; ;VJT;Vistajet;VISTA;Canada; -;VJT;Vistajet;VISTA MALTA;Malta;2014[61] +;VJT;VistaJet;VISTA MALTA;Malta;2014[60] VE;VLE;C.A.I. Second;VOLA;Italy; VY;VLG;Vueling Airlines;VUELING;Spain; XF;VLK;Vladivostok Air;VLADAIR;Russia;Merged with Aurora @@ -5753,7 +5759,7 @@ ST*;STT;Western Aircraft, Inc;SAWTOOTH;United States; ;WAL;Western Arctic Air;WESTERN ARCTIC;Canada; ;WTV;Western Aviators;WESTAVIA;United States; ;WES;Western Express Air Lines;WEST EX;Canada; -;WGN;Western Global Airlines;WESTERN GLOBAL;United States;Allocated in 2014[62] +;WGN;Western Global Airlines;WESTERN GLOBAL;United States;Allocated in 2014[61] W7;KMR;Western Pacific Airlines;KOMSTAR;United States; ;WPA;Western Pacific Airservice;WESTPAC;Solomon Islands; ;WSL;Westflight Aviation;WEST LINE;United Kingdom; @@ -5805,6 +5811,7 @@ WW;WOW;WOW air;WOW air;Iceland; ;WYG;Wyoming Airlines;WYOMING;United States; KW;WAN;Wataniya Airways;WATANIYA;Kuwait; WR;WEN;WestJet Encore;ENCORE;Canada; +WJ;JES;JetSmart Argentina;SMARTBIRD;Argentina; ;XJE;X-Jet;;Austria; ;XAB;Xabre Aerolineas;AERO XABRE;Mexico; ;XAE;Xair;AURA;Czech Republic; @@ -5842,7 +5849,7 @@ YT;NYT;Yeti Airlines;YETI AIRLINES;Nepal;Domestic ;AYE;Yunnan Yingan Airlines;AIR YING AN;China; ;UGN;Yuzhnaya Aircompany;PLUTON;Kazakhstan; 2N;UMK;Yuzhmashavia;YUZMASH;Ukraine; -;BZE;Zenith Aviation;ZENSTAR;United Kingdom;2014[63] +;BZE;Zenith Aviation;ZENSTAR;United Kingdom;2014[62] ;AZB;Zaab Air;ZAAB AIR;Ghana; ;AZJ;Zas Air;;Egypt; ;AZR;Zenith Air;ZENAIR;South Africa; diff --git a/dev/prometheus/podman-compose.yml b/dev/prometheus/podman-compose.yml index e1bbb10..b1c74af 100644 --- a/dev/prometheus/podman-compose.yml +++ b/dev/prometheus/podman-compose.yml @@ -17,10 +17,7 @@ services: - '--web.console.templates=/etc/prometheus/consoles' - '--web.enable-lifecycle' restart: unless-stopped - extra_hosts: - - "host.containers.internal:host-gateway" - networks: - - monitoring + network_mode: "slirp4netns:allow_host_loopback=true" grafana: image: docker.io/grafana/grafana:latest @@ -36,14 +33,7 @@ services: restart: unless-stopped depends_on: - prometheus - networks: - - monitoring - extra_hosts: - - "host.containers.internal:host-gateway" - -networks: - monitoring: - driver: bridge + network_mode: "slirp4netns:allow_host_loopback=true" volumes: prometheus_data: diff --git a/dev/prometheus/prometheus.yml b/dev/prometheus/prometheus.yml index c9f905b..1889271 100644 --- a/dev/prometheus/prometheus.yml +++ b/dev/prometheus/prometheus.yml @@ -11,4 +11,4 @@ scrape_configs: - job_name: 'prometheus' static_configs: - - targets: ['localhost:9090'] \ No newline at end of file + - targets: ['localhost:9090'] diff --git a/go.mod b/go.mod index 0426fae..3e255f4 100644 --- a/go.mod +++ b/go.mod @@ -3,19 +3,22 @@ module github.com/emschu/dump1090prom go 1.25.0 require ( - github.com/golang/geo v0.0.0-20260129164528-943061e2742c + github.com/golang/geo v0.0.0-20260328141014-8b970c039d06 github.com/prometheus/client_golang v1.23.2 + github.com/prometheus/common v0.67.5 ) require ( github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/kr/text v0.2.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/klauspost/compress v1.18.5 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/prometheus/client_model v0.6.2 // indirect - github.com/prometheus/common v0.67.5 // indirect github.com/prometheus/procfs v0.20.1 // indirect - go.yaml.in/yaml/v2 v2.4.3 // indirect - golang.org/x/sys v0.41.0 // indirect + go.yaml.in/yaml/v2 v2.4.4 // indirect + golang.org/x/sys v0.42.0 // indirect google.golang.org/protobuf v1.36.11 // indirect ) diff --git a/go.sum b/go.sum index c40a653..9f7da1e 100644 --- a/go.sum +++ b/go.sum @@ -2,23 +2,35 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/golang/geo v0.0.0-20260129164528-943061e2742c h1:ysO2h2Odnl1AJM1I2Lm/fa6JvO0pECMSt2CwBaa+ITo= -github.com/golang/geo v0.0.0-20260129164528-943061e2742c/go.mod h1:Mymr9kRGDc64JPr03TSZmuIBODZ3KyswLzm1xL0HFA8= +github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo= +github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= +github.com/golang/geo v0.0.0-20260328141014-8b970c039d06 h1:j+1P01wEldOsnwe1qD4Cl/xXskAbqU5ob675KL9DJb8= +github.com/golang/geo v0.0.0-20260328141014-8b970c039d06/go.mod h1:Mymr9kRGDc64JPr03TSZmuIBODZ3KyswLzm1xL0HFA8= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= -github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= -github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/klauspost/compress v1.18.5 h1:/h1gH5Ce+VWNLSWqPzOVn6XBO+vJbCNGvjoaGBFW2IE= +github.com/klauspost/compress v1.18.5/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o= @@ -29,20 +41,23 @@ github.com/prometheus/common v0.67.5 h1:pIgK94WWlQt1WLwAC5j2ynLaBRDiinoAb86HZHTU github.com/prometheus/common v0.67.5/go.mod h1:SjE/0MzDEEAyrdr5Gqc6G+sXI67maCxzaT3A2+HqjUw= github.com/prometheus/procfs v0.20.1 h1:XwbrGOIplXW/AU3YhIhLODXMJYyC1isLFfYCsTEycfc= github.com/prometheus/procfs v0.20.1/go.mod h1:o9EMBZGRyvDrSPH1RqdxhojkuXstoe4UlK79eF5TGGo= -github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0= -go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8= -golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k= -golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +go.yaml.in/yaml/v2 v2.4.4 h1:tuyd0P+2Ont/d6e2rl3be67goVK4R6deVxCUX5vyPaQ= +go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ= +golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= +golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= +golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw= +golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA= +golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo= +golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= +golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/main.go b/main.go index c8e99d4..c5c0b13 100644 --- a/main.go +++ b/main.go @@ -30,11 +30,14 @@ import ( "github.com/prometheus/client_golang/prometheus/promhttp" ) -var VERSION = "1.0.3" +var VERSION = "1.0.4" //go:embed data/wikipedia-airlines.csv var wikipediaAirlinesCsvFileContent string +//go:embed data/countries.csv +var countriesCsvFileContent string + var CONFIG dump1090MetricCollectorConfig func main() { @@ -42,13 +45,15 @@ func main() { file := flag.String("base-path", "", "Path to the directory where aircraft.json and receiver.json are located") lat := flag.Float64("lat", 0.0, "Custom latitude of the receiver") lon := flag.Float64("lon", 0.0, "Custom longitude of the receiver") - host := flag.String("host", "0.0.0.0", "Host to listen on (default: 0.0.0.0)") + host := flag.String("host", "127.0.0.1", "Host to listen on (default: 127.0.0.1)") port := flag.Int("port", 8080, "Port to listen on (default: 8080)") verbose := flag.Bool("verbose", false, "Enable verbose output") distanceCalc := flag.Bool("distance-calc", true, "Enable distance calculation to aircraft") airlineLabel := flag.Bool("airline-label", true, "Enable airline labelling") exposeFiles := flag.Bool("expose-files", true, "Expose original aircraft.json and receiver.json files") rollingMapSize := flag.Int("rolling-map-size", 1000, "Default size of the rolling map for caching") + collector := flag.String("collector", "dump1090prom", "Constant 'collector' label value of this instance") + globalLabels := flag.String("labels", "", "Global labels to add to all metrics (e.g., 'location=home,env=prod')") flag.Parse() log.Printf("Dump1090Prom - A bridge between the dump1090 JSON data and prometheus – Version %s", VERSION) source := findMetricSource(url, file) @@ -71,6 +76,19 @@ func main() { if rollingMapSize != nil { CONFIG.RollingMapDefaultSize = *rollingMapSize } + if collector != nil { + CONFIG.Collector = *collector + } + CONFIG.GlobalLabels["collector"] = CONFIG.Collector + if globalLabels != nil && *globalLabels != "" { + labels := strings.Split(*globalLabels, ",") + for _, label := range labels { + parts := strings.SplitN(label, "=", 2) + if len(parts) == 2 { + CONFIG.GlobalLabels[strings.TrimSpace(parts[0])] = strings.TrimSpace(parts[1]) + } + } + } initRollingMaps() receiverData, err := source.fetchReceiverMetrics() if err != nil { @@ -104,11 +122,11 @@ func main() { } // Read airline data - data, err := readAirlinesData(wikipediaAirlinesCsvFileContent) + airlineData, err := readAirlinesData(wikipediaAirlinesCsvFileContent) if err != nil { log.Fatalf("Cannot open airline data: %v", err) } - airlines = data + airlines = airlineData for _, airline := range airlines { icao := strings.TrimSpace(airline.ICAO) if icao == "" { @@ -117,6 +135,10 @@ func main() { } icaoToFilter = append(icaoToFilter, icao) } + icaoCountries, err = readCountryData(countriesCsvFileContent) + if err != nil { + log.Fatalf("Cannot open country data: %v", err) + } metric := newDump1090Metric(CONFIG.Source) metric.LoadAll() @@ -130,7 +152,19 @@ func main() { } else { if CONFIG.IsVerbose { for _, mf := range metricFamilies { - log.Printf("Metric: %s, Type: %s, Description: %s\n", *mf.Name, mf.Type.String(), *mf.Help) + var metric *dump1090MetricItem + for _, v := range metrics { + metricName := fmt.Sprintf("%s_%s", v.Namespace, v.Name) + if metricName == *mf.Name { + metric = &v + break + } + } + if metric == nil { + continue + } + log.Printf("Metric: %s – Type: %s – Labels: %s – Description: %s\n", + *mf.Name, mf.Type.String(), strings.Join(metric.Labels, ", "), *mf.Help) } } } @@ -158,17 +192,18 @@ func main() { } } -func writeFileAsJson(w http.ResponseWriter, err error, fetchMetrics interface{}) { +func writeFileAsJson(w http.ResponseWriter, err error, fetchMetrics any) { w.Header().Set("Content-Type", "application/json") if err != nil { log.Printf("Error fetching metrics: %v", err) w.WriteHeader(http.StatusNotFound) return } - marshal, err := json.Marshal(fetchMetrics) + marshal, err := json.MarshalIndent(fetchMetrics, "", " ") if err != nil { log.Printf("Error marshalling metrics: %v", err) w.WriteHeader(http.StatusInternalServerError) + return } _, err = w.Write(marshal) if err != nil { diff --git a/main_test.go b/main_test.go index 419d2a2..2dc3596 100644 --- a/main_test.go +++ b/main_test.go @@ -18,9 +18,16 @@ package main import ( + "io" + "net/http" + "net/http/httptest" "os" "path/filepath" + "strings" "testing" + + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/promhttp" ) func TestFindMetricSource_FileBasePath(t *testing.T) { @@ -73,3 +80,54 @@ func TestIsDir(t *testing.T) { t.Fatalf("expected non-existing path to return false") } } + +func TestGlobalLabels(t *testing.T) { + // Setup config with global labels + empty := "" + path := "example" + source := findMetricSource(&empty, &path) + CONFIG = *newDump1090MetricCollectorConfig(source) + CONFIG.GlobalLabels = map[string]string{ + "location": "home", + "env": "test", + } + + // Create and register the collector + // Note: since prometheus.DefaultRegisterer is global, we should use a local registry for testing + registry := prometheus.NewRegistry() + metric := newDump1090Metric(source) + registry.MustRegister(metric) + + // Create a test HTTP server + handler := promhttp.HandlerFor(registry, promhttp.HandlerOpts{}) + ts := httptest.NewServer(handler) + defer ts.Close() + + // Make a request to the test server + resp, err := http.Get(ts.URL) + if err != nil { + t.Fatalf("failed to get metrics: %v", err) + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + t.Fatalf("failed to read body: %v", err) + } + + output := string(body) + + // Check if global labels are present in at least one metric + // e.g. dump1090prom_aircraft_count{env="test",location="home"} + if !strings.Contains(output, `location="home"`) { + t.Errorf("expected global label location=\"home\" not found in output") + } + if !strings.Contains(output, `env="test"`) { + t.Errorf("expected global label env=\"test\" not found in output") + } + + // Verify it's on a specific metric too + if !strings.Contains(output, `dump1090prom_aircraft_count{env="test",location="home"}`) { + t.Errorf("metric dump1090prom_aircraft_count does not have expected global labels") + } +} diff --git a/metric.go b/metric.go index 9e309c4..480a756 100644 --- a/metric.go +++ b/metric.go @@ -141,7 +141,7 @@ var metrics = []dump1090MetricItem{ Name: METRIC_AIRCRAFT_FLIGHT_INFO, Namespace: Dump1090Namespace, Help: "Metadata about the flight and aircraft", - Labels: []string{"hex", "flight", "lat", "lon", "category", "squawk", "direction", "distance", "airline"}, + Labels: []string{"hex", "flight", "lat", "lon", "category", "squawk", "direction", "distance", "airline", "country"}, Type: METRIC_ITEM_TYPE_GAUGE_VEC, }, { Name: METRIC_AIRCRAFT_TRUE_AIR_SPEED_KNOTS, @@ -345,6 +345,7 @@ type dump1090Metric struct { var flightMap *RollingFlightMap var flightAirLineMap *RollingAirlineMap var flightAirLineLabelMap *RollingAirlineLabelMap +var flightIcaoCountryMap *RollingIcaoCountryMap func initRollingMaps() { if flightMap != nil { @@ -353,6 +354,7 @@ func initRollingMaps() { flightMap = NewRollingFlightMap(CONFIG.RollingMapDefaultSize) flightAirLineMap = NewRollingAirLineMap(CONFIG.RollingMapDefaultSize) flightAirLineLabelMap = NewRollingAirLineLabelMap(CONFIG.RollingMapDefaultSize) + flightIcaoCountryMap = NewRollingAirLineCountryMap(CONFIG.RollingMapDefaultSize) } func newDump1090Metric(source MetricSource) *dump1090Metric { @@ -390,6 +392,7 @@ func (d *dump1090Metric) Collect(ch chan<- prometheus.Metric) { for _, ac := range data.Aircraft { hex := strings.TrimSpace(ac.Hex) flight := strings.TrimSpace(ac.Flight) + country := strings.TrimSpace(getIcaoCountryLabel(hex)) var distance float64 if ac.Lat != nil && ac.Lon != nil { @@ -423,7 +426,7 @@ func (d *dump1090Metric) Collect(ch chan<- prometheus.Metric) { } var airline string if CONFIG.IsAirlineLabellingEnabled { - possibleAirline := getAirlineLabel(flight) + possibleAirline := getAirlineLabel(flight, hex) if possibleAirline != nil { airline = strings.TrimSpace(*possibleAirline) } @@ -492,7 +495,7 @@ func (d *dump1090Metric) Collect(ch chan<- prometheus.Metric) { d.mustFindMetric(METRIC_AIRCRAFT_SEEN_POS_SECOND).GaugeVec.WithLabelValues(hex, flight).Set(*ac.SeenPos) } - d.mustFindMetric(METRIC_AIRCRAFT_FLIGHT_INFO).GaugeVec.WithLabelValues(hex, flight, aircraftLat, aircraftLon, ac.Category, ac.Squawk, direction, fmt.Sprintf("%.6f", distance), airline).Set(1) + d.mustFindMetric(METRIC_AIRCRAFT_FLIGHT_INFO).GaugeVec.WithLabelValues(hex, flight, aircraftLat, aircraftLon, ac.Category, ac.Squawk, direction, fmt.Sprintf("%.6f", distance), airline, country).Set(1) d.mustFindMetric(METRIC_AIRCRAFT_ADSB_VERSION).GaugeVec.WithLabelValues(hex, flight).Set(float64(ac.Version)) @@ -588,21 +591,24 @@ func (d *dump1090Metric) LoadAll() { switch i.Type { case METRIC_ITEM_TYPE_GAUGE: gauge = prometheus.NewGauge(prometheus.GaugeOpts{ - Namespace: i.Namespace, - Name: i.Name, - Help: i.Help, + Namespace: i.Namespace, + Name: i.Name, + Help: i.Help, + ConstLabels: CONFIG.GlobalLabels, }) case METRIC_ITEM_TYPE_GAUGE_VEC: vec = prometheus.NewGaugeVec(prometheus.GaugeOpts{ - Namespace: i.Namespace, - Name: i.Name, - Help: i.Help, + Namespace: i.Namespace, + Name: i.Name, + Help: i.Help, + ConstLabels: CONFIG.GlobalLabels, }, i.Labels) case METRIC_ITEM_TYPE_COUNTER: counter = prometheus.NewCounter(prometheus.CounterOpts{ - Namespace: i.Namespace, - Name: i.Name, - Help: i.Help, + Namespace: i.Namespace, + Name: i.Name, + Help: i.Help, + ConstLabels: CONFIG.GlobalLabels, }) default: log.Fatalf("Unknown metric type: %d", i.Type) diff --git a/metric_collect_test.go b/metric_collect_test.go deleted file mode 100644 index d4a0c03..0000000 --- a/metric_collect_test.go +++ /dev/null @@ -1,136 +0,0 @@ -// dump1090prom -// Copyright (C) 2025 emschu[aet]mailbox.org -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public -// License along with this program. -// If not, see . - -package main - -import ( - "net/http" - "net/http/httptest" - "testing" - - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/client_golang/prometheus/promhttp" -) - -type stubRichSource struct{ p string } - -func (s *stubRichSource) getPath() string { return s.p } -func (s *stubRichSource) validateInput() bool { return true } -func (s *stubRichSource) fetchReceiverMetrics() (*Dump1090ReceiverJson, error) { - return &Dump1090ReceiverJson{}, nil -} -func (s *stubRichSource) fetchMetrics() (*Dump1090AircraftJson, error) { - lat := 48.0 - lon := 11.0 - altb := 30000.0 - altg := 30500.0 - gs := 420.0 - ias := 250.0 - tas := 300.0 - mach := 0.78 - track := 270.0 - trackRate := 1.2 - roll := 2.0 - magHeading := 268.0 - baroRate := -500.0 - geomRate := -450.0 - navQNH := 1013.0 - navAlt := 32000.0 - navHeading := 265.0 - trueHeading := 266.0 - seenPos := 2.0 - nacp := 8 - nacv := 2 - nic := 7 - nicBaro := 1 - sil := 2 - gva := 1 - sda := 2 - rc := 75 - - return &Dump1090AircraftJson{ - Now: 12345, - Messages: 3, - Aircraft: []AircraftStateRecord{{ - Hex: "ABCDEF", - Flight: "TST123", - AltBaro: &altb, - AltGeom: &altg, - GS: &gs, - IAS: &ias, - TAS: &tas, - Mach: &mach, - Track: &track, - TrackRate: &trackRate, - Roll: &roll, - MagHeading: &magHeading, - BaroRate: &baroRate, - GeomRate: &geomRate, - NavQNH: &navQNH, - NavAltitudeMCP: &navAlt, - NavHeading: &navHeading, - TrueHeading: &trueHeading, - Lat: &lat, - Lon: &lon, - SeenPos: &seenPos, - Messages: 2, - Seen: 1, - RSSI: -2, - Category: "A1", - Squawk: "7000", - Emergency: "none", - SILType: "perhour", - Version: 2, - NACP: &nacp, - NACV: &nacv, - NIC: &nic, - NICBaro: &nicBaro, - SIL: &sil, - GVA: &gva, - SDA: &sda, - RC: &rc, - ModeA: true, - ModeC: true, - }}, - }, nil -} - -func TestCollectCoversMostBranches(t *testing.T) { - // Receiver position for distance - plat := 48.1 - plon := 11.6 - src := &stubRichSource{p: "stub"} - CONFIG = *newDump1090MetricCollectorConfig(src) - CONFIG.ReceiverPositionLat = &plat - CONFIG.ReceiverPositionLon = &plon - CONFIG.IsVerbose = true - - reg := prometheus.NewRegistry() - m := newDump1090Metric(src) - reg.MustRegister(m) - - // Expose via HTTP and query once to trigger Collect - handler := promhttp.HandlerFor(reg, promhttp.HandlerOpts{}) - srv := httptest.NewServer(handler) - defer srv.Close() - - resp, err := http.Get(srv.URL) - if err != nil { - t.Fatalf("http get: %v", err) - } - _ = resp.Body.Close() -} diff --git a/sources.go b/sources.go index 1736e62..15761e9 100644 --- a/sources.go +++ b/sources.go @@ -77,17 +77,20 @@ func readReceiverJsonFromFile(inFile string) (*Dump1090ReceiverJson, error) { } func readFile[T payloads](inFile string) (*T, error) { - // TODO make secure - file, err := os.ReadFile(inFile) + f, err := os.Open(inFile) if err != nil { return nil, err } - var msg *T - jsonErr := json.Unmarshal(file, &msg) - if jsonErr != nil { - log.Fatalf("Error parsing receiver.json: %v", jsonErr) + defer f.Close() + + // Use a LimitReader to prevent reading extremely large files (e.g., 10MB limit) + lr := io.LimitReader(f, 10*1024*1024) + + var payload T + if err := json.NewDecoder(lr).Decode(&payload); err != nil { + return nil, fmt.Errorf("error parsing JSON from file '%s': %w", inFile, err) } - return msg, nil + return &payload, nil } type URLMetricSource struct { diff --git a/sources_test.go b/sources_test.go index 3f94bc0..c0e194e 100644 --- a/sources_test.go +++ b/sources_test.go @@ -165,3 +165,13 @@ func TestReadJsonFromFile_NotFound(t *testing.T) { t.Fatalf("expected error for missing receiver.json") } } + +func TestReadFile_InvalidJSON_ShouldReturnError(t *testing.T) { + tmp := t.TempDir() + file := filepath.Join(tmp, "invalid.json") + _ = os.WriteFile(file, []byte("{"), 0o644) + _, err := readFile[Dump1090AircraftJson](file) + if err == nil { + t.Fatal("expected error, got nil") + } +} diff --git a/util.go b/util.go index e4a0c09..d141650 100644 --- a/util.go +++ b/util.go @@ -25,6 +25,7 @@ import ( type RollingFlightMap = GenericRollingStringKeyValueStore[string] type RollingAirlineMap = GenericRollingStringKeyValueStore[airline] type RollingAirlineLabelMap = GenericRollingStringKeyValueStore[string] +type RollingIcaoCountryMap = GenericRollingStringKeyValueStore[[]countryData] type GenericRollingStringKeyValueStore[T any] struct { capacity int @@ -33,10 +34,10 @@ type GenericRollingStringKeyValueStore[T any] struct { store sync.Map // string -> T } -func NewRollingFlightMap(n int) *RollingFlightMap { +func NewRollingFlightMap(i int) *RollingFlightMap { return &RollingFlightMap{ - capacity: n, - keys: make([]string, 0, n), + capacity: i, + keys: make([]string, 0, i), } } @@ -54,6 +55,13 @@ func NewRollingAirLineMap(i int) *RollingAirlineMap { } } +func NewRollingAirLineCountryMap(i int) *RollingIcaoCountryMap { + return &RollingIcaoCountryMap{ + capacity: i, + keys: make([]string, 0, i), + } +} + func (rm *GenericRollingStringKeyValueStore[T]) Set(key string, value T) { // Fast path: update existing value if _, exists := rm.store.Load(key); exists {