Use the HTTP input plugin

    Configure influxdb output plugin to write metrics to your InfluxDB 2.2 instance.

    To retrieve data from the Citi Bike URL endpoint, enable the inputs.http input plugin in your Telegraf configuration file.

    Specify the following options:

    One or more URLs to read metrics from. For this example, use https://gbfs.citibikenyc.com/gbfs/en/station_status.json.

    Specify the following JSON-specific options.

    json_query

    To parse only the relevant portion of JSON data, set the json_query option with a GJSON path. The result of the query should contain a JSON object or an array of objects. In this case, we don’t want to parse the JSON query’s executionTime at the beginning of the data, so we’ll limit this to include only the data in the stationBeanList array.

    tag_keys

    List of one or more JSON keys that should be added as tags. For this example, we’ll use the tag keys id, stationName, city, and postalCode.

    json_string_fields

    List the keys of fields that are in string format so that they can be parsed as strings. Here, the string fields are , stAddress1, stAddress2, location, and landMark.

    json_time_key

    json_time_format

    The format used to interpret the designated json_time_key. This example uses . For example, Mon Jan 2 15:04:05 MST 2006.

    json_timezone

    The timezone We’ll set this to the Unix TZ value where our bike data takes place, .

    Example configuration

    Start the Telegraf service.

    To test that the data is being sent to InfluxDB, run the following (replacing telegraf.conf with the path to your configuration file):

    Now, you can explore and query the Citi Bike data in InfluxDB.