Fleet logo
Menu An icon indicating that interacting with this button will open the navigation menu.
Fleet logo An 'X' icon indicating that this can be interacted with to close the navigation menu.

Solutions

a small chevron
Device management

Device management

Remotely manage, and protect laptops and mobile devices.

Orchestration

Orchestration

Automate tasks across devices, from app installs to scripts.

Software management

Software management

Inventory, patch, and manage installed software.

Extend Fleet

Extend Fleet

Integrate your favorite tools with Fleet.


Customers

a small chevron
Fintech + Fleet

Stripe + Fleet

Stripe moved 10,000 Macs to Fleet, saving hundreds of thousands annually

Foursquare + Fleet

Foursquare + Fleet

Foursquare quickly migrates to Fleet for device management.

Faire + Fleet

Faire + Fleet

Faire secures Macs with CIS benchmarks and Fleet

What people are saying

What people are saying

Stories from the Fleet community.


Pricing

More

a small chevron
Docs

Docs

Guides

Guides

Support

Support

News

News

Get your license

Get your license

The handbook

The handbook

GitOps for device management

In-person workshop for beginners.

Join us
Get a demo Try it yourself
Solutions A small chevron
Device management

Device management

Remotely manage, and protect laptops and mobile devices.

Orchestration

Orchestration

Automate tasks across devices, from app installs to scripts.

Software management

Software management

Inventory, patch, and manage installed software.

Extend Fleet

Extend Fleet

Integrate your favorite tools with Fleet.

Customers A small chevron
Stripe + Fleet

Stripe + Fleet

Stripe moved 10,000 Macs to Fleet, saving hundreds of thousands annually

Foursquare + Fleet

Foursquare + Fleet

Foursquare cut costs and gained 114% ROI with Fleet

Faire + Fleet

Faire + Fleet

Faire secures Macs with CIS benchmarks and Fleet

What people are saying

What people are saying

Stories from the Fleet community.

Pricing
More A small chevron

GitOps for device management

In-person workshop for beginners.

Join us
Docs

Docs

Guides

Guides

Support

Support

News

News

Get your license

Get your license

The handbook

The handbook

Try it yourself Get a demo
{{categoryFriendlyName}}/
{{thisPage.meta.articleTitle}}
search

Locate device assets in the event of an emergency.

{{articleSubtitle}}

Last updated on |
The author's GitHub profile picture

Zach Wasserman

Share

Share this article on Hacker News Share this article on LinkedIn Share this article on Twitter

On this page

{{topic.title}}
Docs Docs REST API REST API Guides Guides Get a demoGet a demo
Suggest an editSuggest an edit

Locate device assets in the event of an emergency.

{{articleSubtitle}}

Last updated on | The author's GitHub profile picture

Zach Wasserman

Locate device assets in the event of an emergency.

A simple query for IP-Geolocation

Locate device assets in the event of an emergency

In the event of an emergency or public safety concern, osquery can be easily used to identify employees the direct vicinity, so that teams can push warnings or safety precautions to their staff.

This simple strategy for obtaining the location of an osquery device utilizes the ipapi.co API to retrieve the IP geolocation of the device. Note that the device must be able to connect to the internet over HTTP, and the calculated location may be skewed by VPN, proxies, etc.

Query:

SELECT JSON_EXTRACT(result, '$.ip') AS ip,
 JSON_EXTRACT(result, '$.city') AS city,
 JSON_EXTRACT(result, '$.region') AS region,
 JSON_EXTRACT(result, '$.country') AS country
FROM curl
WHERE url = 'http://ipapi.co/json';

Sample result:

+--------------+------------+------------+---------+
| ip           | city       | region     | country |
+--------------+------------+------------+---------+
| 71.92.162.65 | Sacramento | California | US      |
+--------------+------------+------------+---------+

Other techniques A common technique for geolocation of macOS devices with osquery is to use the wifi_survey table in combination with the Google Geolocation API. This strategy has become more difficult to use due to security controls introduced in macOS 10.15, and poses privacy concerns due to the precision of the location data returned by the API.

Fleet logo
Multi platform Device management Orchestration Software management Integrations Pricing
Documentation Support Docs API Release notes Get your license
Company About News Jobs Logos/artwork Why open source?
a small checkmarkSOC2 Type 2 Creative Commons Licence CC BY-SA 4.0
© 2025 Fleet Inc. Privacy
Slack logo GitHub logo LinkedIn logo X (Twitter) logo Youtube logo Mastadon logo