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.2
Also available for: 6.0

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

OpenWeatherMap by HTTP

Overview

For Zabbix version: 6.2 and higher
Get weather metrics from OpenWeatherMap current weather API by HTTP. It works without any external scripts and uses the Script item.

Setup

See Zabbix template operation for basic instructions.

  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.

Zabbix configuration

No specific Zabbix configuration is required.

Macros used

Name Description Default
{$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?
{$OPENWEATHERMAP.API.TOKEN}

Specify openweathermap API key.

``
{$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
{$UNITS}

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

metric

Template links

There are no template links in this template.

Discovery rules

Name Description Type Key and additional info
Locations discovery

Weather metrics discovery by location.

DEPENDENT openweathermap.locations.discovery

Preprocessing:

- JSONPATH: $.data

- NOT_MATCHES_REGEX: \[\]

- DISCARD_UNCHANGED_HEARTBEAT: 1h

Items collected

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

JSON with result of OpenWeatherMap API request by location.

DEPENDENT openweathermap.location.data[{#ID}]

Preprocessing:

- JSONPATH: $.data.[?(@.id=='{#ID}')].first()

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

Atmospheric pressure in Pa.

DEPENDENT openweathermap.pressure[{#ID}]

Preprocessing:

- JSONPATH: $.main.pressure

- MULTIPLIER: 100

- DISCARD_UNCHANGED_HEARTBEAT: 1h

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

Cloudiness in %.

DEPENDENT openweathermap.clouds[{#ID}]

Preprocessing:

- JSONPATH: $.clouds.all

- DISCARD_UNCHANGED_HEARTBEAT: 1h

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

Humidity in %.

DEPENDENT openweathermap.humidity[{#ID}]

Preprocessing:

- JSONPATH: $.main.humidity

- DISCARD_UNCHANGED_HEARTBEAT: 1h

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

Rain volume for the lat one hour in m.

DEPENDENT openweathermap.rain[{#ID}]

Preprocessing:

- JSONPATH: $.rain.1h

⛔️ON_FAIL: CUSTOM_VALUE -> 0

- MULTIPLIER: 0.001

- DISCARD_UNCHANGED_HEARTBEAT: 1h

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

Short weather status description.

DEPENDENT openweathermap.description[{#ID}]

Preprocessing:

- JSONPATH: $.weather..description.first()

- DISCARD_UNCHANGED_HEARTBEAT: 1h

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

Snow volume for the lat one hour in m.

DEPENDENT openweathermap.snow[{#ID}]

Preprocessing:

- JSONPATH: $.snow.1h

⛔️ON_FAIL: CUSTOM_VALUE -> 0

- MULTIPLIER: 0.001

- DISCARD_UNCHANGED_HEARTBEAT: 1h

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

Atmospheric temperature value.

DEPENDENT openweathermap.temp[{#ID}]

Preprocessing:

- JSONPATH: $.main.temp

- DISCARD_UNCHANGED_HEARTBEAT: 1h

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

Visibility in m.

DEPENDENT openweathermap.visibility[{#ID}]

Preprocessing:

- JSONPATH: $.visibility

- DISCARD_UNCHANGED_HEARTBEAT: 1h

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

Wind direction in degrees.

DEPENDENT openweathermap.wind.direction[{#ID}]

Preprocessing:

- JSONPATH: $.wind.deg

- DISCARD_UNCHANGED_HEARTBEAT: 1h

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

Wind speed value.

DEPENDENT openweathermap.wind.speed[{#ID}]

Preprocessing:

- JSONPATH: $.wind.speed

- DISCARD_UNCHANGED_HEARTBEAT: 1h

Zabbix raw items Openweathermap: Get data

JSON array with result of OpenWeatherMap API requests.

SCRIPT openweathermap.get.data

Expression:

The text is too long. Please see the template.
Zabbix raw items Openweathermap: Get data collection errors

Errors from get data requests by script item.

DEPENDENT openweathermap.get.errors

Preprocessing:

- JSONPATH: $.errors

- DISCARD_UNCHANGED_HEARTBEAT: 1h

Triggers

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

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

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 with it at ZABBIX forums.

Articles and documentation

+ Propose new article

Sie können die Integration nicht finden, die Sie benötigen?