文档文档

OpenWeatherMap 输入插件

此插件从 OpenWeatherMap 服务收集天气和预报数据。

要使用此插件,您需要一个APP-ID才能工作。

发布于: Telegraf v1.11.0 标签: applications, web 操作系统支持: all

全局配置选项

插件支持其他全局和插件配置设置,用于修改指标、标签和字段,创建别名以及配置插件顺序等任务。更多详情请参阅 CONFIGURATION.md

配置

# Read current weather and forecasts data from openweathermap.org
[[inputs.openweathermap]]
  ## OpenWeatherMap API key.
  app_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

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

  ## Language of the description field. Can be one of "ar", "bg",
  ## "ca", "cz", "de", "el", "en", "fa", "fi", "fr", "gl", "hr", "hu",
  ## "it", "ja", "kr", "la", "lt", "mk", "nl", "pl", "pt", "ro", "ru",
  ## "se", "sk", "sl", "es", "tr", "ua", "vi", "zh_cn", "zh_tw"
  # lang = "en"

  ## 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".
  ## The default is "metric" if not specified.
  # units = "metric"

  ## Style to query the current weather; available options
  ##   batch      -- query multiple cities at once using the "group" endpoint
  ##   individual -- query each city individually using the "weather" endpoint
  ## You should use "individual" here as it is documented and provides more
  ## frequent updates. The default is "batch" for backward compatibility.
  # query_style = "batch"

  ## Query interval to fetch data.
  ## By default the global 'interval' setting is used. You should override the
  ## interval here if the global setting is shorter than 10 minutes as
  ## OpenWeatherMap weather data is only updated every 10 minutes.
  # interval = "10m"

城市标识符可以在 城市列表文件 中找到,或者您可以在 OpenWeatherMap 网站 上按名称搜索您的城市,并使用相应 URL 的最后一个数字元素。语言标识符可以在 API 文档 中找到。

Metrics

  • weather
    • 标签 (tags)
      • city_id
      • forecast
      • condition_id
      • condition_main
    • 字段 (fields)
      • cloudiness (int, percent)
      • humidity (int, percent)
      • pressure (float) - atmospheric pressure hPa
      • rain (float) - rain volume in mm for the last 1-3h (depending on API response)
      • snow (float) - snow volume in mm for the last 1-3h (depending on API response)
      • sunrise (int) - nanoseconds since unix epoch
      • sunset (int) - nanoseconds since unix epoch
      • temperature (float, degrees)
      • feels_like (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
      • condition_description (string, localized long description)
      • condition_icon

有关 condition ID、icon 和 main 的文档可以在 文档 中找到。

示例输出

weather,city=San\ Francisco,city_id=5391959,condition_id=803,condition_main=Clouds,country=US,forecast=114h,host=robot pressure=1027,temperature=10.09,wind_degrees=34,wind_speed=1.24,condition_description="broken clouds",cloudiness=80i,humidity=67i,rain=0,feels_like=8.9,condition_icon="04n" 1645952400000000000
weather,city=San\ Francisco,city_id=5391959,condition_id=804,condition_main=Clouds,country=US,forecast=117h,host=robot humidity=65i,rain=0,temperature=10.12,wind_degrees=31,cloudiness=90i,pressure=1026,feels_like=8.88,wind_speed=1.31,condition_description="overcast clouds",condition_icon="04n" 1645963200000000000
weather,city=San\ Francisco,city_id=5391959,condition_id=804,condition_main=Clouds,country=US,forecast=120h,host=robot cloudiness=100i,humidity=61i,rain=0,temperature=10.28,wind_speed=1.94,condition_icon="04d",pressure=1027,feels_like=8.96,wind_degrees=16,condition_description="overcast clouds" 1645974000000000000

此页面是否有帮助?

感谢您的反馈!


InfluxDB 3.8 新特性

InfluxDB 3.8 和 InfluxDB 3 Explorer 1.6 的主要增强功能。

查看博客文章

InfluxDB 3.8 现已适用于 Core 和 Enterprise 版本,同时发布了 InfluxDB 3 Explorer UI 的 1.6 版本。本次发布着重于操作成熟度,以及如何更轻松地部署、管理和可靠地运行 InfluxDB。

更多信息,请查看

InfluxDB Docker 的 latest 标签将指向 InfluxDB 3 Core

在 **2026 年 2 月 3 日**,InfluxDB Docker 镜像的 latest 标签将指向 InfluxDB 3 Core。为避免意外升级,请在您的 Docker 部署中使用特定的版本标签。

如果使用 Docker 来安装和运行 InfluxDB,latest 标签将指向 InfluxDB 3 Core。为避免意外升级,请在您的 Docker 部署中使用特定的版本标签。例如,如果使用 Docker 运行 InfluxDB v2,请将 latest 版本标签替换为 Docker pull 命令中的特定版本标签 — 例如

docker pull influxdb:2