json数据格式

ckocjqey  于 2021-07-15  发布在  Kafka
关注(0)|答案(0)|浏览(363)

我必须处理来自kafka的json数据并将其存储到一个xdb bucket中,我想使用telegraf连接器来实现这一点。然而,考虑到json数据的奇怪结构,我不明白如何做到这一点。下面是此类数据的一个示例:

{
    "v": "2.2",
    "r": [{
        "d": "IBA001",
        "u": "LowFrequencySampler",
        "s": [{
            "m": ["IRMS-AE-1", "IRMS-AE-2", "IRMS-AE-3", "IRMS-AE-4", "IRMS-AH-1", "IRMS-AH-2", "IRMS-AH-3", "IRMS-AH-4", "VRMS-AE-VT1", "VRMS-AE-VT2", "WATT-AE-1", "WATT-AE-2", "WATT-AE-3", "WATT-AE-4", "WATT-AH-1", "WATT-AH-2", "WATT-AH-3", "WATT-AH-4", "VAR-AE-1", "VAR-AE-2", "VAR-AE-3", "VAR-AE-4", "VAR-AH-1", "VAR-AH-2", "VAR-AH-3", "VAR-AH-4", "VA-AE-1", "VA-AE-2", "VA-AE-3", "VA-AE-4", "VA-AH-1", "VA-AH-2", "VA-AH-3", "VA-AH-4", "THD-AE-1", "THD-AE-2", "THD-AE-3", "THD-AE-4", "THD-AH-1", "THD-AH-2", "THD-AH-3", "THD-AH-4", "THD-AE-VT1", "THD-AE-VT2", "PF-AE-1", "PF-AE-2", "PF-AE-3", "PF-AE-4", "PF-AH-1", "PF-AH-2", "PF-AH-3", "PF-AH-4"],
            "t": "float",
            "s": {
                "@type": "array",
                "v": [
                    [20.18846, 21.02329, 33.39281, 20.41747, 4.764703, 4.472236, 0, 0, 25051.09, 25051.09, 322762.8, 342534.9, 656503.3, 336749, 95009.87, 92406.12, 0, 0, 389350.4, 400028.1, 518433.7, 384965, 72220.56, 63307.15, 0, 0, 505743, 526656.1, 836526.3, 511479.8, 119361, 112034.4, 0, 0, 6.514048, 6.288249, 7.584458, 6.183965, 14.40868, 15.38503, 0, 0, 1.644895, 1.639531, 0.6381919, 0.6503779, 0.7847961, 0.6583645, 0.7959343, 0.8248615, 0, 0]
                ],
                "t": ["2021-03-03T16:11:22.9511963Z"]
            }
        }]
    }]
}

我的目标是“解压”数组中的所有不同元素,并将它们链接到设备名称和时间戳(即单个值),以便获得类似以下内容的输出:

IBA001, IRMS-AE-1, 20.18846, 2021-03-03T16:11:22.9511963Z
IBA001, IRMS-AE-2, 21.02329, 2021-03-03T16:11:22.9511963Z
IBA001, IRMS-AE-3, 33.39281, 2021-03-03T16:11:22.9511963Z
...

我怎么办?我真的不明白如何配置.config文件来获得这样的结构。
欢迎任何帮助,谢谢!

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题