JSON Settings
the following collectors can be configured to read values from mqtt collector docid\ ggnqijhlxifoimbt yp2crest api collector docid\ sybxzdwwtncpai2hqdusc this page explains the settings that control how a json payload is parsed the settings that are not specific to json are documented on the collector pages listed above collector json settings ignorejsonpatherrors description the ignorejsonpatherrors setting determines whether errors in jsonpath expressions should be logged or not use ignorejsonpatherrors = false if your json structure should always contain specific fields, and you want to log missing or malformed jsonpath expressions use ignorejsonpatherrors = true if your json format is dynamic and you expect some fields to be missing errors resulting from missing paths or invalid expressions are ignored the setting does not cover statuspath an error there is always swallowed and the point falls back to status good , whichever value you choose required no default false measurement json settings the measurement settings reflect the configuration possibilities for mapping a json message the values are extracted from the messages using jsonpath jsonpath documentation can be found in the jsonpath specification https //goessner net/articles/jsonpath/ , and jsonpath com https //jsonpath com is a useful tool to test jsonpath expressions a path ending in is a factry extension the suffix is stripped, the path is evaluated, and the keys of the resulting json object are extracted use it to read object keys rather than values the path expressions can either yield a single value, or a list of values the expressions for the timestamp(s), status(es), and tags and values have to either yield the same amount of results as the expression for the measurement(s), or only a single value, in which case that single value will be used for all found measurements topic description the topic to listen to when the topic is specified here, it will override the topic that was set in the collector only used by the mqtt collector required no measurementpath description the json path that leads to a value, or a list of values in the message required yes timestamppath description the jsonpath that leads to a timestamp, or a list of timestamps in the message required no if empty the collector's timestamp will be assigned to data points statuspath description the json path that leads to a status, or a list of statuses in the message if not set, status will default to ‘good’ required no tagnamesandtagvaluepaths description map describing tags, where keys are the tag names, and the values are the json paths of the tag values required no timestamplayout description a timestamp layout is used to correctly interpret the resulting timestamp(s) from the timestamppath a list of available timestamp formats, along with their string representations, can be found in the golang time package documentation https //pkg go dev/time#layout required no if empty the default rfc3339 timestamplayout e g 2006 01 02t15 04 05z07 00 is used for timestamps in unix format, one of the following values can be used unix (time in s), unixmillis (time in ms), unixmicros (time in μs), or unixnanos (time in ns) for other timestamp formats, see the examples docid\ rkukkrd4ariwfqk96lqy5 below warning the measurement timestamplayout setting overrides the collector's timestamplayout setting timestamp layout examples timestamp in json message timestamplayout 2024 03 31t14 30 00z 2006 01 02t15 04 05z07 00 2024 03 31t14 30 00 +02 00 2006 01 02t15 04 05z07 00 1711895400 unix 1711895400123 unixmillis custom timestamp layout examples timestamp in json message timestamplayout 31 03 2024 14 30 00 123 02 01 2006 15 04 05 000 sunday, 31 mar 2024 14 30 00 utc monday, 02 jan 2006 15 04 05 mst custom timestamp layouts allow flexibility for different timestamp representations you can define them according to your needs using go’s time layout reference here https //pkg go dev/time#layout important if your timestamps use a different structure, make sure to adjust the timestamp layout accordingly next steps to learn how to read data from a response using the json settings see read data from json docid\ rkukkrd4ariwfqk96lqy5