Hello. I am trying to get data in a deep nested json. All data. I have seen the test examples on GitHub but none of them has the context to get all data deep nested json files.
Example
{
trafficRegistrationPoints {
id
name
location {
roadLinkSequence {
roadLinkSequenceId
relativePosition
}
county {
name
}
municipality {
name
}
coordinates {
latLon {
lat
lon
}
}
roadReference {
shortForm
roadCategory {
id
}
}
roadReferenceHistory {
validFrom
validTo
meteringDirectionChanged
}
}
trafficRegistrationType
direction {
from
fromAccordingToMetering
to
toAccordingToMetering
}
commissions {
validFrom
validTo
lanes {
laneNumber
laneNumberAccordingToMetering
}
}
manualLabels {
validFrom
validTo
affectedLanes {
lane {
laneNumber
laneNumberAccordingToMetering
}
states
}
}
dataTimeSpan {
firstData
firstDataWithQualityMetrics
latestData {
volumeByHour
volumeByDay
volumeAverageDailyByMonth
volumeAverageDailyBySeason
volumeAverageDailyByYear
}
}
meteringDirectionChanged
operationalStatus
registrationFrequency
}
}
How do I get this to the line protocol influxdb requires, kindly. thanks.
Hello thanks for the reply. an example similar to mine is an examples on GitHub testdata links, the multiple_json_input example. under root.station object and #.etd.0.estimate.0.minutes. How can I convert it to get all minutes in each json file rather than first minute in each. I’ve tried #.etd.0.estimate.#.minutes and #.etd.#.estimate.#.minutes as object.field, object.fields, object.tag, and object.object but still no solution. thanks.
Both my editor and telegraf complains, that this is not valid json.
Maybe something went wrong during copy and paste?
Can you provide a full example of your data?
If it is too large for the forum, provide a download link or a github gist or similar.
Phew, this is a tough one.
I had no success either, so far.
The problem seems to be the arrays within the array.
They are ignored by the parser and i don’t know how to properly address them in the config
I agree that there is no example, that covers this use case.
Maybe someone form the developers can help? @jpowers
How would you want that in-line protocol to look? You said you wanted all the data, so I assume you want each element of that array to be in your final data like:
Since you mentioned getting these into line protocol, my first instinct with something like this is not to use Telegraf, but instead, to use my programming language of choice and the InfluxDB Client Libraries. The Telegraf JSON parsers are great for relatively simple data, but as soon as you get nested and complex data it becomes far too difficult to keep straight, let alone debug.
@Cyrus_Jomo
That would have been my next suggestion as well.
Before you waste many hours trying to configure the parser, I would have written the parser myself faster for such complicated data structures, either in an exec(d) or starlark plugin.