Documentation
Golbat
Configuration

Golbat Configuration

Golbat reads its settings from a TOML file. Every key has a built-in default, so you only need to set what you want to change. Start from config.toml.example (opens in a new tab) in the repository and add keys from this page as needed.

The Default column below is the value Golbat uses when the key is missing from your file. The example config sometimes sets a different value; where that matters it is called out.

Loading the config

  • Golbat reads config.toml from its working directory. Use -c / --config to load a different file:
    ./golbat --config /etc/golbat/config.toml
    The default config.toml is optional. A file passed with --config must exist.
  • Environment variables override the file. The name is GOLBAT. followed by the upper-cased key path, for example GOLBAT.DATABASE.ADDRESS or GOLBAT.CLEANUP.STATION_BATTLES. Array-of-table sections take an index: GOLBAT.WEBHOOKS.0.URL, GOLBAT.SCAN_RULES.1.CONTEXT. See docker-compose.yml.example (opens in a new tab) for a full example.

Root section

port = 9001
#grpc_port = 50001
raw_bearer = ""
api_secret = "golbat"
pokemon_memory_only = true
KeyDefaultDescription
port0HTTP listening port for /raw and the API. The example uses 9001.
grpc_port0 (off)gRPC listening port. Serves both raw ingest and the gRPC query API.
raw_bearer""When set, /raw requires Authorization: Bearer <raw_bearer>.
api_secret""When set, API calls require the X-Golbat-Secret header (gRPC: x-golbat-secret metadata). Empty disables the check.
api_docstrueServes interactive API docs at /docs plus /openapi.json and /schemas. These never require the API secret.
pokemon_memory_onlyfalseStop writing Pokémon to the pokemon table. Golbat always tracks Pokémon in memory and serves them over the API, so most setups enable this (the example config does).
preserve_pokemonfalseWith pokemon_memory_only, save the in-memory Pokémon to the database on shutdown and restore them on startup.
pokemon_internal_to_dbfalseWrite the internal scan-history blob to the database for encountered Pokémon.
store_usernamefalseStore the reporting account on the Pokémon row. When off, Pokémon webhooks report the account that triggered the save, and saves without one carry "username": null.
preloadfalseLoad forts, stations and recent spawnpoints into cache at startup. Faster first responses, longer startup.
fort_in_memoryfalseKeep forts in an in-memory spatial index. Required for the fort scan and available API endpoints (they return 503 without it). Experimental.

Koji section

[koji]
url = "http://{koji_url}/api/v1/geofence/feature-collection/{golbat_project}"
bearer_token = "secret"
KeyDefaultDescription
url""Koji feature-collection endpoint for the geofences Golbat uses for area stats, webhook areas and scan rules.
bearer_token""Koji bearer token.

Without a Koji URL, Golbat reads geojson/geofence.json instead. Koji results are cached in cache/koji_geofence.json and used if Koji is unreachable at startup. Reload geofences without restarting via /api/reload-geojson.

Cleanup section

[cleanup]
pokemon = true
incidents = true
station_battles = true
quests = true
tappables = true
stats = true
stats_days = 7
device_hours = 24
KeyDefaultDescription
pokemontrueRemove expired Pokémon from the pokemon table (only relevant when Pokémon are written to the database).
incidentstrueRemove expired invasions.
station_battlestrueRemove expired max battles.
queststrueRemove expired quests.
tappablestrueRemove expired tappables.
statsfalsePrune statistics tables older than stats_days. The example config enables it.
stats_days7Days to keep in pokemon_stats, pokemon_shiny_stats, pokemon_iv_stats, pokemon_hundo_stats, pokemon_nundo_stats, invasion_stats, quest_stats and raid_stats.
device_hours24Forget devices not seen for this many hours.
forts_stale_threshold3600Seconds before a fort missing from cell scans is considered stale and removed.
forts_min_miss_count1Consecutive cell scans a fort must be missing from before it can be considered stale.

Logging section

[logging]
debug = false
save_logs = true
max_size = 50
max_backups = 10
max_age = 30
compress = true
KeyDefaultDescription
debugfalseDebug logging.
api_request_loggingfalseLog raw request and response bodies of all /api endpoints. Very large; enable only while debugging a client.
save_logsfalseWrite logs to logs/. The example config enables it.
max_size50Log file size in MB before rotation.
max_backups10Rotated files to keep.
max_age30Days to keep rotated files.
compresstrueGzip rotated files.

Database section

[database]
user = ""
password = ""
address = "127.0.0.1:3306"
db = ""
max_pool = 100
KeyDefaultDescription
user""Database user.
password""Database password.
address""host:port of the database.
db""Database (schema) name.
max_pool100Maximum connections in the pool.

Golbat supports MariaDB (MySQL may work but is not tested) and creates and migrates its tables automatically on startup. See Database.

PvP section

[pvp]
enabled = true
include_hundos_under_cap = false
level_caps = [50, 51]
#ranking_comparator = "prefer_higher_cp"
KeyDefaultDescription
enabledfalseCalculate PvP rankings for encountered Pokémon.
include_hundos_under_capfalseInclude 100% IV Pokémon below the level cap in rankings.
level_caps[50, 51]Level caps used in rankings.
ranking_comparator""Empty uses tied rankings (1, 1, 3, 4). prefer_higher_cp or prefer_lower_cp break ties (1, 2, 3, 4), matching external calculators.

See PvP.

Weather section

[weather]
proactive_iv_switching = true
proactive_iv_switching_to_db = false
KeyDefaultDescription
proactive_iv_switchingtrueWhen a cell's weather changes, update the IVs of Pokémon in that cell for the new boost state without waiting for a rescan.
proactive_iv_switching_to_dbfalseAlso write those changes to the database.

Both can be overridden per area or scanner mode with scan rules.

Scan rules

⭐ Advanced option ⭐

Scan rules change which game objects Golbat processes, either globally, for specific areas, or for specific scanner modes (context). Rules are checked in order and the first matching rule applies. Keys you leave out keep their normal behaviour.

KeyDescription
areasGeofence names the rule applies to ("Parent/Name", "Parent/*" or "Name").
contextScanner modes the rule applies to. Dragonite sends Fort, Pokemon, Quest, Scout and RarePokemon. Matching ignores case.
pokemonAny Pokémon processing (also disables spawnpoints).
wild_pokemonWild Pokémon from the GMO.
nearby_pokemonNearby Pokémon at a pokestop.
nearby_cell_pokemonNearby Pokémon without a pokestop, placed at the S2 cell centre. Off unless a rule sets it to true; nearby_pokemon does not enable it.
weatherWeather from the GMO.
cellsCell updates. Disabling this also disables automatic removal of stale forts.
pokestopsPokestops from the GMO.
gymsGyms from the GMO.
stationsPower spot stations from the GMO.
tappablesTappables.
proactive_iv_switchingOverride the [weather] setting for matching data.
proactive_iv_switching_to_dbOverride the [weather] setting for matching data.

A global rule: drop Pokémon without IVs from the GMO and nearby Pokémon.

[[scan_rules]]
wild_pokemon = false
nearby_pokemon = false

Per area and per mode: the main area skips nearby Pokémon, everything from Scout mode is processed, and no Pokémon are processed anywhere else.

[[scan_rules]]
areas = ["MainArea"]
nearby_pokemon = false
 
[[scan_rules]]
context = ["Scout"]
 
[[scan_rules]]
pokemon = false

Per mode only:

[[scan_rules]]
context = ["Quest"]
 
[[scan_rules]]
context = ["Fort"]
pokemon = false
 
[[scan_rules]]
context = ["Pokemon"]
nearby_pokemon = false

Under heavy load, disabling nearby_pokemon saves a lot of processing.

Webhooks section

Add one [[webhooks]] block per destination.

[[webhooks]]
url = "http://localhost:4201"
types = ["pokemon_iv", "raid", "quest"]
 
[[webhooks]]
url = "http://localhost:4202"
types = ["raid"]
areas = ["London/*", "*/Harrow"]
exclude_areas = ["London/Westminster"]
headers = ["X-Poracle-Secret:abc"]
KeyDefaultDescription
urlDestination URL.
typesallWebhook types to send: pokemon, pokemon_iv, pokemon_no_iv, gym, raid, quest, pokestop, invasion, weather, fort_update, max_battle, tappable, raid_lobby, max_battle_lobby.
areasallOnly send messages from these areas.
exclude_areasnoneNever send messages from these areas. Exclusion wins over areas.
headersnoneExtra HTTP headers as "Name:value" strings. The value cannot contain another :.

pokemon covers both pokemon_iv (all three IVs known) and pokemon_no_iv (IVs not known yet). See Webhooks for payloads and when each type fires.

Prometheus section

[prometheus]
enabled = true
token = ""
KeyDefaultDescription
enabledfalseServe metrics at /metrics.
token""When set, /metrics requires Authorization: Bearer <token>.
bucket_size[.00005 … 10]Histogram buckets in seconds.
live_statsfalsePeriodically query the database and export current gym, raid and invasion counts.
live_stats_sleep120Seconds between live stats updates.

See Prometheus.

Stats intervals section

[stats_intervals]
pokemon_stats_interval_minutes = 1
pokemon_count_interval_minutes = 10
raid_stats_interval_minutes = 10
invasion_stats_interval_minutes = 15
quest_stats_interval_minutes = 15

How often the statistics tables are written, in minutes. The defaults are shown above.

Tuning section

⭐ Advanced option ⭐ The defaults suit most installs.

KeyDefaultDescription
max_pokemon_results3000Maximum Pokémon returned per API scan.
max_pokemon_distance100Maximum diagonal of a Pokémon scan area, in km.
max_fort_results9000Maximum gyms, pokestops or stations returned per fort scan.
max_tappable_results9000Maximum tappables returned per scan.
extended_timeoutfalseRaise the per-proto processing timeout from 5 s to 30 s.
reduce_updatesfalseWrite unchanged forts every 12 hours instead of every 15 minutes, and spawnpoint last_seen every 12 hours instead of 6. Reduces database load.
max_concurrent_proactive_iv_switch6Parallel cells processed on weather changes.
write_behind_startup_delay120Seconds after startup during which database writes are only queued.
write_behind_worker_count16Maximum parallel batch writers. Raise only if write latency grows in steady state.
write_behind_batch_size50Rows per batch write.
write_behind_batch_timeout100Milliseconds to wait before flushing a partial batch.
raw_processing_concurrency0Concurrent raw decoders. 0 = 4× CPUs (max 96), -1 = unlimited.
raw_processing_queue_factor0Decode queue size as a multiple of the concurrency limit. 0 = 32. When full, requests are dropped.
s2_cell_lookupfalsePrecompute geofence lookups per S2 cell. About 7× faster matching for about 60× the geofence file size in memory.
slow_db_query_ms0Log [DB_SLOW] for queries slower than this. 0 = 1000 ms, -1 = off.
gogc_percent0Go GC target (Go default 100). Higher values use more memory and less CPU. 0 leaves Go's default.
go_mem_limit_mib0Soft memory limit in MiB. 0 = off. Useful as a backstop when raising gogc_percent.
profile_routesfalseEnable /debug/pprof endpoints.
profile_contentionfalseCollect block and mutex profiles. Has a performance cost.

Pyroscope section

Continuous profiling with Pyroscope (opens in a new tab).

KeyDefaultDescription
server_address""Pyroscope server. Empty disables profiling.
application_name"golbat"Application name in Pyroscope.
basic_auth_user""Basic auth user.
basic_auth_password""Basic auth password.
loggerfalseLog Pyroscope client output.
mutex_profile_fraction5Mutex profile sampling.
block_profile_rate5Block profile sampling.