OpenWeatherMap

OpenWeatherMap is an online service, owned by OpenWeather Ltd, that provides global weather data via API, including current weather data, forecasts, nowcasts and historical weather data for any geographical location. The company provides a minute-by-minute hyperlocal precipitation forecast for any location.

Available solutions




This template is for Zabbix version: 6.4
Also available for: 6.2 6.0

Source: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/app/openweathermap_http?at=release/6.4

OpenWeatherMap by HTTP

Overview

This template is designed for the effortless deployment of OpenWeatherMap monitoring by Zabbix via HTTP and doesn't require any external scripts.

Requirements

Zabbix version: 6.4 and higher.

Tested versions

This template has been tested on:

  • OpenWeatherMap API

Configuration

Zabbix should be configured according to the instructions in the Templates out of the box section.

Setup

  1. Create a host.

  2. Link the template to the host.

  3. Customize the values of {$OPENWEATHERMAP.API.TOKEN} and {$LOCATION} macros.
    OpenWeatherMap API Tokens are available in your OpenWeatherMap account https://home.openweathermap.org/api_keys.
    Locations can be set by few ways:

    • by geo coordinates (for example: 56.95,24.0833)
    • by location name (for example: Riga)
    • by location ID. Link to the list of city ID: http://bulk.openweathermap.org/sample/city.list.json.gz
    • by zip/post code with a country code (for example: 94040,us) A few locations can be added to the macro at the same time by | delimiter. For example: 43.81821,7.76115|Riga|2643743|94040,us. Please note that API requests by city name, zip-codes and city id will be deprecated soon.

    Language and units macros can be customized too if necessary. List of available languages: https://openweathermap.org/current#multi. Available units of measurement are: standard, metric and imperial https://openweathermap.org/current#data.

Macros used

Name Description Default
{$OPENWEATHERMAP.API.TOKEN}

Specify openweathermap API key.

{$LANG}

List of available languages https://openweathermap.org/current#multi.

en
{$LOCATION}

Locations can be set by few ways:

1. by geo coordinates (for example: 56.95,24.0833)

2. by location name (for example: Riga)

3. by location ID. Link to the list of city ID: http://bulk.openweathermap.org/sample/city.list.json.gz

4. by zip/post code with a country code (for example: 94040,us)

A few locations can be added to the macro at the same time by | delimiter.

For example: 43.81821,7.76115|Riga|2643743|94040,us.

Please note that API requests by city name, zip-codes and city id will be deprecated soon.

Riga
{$OPENWEATHERMAP.API.ENDPOINT}

OpenWeatherMap API endpoint.

api.openweathermap.org/data/2.5/weather?
{$UNITS}

Available units of measurement are standard, metric and imperial https://openweathermap.org/current#data.

metric
{$OPENWEATHERMAP.DATA.TIMEOUT}

Response timeout for OpenWeatherMap API.

3s
{$TEMP.CRIT.HIGH}

Threshold for high temperature trigger.

30
{$TEMP.CRIT.LOW}

Threshold for low temperature trigger.

-20

Items

Name Description Type Key and additional info
Openweathermap: Get data

JSON array with result of OpenWeatherMap API requests.

Script openweathermap.get.data
Openweathermap: Get data collection errors

Errors from get data requests by script item.

Dependent item openweathermap.get.errors

Preprocessing

  • JSON Path: $.errors

  • Discard unchanged with heartbeat: 1h

Triggers

Name Description Expression Severity Dependencies and additional info
Openweathermap: There are errors in requests to OpenWeatherMap API

Zabbix has received errors in requests to OpenWeatherMap API.

length(last(/OpenWeatherMap by HTTP/openweathermap.get.errors))>0 Average Manual close: Yes

LLD rule Locations discovery

Name Description Type Key and additional info
Locations discovery

Weather metrics discovery by location.

Dependent item openweathermap.locations.discovery

Preprocessing

  • JSON Path: $.data

  • Does not match regular expression: \[\]

    ⛔️Custom on fail: Set error to: Failed to receive data about required locations from API

  • Discard unchanged with heartbeat: 1h

Item prototypes for Locations discovery

Name Description Type Key and additional info
[{#LOCATION}, {#COUNTRY}]: Data

JSON with result of OpenWeatherMap API request by location.

Dependent item openweathermap.location.data[{#ID}]

Preprocessing

  • JSON Path: $.data.[?(@.id=='{#ID}')].first()

[{#LOCATION}, {#COUNTRY}]: Atmospheric pressure

Atmospheric pressure in Pa.

Dependent item openweathermap.pressure[{#ID}]

Preprocessing

  • JSON Path: $.main.pressure

  • Custom multiplier: 100

  • Discard unchanged with heartbeat: 1h

[{#LOCATION}, {#COUNTRY}]: Cloudiness

Cloudiness in %.

Dependent item openweathermap.clouds[{#ID}]

Preprocessing

  • JSON Path: $.clouds.all

  • Discard unchanged with heartbeat: 1h

[{#LOCATION}, {#COUNTRY}]: Humidity

Humidity in %.

Dependent item openweathermap.humidity[{#ID}]

Preprocessing

  • JSON Path: $.main.humidity

  • Discard unchanged with heartbeat: 1h

[{#LOCATION}, {#COUNTRY}]: Rain volume for the last one hour

Rain volume for the lat one hour in m.

Dependent item openweathermap.rain[{#ID}]

Preprocessing

  • JSON Path: $.rain.1h

    ⛔️Custom on fail: Set value to: 0

  • Custom multiplier: 0.001

  • Discard unchanged with heartbeat: 1h

[{#LOCATION}, {#COUNTRY}]: Short weather status

Short weather status description.

Dependent item openweathermap.description[{#ID}]

Preprocessing

  • JSON Path: $.weather..description.first()

  • Discard unchanged with heartbeat: 1h

[{#LOCATION}, {#COUNTRY}]: Snow volume for the last one hour

Snow volume for the lat one hour in m.

Dependent item openweathermap.snow[{#ID}]

Preprocessing

  • JSON Path: $.snow.1h

    ⛔️Custom on fail: Set value to: 0

  • Custom multiplier: 0.001

  • Discard unchanged with heartbeat: 1h

[{#LOCATION}, {#COUNTRY}]: Temperature

Atmospheric temperature value.

Dependent item openweathermap.temp[{#ID}]

Preprocessing

  • JSON Path: $.main.temp

  • Discard unchanged with heartbeat: 1h

[{#LOCATION}, {#COUNTRY}]: Visibility

Visibility in m.

Dependent item openweathermap.visibility[{#ID}]

Preprocessing

  • JSON Path: $.visibility

  • Discard unchanged with heartbeat: 1h

[{#LOCATION}, {#COUNTRY}]: Wind direction

Wind direction in degrees.

Dependent item openweathermap.wind.direction[{#ID}]

Preprocessing

  • JSON Path: $.wind.deg

  • Discard unchanged with heartbeat: 1h

[{#LOCATION}, {#COUNTRY}]: Wind speed

Wind speed value.

Dependent item openweathermap.wind.speed[{#ID}]

Preprocessing

  • JSON Path: $.wind.speed

  • Discard unchanged with heartbeat: 1h

Trigger prototypes for Locations discovery

Name Description Expression Severity Dependencies and additional info
[{#LOCATION}, {#COUNTRY}]: Temperature is too high

Temperature value is too high.

min(/OpenWeatherMap by HTTP/openweathermap.temp[{#ID}],#3)>{$TEMP.CRIT.HIGH} Average Manual close: Yes
[{#LOCATION}, {#COUNTRY}]: Temperature is too low

Temperature value is too low.

max(/OpenWeatherMap by HTTP/openweathermap.temp[{#ID}],#3)<{$TEMP.CRIT.LOW} Average Manual close: Yes

Feedback

Please report any issues with the template at https://support.zabbix.com

You can also provide feedback, discuss the template, or ask for help at ZABBIX forums

Articles and documentation

+ Propose new article

Didn't find integration you need?