Skip to content

Commit a9e1036

Browse files
authored
Adjust metadata (#20)
* Remove version and tool * Use agent_uuid as raw.Metadata.UUID * Set raw.Metadata.TracerouteCallerVersion to NULL * Use hash as raw.Metadata.CachedUUID * Set parse.Time to NULL * Set raw.Tracelb.type to tracelb * Testing & Validation - Verified pipeline integrity on the server. - Verified correctness of field values.
1 parent 4615faf commit a9e1036

File tree

2 files changed

+15
-28
lines changed

2 files changed

+15
-28
lines changed

db/iris_to_mlab.sql

+12-17
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ DECLARE
1515
measurement_agent STRING DEFAULT @measurement_agent_param;
1616
DECLARE
1717
hostname STRING DEFAULT @host_param;
18-
DECLARE
19-
version STRING DEFAULT @version_param;
20-
DECLARE
21-
tool STRING DEFAULT @tool_param;
2218
DECLARE
2319
start_time STRING DEFAULT @start_time_param;
20+
DECLARE
21+
agent_uuid STRING DEFAULT @agent_uuid_param;
2422
DECLARE
2523
min_ttl STRING DEFAULT @min_ttl_param;
2624
DECLARE
@@ -122,7 +120,7 @@ links AS (
122120
scamper1.id = '%s' AND
123121
scamper1.raw.CycleStart.Hostname = '%s' AND
124122
-- Check for duplicate rows
125-
scamper1.raw.Metadata.UUID = near.sha256
123+
scamper1.raw.Metadata.CachedUUID = near.sha256
126124
)
127125
),
128126
@@ -175,7 +173,7 @@ SELECT
175173
'%s' AS id, -- measurement_uuid AS id
176174
STRUCT(
177175
CAST(NULL AS STRING) AS Version,
178-
CURRENT_TIMESTAMP() AS Time,
176+
CAST(NULL AS TIMESTAMP) AS Time,
179177
CAST(NULL AS STRING) AS ArchiveURL,
180178
CAST(NULL AS STRING) AS Filename,
181179
CAST(NULL AS INT64) AS Priority,
@@ -184,10 +182,10 @@ SELECT
184182
DATE(TIMESTAMP('%s')) AS date,
185183
STRUCT(
186184
STRUCT(
187-
ANY_VALUE(sha256) AS UUID, -- Propagate SHA256 from the previous CTE
188-
'%s' AS TracerouteCallerVersion,
185+
'%s' AS UUID, -- agent UUID
186+
CAST(NULL AS STRING) AS TracerouteCallerVersion,
189187
CAST(NULL AS BOOLEAN) AS CachedResult,
190-
CAST(NULL AS STRING) AS CachedUUID
188+
ANY_VALUE(sha256) AS CachedUUID -- Propagate SHA256 from the previous CTE
191189
) AS Metadata,
192190
STRUCT(
193191
'cycle-start' AS Type,
@@ -197,10 +195,7 @@ SELECT
197195
UNIX_SECONDS(MIN(first_timestamp)) AS start_time
198196
) AS CycleStart,
199197
STRUCT(
200-
CASE
201-
WHEN '%s'='diamond-miner' THEN 'MDA'
202-
ELSE CAST(NULL AS STRING)
203-
END AS type, -- TODO: case when tool is yarrp
198+
'tracelb' AS type,
204199
CAST(NULL AS STRING) AS version,
205200
CAST(NULL AS INT64) AS userid,
206201
'icmp-echo' AS method,
@@ -226,10 +221,10 @@ SELECT
226221
AND probe_dst_addr = lbn.probe_dst_addr
227222
) AS linkc,
228223
ARRAY_AGG(STRUCT(
229-
GENERATE_UUID() AS hop_id,
224+
GENERATE_UUID() AS hop_id,
230225
COALESCE(near_addr, '*') AS addr,
231-
CAST(NULL AS STRING) AS name, -- Not applicable
232-
NULL AS q_ttl, -- Not applicable
226+
CAST(NULL AS STRING) AS name, -- Not applicable
227+
CAST(NULL AS INT64) AS q_ttl, -- Not applicable
233228
(
234229
SELECT COUNT(DISTINCT CONCAT(near_addr, '|', far_addr))
235230
FROM links
@@ -251,6 +246,6 @@ SELECT
251246
) AS raw
252247
FROM links_by_node lbn
253248
GROUP BY probe_protocol, probe_src_addr, probe_dst_addr
254-
""", scamper1_table, measurement_agent, table_name, scamper1_table, measurement_uuid, hostname, measurement_uuid, start_time, version, hostname, tool, min_ttl, failure_probability, hostname);
249+
""", scamper1_table, measurement_agent, table_name, scamper1_table, measurement_uuid, hostname, measurement_uuid, start_time, agent_uuid, hostname, min_ttl, failure_probability, hostname);
255250
EXECUTE IMMEDIATE
256251
convert_iris_to_scamper1;

tools/upload_tables.sh

+3-11
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ convert_and_insert_values() {
146146
local bq_tmp_table="$3"
147147
local agent
148148
local index
149-
local tool
150149
local start_time
151150
local md_fields
152151
local MD_FIELDS=()
@@ -162,17 +161,11 @@ convert_and_insert_values() {
162161
fi
163162
done
164163

165-
tool="$(jq -r .tool "${meas_md_tmpfile}")"
166164
start_time="$(jq -r .start_time "${meas_md_tmpfile}")"
167-
# sanity check
168-
if [[ "${tool}" != "diamond-miner" && "${tool}" != "yarrp" ]]; then
169-
echo "error: invalid tool: ${tool}"
170-
return 1
171-
fi
172165
# order of these fields should match --parameter lines in the bq command below
173166
MD_FIELDS=(
167+
.agent_uuid
174168
.agent_parameters.hostname
175-
.agent_parameters.version
176169
.agent_parameters.min_ttl
177170
.tool_parameters.failure_probability
178171
)
@@ -190,10 +183,9 @@ convert_and_insert_values() {
190183
--parameter="measurement_uuid_param:STRING:${meas_uuid}" \
191184
--parameter="table_name_param:STRING:${bq_tmp_table}" \
192185
--parameter="measurement_agent_param:STRING:${bq_tmp_table#*__}" \
193-
--parameter="tool_param:STRING:${tool}" \
194186
--parameter="start_time_param:STRING:${start_time}" \
195-
--parameter="host_param:STRING:${MD_VALUES[0]}" \
196-
--parameter="version_param:STRING:${MD_VALUES[1]}" \
187+
--parameter="agent_uuid_param:STRING:${MD_VALUES[0]}" \
188+
--parameter="host_param:STRING:${MD_VALUES[1]}" \
197189
--parameter="min_ttl_param:STRING:${MD_VALUES[2]}" \
198190
--parameter="failure_probability_param:STRING:${MD_VALUES[3]}" \
199191
< "${TABLE_CONVERSION_QUERY}"

0 commit comments

Comments
 (0)