openweathermap

package
v0.0.0-...-535192b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2019 License: MIT Imports: 13 Imported by: 0

README

OpenWeatherMap Input Plugin

Collect current weather and forecast data from OpenWeatherMap.

To use this plugin you will need an api key (app_id).

City identifiers can be found in the city list. Alternately you can search by name; the city_id can be found as the last digits of the URL: https://openweathermap.org/city/2643743

Configuration
[[inputs.openweathermap]]
  ## OpenWeatherMap API key.
  app_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

  ## City ID's to collect weather data from.
  city_id = ["5391959"]

  ## APIs to fetch; can contain "weather" or "forecast".
  fetch = ["weather", "forecast"]

  ## OpenWeatherMap base URL
  # base_url = "https://api.openweathermap.org/"

  ## Timeout for HTTP response.
  # response_timeout = "5s"

  ## Preferred unit system for temperature and wind speed. Can be one of
  ## "metric", "imperial", or "standard".
  # units = "metric"

  ## Query interval; OpenWeatherMap weather data is updated every 10
  ## minutes.
  interval = "10m"
Metrics
  • weather
    • tags:
      • city_id
      • forecast
    • fields:
      • cloudiness (int, percent)
      • humidity (int, percent)
      • pressure (float, atmospheric pressure hPa)
      • rain (float, rain volume for the last 3 hours in mm)
      • sunrise (int, nanoseconds since unix epoch)
      • sunset (int, nanoseconds since unix epoch)
      • temperature (float, degrees)
      • visibility (int, meters, not available on forecast data)
      • wind_degrees (float, wind direction in degrees)
      • wind_speed (float, wind speed in meters/sec or miles/sec)
Example Output
> weather,city=San\ Francisco,city_id=5391959,country=US,forecast=* cloudiness=40i,humidity=72i,pressure=1013,rain=0,sunrise=1559220629000000000i,sunset=1559273058000000000i,temperature=13.31,visibility=16093i,wind_degrees=280,wind_speed=4.6 1559268695000000000
> weather,city=San\ Francisco,city_id=5391959,country=US,forecast=3h cloudiness=0i,humidity=86i,pressure=1012.03,rain=0,temperature=10.69,wind_degrees=222.855,wind_speed=2.76 1559271600000000000
> weather,city=San\ Francisco,city_id=5391959,country=US,forecast=6h cloudiness=11i,humidity=93i,pressure=1012.79,rain=0,temperature=9.34,wind_degrees=212.685,wind_speed=1.85 1559282400000000000

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OpenWeatherMap

type OpenWeatherMap struct {
	AppId           string            `toml:"app_id"`
	CityId          []string          `toml:"city_id"`
	Fetch           []string          `toml:"fetch"`
	BaseUrl         string            `toml:"base_url"`
	ResponseTimeout internal.Duration `toml:"response_timeout"`
	Units           string            `toml:"units"`
	// contains filtered or unexported fields
}

func (*OpenWeatherMap) Description

func (n *OpenWeatherMap) Description() string

func (*OpenWeatherMap) Gather

func (n *OpenWeatherMap) Gather(acc telegraf.Accumulator) error

func (*OpenWeatherMap) SampleConfig

func (n *OpenWeatherMap) SampleConfig() string

type Status

type Status struct {
	City struct {
		Coord struct {
			Lat float64 `json:"lat"`
			Lon float64 `json:"lon"`
		} `json:"coord"`
		Country string `json:"country"`
		Id      int64  `json:"id"`
		Name    string `json:"name"`
	} `json:"city"`
	List []WeatherEntry `json:"list"`
}

type WeatherEntry

type WeatherEntry struct {
	Dt     int64 `json:"dt"`
	Clouds struct {
		All int64 `json:"all"`
	} `json:"clouds"`
	Main struct {
		Humidity int64   `json:"humidity"`
		Pressure float64 `json:"pressure"`
		Temp     float64 `json:"temp"`
	} `json:"main"`
	Rain struct {
		Rain3 float64 `json:"3h"`
	} `json:"rain"`
	Sys struct {
		Country string `json:"country"`
		Sunrise int64  `json:"sunrise"`
		Sunset  int64  `json:"sunset"`
	} `json:"sys"`
	Wind struct {
		Deg   float64 `json:"deg"`
		Speed float64 `json:"speed"`
	} `json:"wind"`
	Id    int64  `json:"id"`
	Name  string `json:"name"`
	Coord struct {
		Lat float64 `json:"lat"`
		Lon float64 `json:"lon"`
	} `json:"coord"`
	Visibility int64 `json:"visibility"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL