Skip to content

Commit ec16b9e

Browse files
committed
ref: change AS_SET check and move "move_up" to python
1 parent 4d6387a commit ec16b9e

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

ris_live.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,14 @@ async def process(message):
3232
data = orjson.loads(message)
3333

3434
# as `path` may contain mixed data types Array(UInt32 | Array(Uint32)) (see https://ris-live.ripe.net/manual/)
35-
# check `path`` for AS_SET (the array in the array) and pop it into it's own key
36-
if "path" in data["data"]:
37-
for idx, i in enumerate(data["data"]["path"]):
38-
if type(i) == type(list()):
39-
data["data"]["path"].pop(int(idx))
40-
data["data"]["as_set"] = i
35+
# check `path` for AS_SET (the array in the array) and pop it into it's own key
36+
if "path" in data["data"] and data["data"]["path"]:
37+
if type(data["data"]["path"][-1]) == type(list()):
38+
data["data"]["as_set"] = data["data"]["path"][-1].copy()
39+
data["data"]["path"].pop()
4140

4241
# print and pipe into whatever
43-
print(orjson.dumps(data).decode("utf-8"))
42+
print(orjson.dumps(data["data"]).decode("utf-8"))
4443

4544

4645
if __name__ == "__main__":

vector/vector.toml.example

+2-9
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,11 @@ decoding.codec = "json"
55
[transforms.update_only]
66
type = "filter"
77
inputs = ["stdin"]
8-
condition = '.data.type == "UPDATE"'
9-
10-
[transforms.move_up]
11-
type = "remap"
12-
inputs = ["update_only"]
13-
source = """
14-
. = .data
15-
"""
8+
condition = '.type == "UPDATE"'
169

1710
[sinks.clickhouse_http]
1811
type = "http"
19-
inputs = ["move_up"]
12+
inputs = ["update_only"]
2013
encoding.codec = "json"
2114
uri = "http://localhost:8123/?query=INSERT%20INTO%20bgp.ris_live_queue%20%28data%29%20FORMAT%20JSONAsString"
2215
auth.strategy = "basic"

0 commit comments

Comments
 (0)