I fear this is not directly possible because XPath does not support list-zipping… However, you can use the starlark processor to achieve your goal:
[[inputs.file]]
files = ["test_configs/jsontest_forum_mabnz.json"]
data_format = "xpath_json"
xpath_native_types = true
[[inputs.file.xpath]]
metric_name = "'mymetric'"
metric_selection = "/INA3221"
timestamp = "/Time"
timestamp_format = "2006-01-02T15:04:05"
field_selection = "*/*"
[inputs.file.xpath.tags]
id = "Id"
[[processors.starlark]]
source = '''
def apply(metric):
# Split the fields into field-name part and index
fields = [(k.rsplit("_", 1), v) for (k,v) in metric.fields.items()]
# Get a field list with elements in format (index, field-name, value) for
# grouping the data by index.
fields = [(int(x[0][1]), x[0][0], x[1]) for x in fields]
# Get indices and iterate over those to collect the data per metric
indices = list(set([i for i,_,_ in fields]))
# Create the new metrics after grouping the fields
results = list()
for idx in indices:
f = {k: v for i, k, v in fields if i == idx}
m = Metric(metric.name, tags=metric.tags, fields=f)
m.tags["index"] = str(idx)
m.time = metric.time
results.append(m)
return results
'''