Provided by: Adam Silverman
This InfluxDB template uses the United States Geological Survey (USGS) web service to monitor earthquakes around the world. The dashboard displays earthquakes that can be filtered based on magnitude
, location
, location radius
(km or miles), and time
.
Feed consumption is performed within an automated task so it is entirely serverless when run within InfluxDB Cloud. Telegraf, client libraries and the CLI are not required. Additional data cleansing and shaping operations are performed using Flux. [1]
Slacks alerts are sent via a task, with customizable options such as separate magnitude thresholds for global and regional earthquakes, time zones, and delayed triggering. Links to the associated USGS earthquake summary and Google Maps pages are listed as well. [2]
There are two template types:
- Map visualization dashboard cell, supported on InfluxDB Cloud
- No map visualization, supported on OSS (or InfluxDB Cloud)
In the InfluxDB UI, go to Settings->Templates and enter this URL
InfluxDB Cloud (with map visualization): https://raw.githubusercontent.com/influxdata/community-templates/master/earthquake_usgs/earthquake_usgs_cloud_template.yml
InfluxDB OSS (without map visualization): https://raw.githubusercontent.com/influxdata/community-templates/master/earthquake_usgs/earthquake_usgs_template.yml
Although the CLI is not required, if you have your InfluxDB credentials configured in the CLI, you can install this template with
InfluxDB Cloud (with map visualization):
influx apply -u https://raw.githubusercontent.com/influxdata/community-templates/master/earthquake_usgs/earthquake_usgs_cloud_template.yml
InfluxDB OSS (without map visualization):
influx apply -u https://raw.githubusercontent.com/influxdata/community-templates/master/earthquake_usgs/earthquake_usgs_template.yml
- 1 Bucket:
apis
, 30d retention - 1 Label:
Earthquake
- 2 Tasks:
Earthquake Feed Ingestion
,Earthquake Alerts
- 1 Dashboard:
Earthquake Command Center
- 4 Variables:
Magnitude_Threshold
,Location
,Radius
, andUnits
General instructions on using InfluxDB Templates can be found in the use a template document.
The Earthquake Alerts
task is disabled by default since it requires a valid Slack webhook to send alerts.
Edit the task to update the webhook:
slack_webhook = https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
The dashboard features the following locations to filter on:
- Hilo, Hawaii
- Los Angeles, California
- Oklahoma City, Oklahoma
- San Francisco, California
- Tokyo, Japan
- World
Additonal locations (with coordinates) can be added in the InfluxDB UI Settings->Variables->Location
variable. Geographic coordinates can be found by entering the city in Google Maps.
Location emojis used in the dashboard are stored in a Flux dictionary:
globe_dictionary = dict.fromList(pairs: [
{key: "Hilo, HI", value: "🌋"},
{key: "Los Angeles, CA", value: "🏖️"},
{key: "Oklahoma City, OK", value: "🌪️"},
{key: "San Francisco, CA", value: "🌉"},
{key: "Tokyo, Japan", value: "🗾"}
])
From USGS FAQ: "earthquakes smaller than 5.0 outside the U.S. [may not be recorded] unless they have caused significant damage or are widely felt (earthquakes this small rarely cause significant damage)"
Task options may be configured as well:
global_mag_threshold
- Default:
6
- Options:
0
,1
,2
,3
,4
,5
,6
,7
,8
,9
,10
- Minimum earthquake magnitude to trigger an alert for a global earthquake
- Default:
regional_mag_threshold
- Default:
3
- Options:
0
,1
,2
,3
,4
,5
,6
,7
,8
,9
,10
- Minimum earthquake magnitude to trigger an alert for a regional earthquake
- Default:
units
- Default:
miles
- Options:
miles
,km
- Unit to display earthquake depth and distance
- Default:
tz
- Default:
PST
- Options:
UTC
,EST
,EDT
,CST
,PST
,PDT
- Timezone to display earthquake event
- Default:
city
- Default:
San Francisco:37.7576948:-122.4726194
- City and geographic coordinates to alert for regional earthquakes (separated by colons)
- Default:
city_radius
- Default:
1000.0
- Radius of city area
- Default:
alert_delay_min
- Default:
5
- Delay (minutes) before sending alert
- From USGS FAQ: "trade off between the speed of earthquake notifications and number of false alarms."
- Default:
Before ingestion, the following data cleansing and data shaping operatons are performed:
- Data Cleansing
- Drop fields
- Remove 0 kilometer distances from location string
- Generate and standardize new country field based on location string
- Specify tags
- Data Shaping (for Flux Geo package)
- Add S2 cell ID tokens
- Rename geographic coordinate fields
The web service feed is:
https://earthquake.usgs.gov/fdsnws/event/1/query?format=csv&starttime=" + onedayago + "&includedeleted=true&orderby=time-asc
Note that the USGS web service query parameters include:
format=csv
- CSV format
starttime=$onedayago
- Existing earthquake events may be updated later with more accurate details
includedeleted=true
- Include earthquake events that have been removed
orderby=time-asc
- Order earthquake events by ascending time
The fields are listed in ComCat Documentation - Event Terms
Author: Adam Silverman
Email: asilverman@influxdata.com
Github: @abalone23
Influx Slack: @Adam2