Skip to content

Latest commit

 

History

History

earthquake_usgs

Earthquake Command Center

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]

Dashboard Earthquake Monitoring Dashboard

Quick Install

There are two template types:

InfluxDB UI

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

Influx CLI

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

Included Resources

  • 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, and Units

Setup Instructions

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

Customizations

Dashboard

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)"

Tasks

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
  • 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
  • units
    • Default: miles
    • Options: miles, km
    • Unit to display earthquake depth and distance
  • tz
    • Default: PST
    • Options: UTC, EST, EDT, CST, PST, PDT
    • Timezone to display earthquake event
  • city
    • Default: San Francisco:37.7576948:-122.4726194
    • City and geographic coordinates to alert for regional earthquakes (separated by colons)
  • city_radius
    • Default: 1000.0
    • Radius of city area
  • 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."

Additional Notes

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)

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

Contact

Author: Adam Silverman

Email: asilverman@influxdata.com

Github: @abalone23

Influx Slack: @Adam2