influxdata / influxdata/telegraf
JSON_v2 parser enhancement: zip values from two different arrays
- Dominant language
- Go
- Stars
- 17.8k
- Forks
- 5.8k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 161
Description
There is a JSON style (albeit probably not an optimal one) that splits keys and values into separate arrays. A real world example is needing to pair keys in `"keys"` and values in `"values"` in the below JSON, such that the Line Protocol output gets pairs like `shortterm=0.83`:
_Note: it can be assumed that these will be ordered appropriately_
```
{
"keys": [
"shortterm",
"midterm",
"longterm"
],
"values": [
0.83,
1.76,
2.27
]
}
```
This is done in Starlark with `zip()` (snippet):
```
pairs = zip(dsnames, values)
for key,val in pairs:
if val == None:
val = float()
new_metric.fields[key] = val
```
Contributor guide
Research direction
Start by locating the JSON_v2 parser and its existing handling for arrays and field construction. Verify how ordered `keys` and `values` could be paired, then confirm completion by producing Line Protocol fields such as `shortterm=0.83` from the example input.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- data
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100