Documentation

使用笔记本规范化数据

了解如何创建一个规范化数据的笔记本。 数据规范化是修改或清理数据的过程,以使其更易于处理。例如,包括将数值调整为统一的尺度和修改字符串。

通过下面的示例来创建一个查询 NOAA NDBC 示例数据的笔记本,将基于度的风向标准化为基本方向,然后将标准化数据写入一个存储桶。

  1. 创建一个新笔记本

  2. 构建查询单元格中:

    1. In the FROM column under Sample, select NOAA National Buoy Data.
    2. In the next FILTER column, select _measurement from the drop-down list and select the ndbc measurement in the list of measurements.
    3. In the next FILTER column, select _field from the drop-down list, and select the wind_dir_degt field from the list of fields.
  3. 在您的 构建查询 单元格之后点击 以添加一个新单元格并选择 Flux 脚本.

  4. 在Flux脚本单元中:

    1. 定义一个自定义函数 (cardinalDir()),该函数将数值度数转换为方位方向(北、北东北、东北等)。

    2. 使用 __PREVIOUS_RESULT__ 将上一个笔记本单元格的输出加载到Flux脚本中。

    3. 使用 map() 遍历每一行输入,更新字段键为 wind_dir_cardinal,并使用自定义 cardinalDir() 函数将 _value 列规范化为一个方位。

    import "array"
    
    cardinalDir = (d) => {
        _cardinal = if d >= 348.7 or d < 11.25 then "N"
        else if d >= 11.25 and d < 33.75 then "NNE"
        else if d >= 33.75 and d < 56.25 then "NE"
        else if d >= 56.25 and d < 78.75 then "ENE"
        else if d >= 78.75 and d < 101.25 then "E"
        else if d >= 101.25 and d < 123.75 then "ESE"
        else if d >= 123.75 and d < 146.25 then "SE"
        else if d >= 146.25 and d < 168.75 then "SSE"
        else if d >= 168.75 and d < 191.25 then "S"
        else if d >= 191.25 and d < 213.75 then "SSW"
        else if d >= 213.75 and d < 236.25 then "SW"
        else if d >= 236.25 and d < 258.75 then "WSW"
        else if d >= 258.75 and d < 281.25 then "W"
        else if d >= 281.25 and d < 303.75 then "WNW"
        else if d >= 303.75 and d < 326.25 then "NW"
        else if d >= 326.25 and d < 348.75 then "NNW"
        else ""
    
        return _cardinal
    }
    
    __PREVIOUS_RESULT__
        |> map(fn: (r) => ({r with
            _field: "wind_dir_cardinal",
            _value: cardinalDir(d: r._value),
        }))
    
  5. 点击 在你的 Flux Script 单元格之后,添加一个新单元格并选择 输出到存储桶。从 选择存储桶 下拉列表中选择一个存储桶。

  6. (可选) 点击 并选择 注释 来添加一个包含有关此笔记本功能的注释的单元格。例如,该单元格可能会说:“此笔记本将十进制度风向值转换为方位方向。”

  7. 点击 预览 在左上角以验证您的笔记本是否运行并预览输出。

  8. 点击 运行 来运行笔记本并将规范化的数据写入您的存储桶。

持续运行一个笔记本

要持续运行您的笔记本,请将笔记本导出为任务:

  1. 点击 添加一个新单元格,然后选择 任务.

  2. 提供以下内容:

    • 每个: 任务应运行的时间间隔。
    • 偏移量: (可选) 在定义的时间间隔后等待的时间以执行任务。 这允许任务捕获迟到的数据。
  3. 点击 导出为任务



Flux的未来

Flux 正在进入维护模式。您可以像现在一样继续使用它,而无需对您的代码进行任何更改。

阅读更多

InfluxDB 3 开源版本现已公开Alpha测试

InfluxDB 3 Open Source is now available for alpha testing, licensed under MIT or Apache 2 licensing.

我们将发布两个产品作为测试版的一部分。

InfluxDB 3 核心,是我们新的开源产品。 它是一个用于时间序列和事件数据的实时数据引擎。 InfluxDB 3 企业版是建立在核心基础之上的商业版本,增加了历史查询能力、读取副本、高可用性、可扩展性和细粒度安全性。

有关如何开始的更多信息,请查看: