Using the HTTP input plugin with Citi Bike data

This example walks through using the Telegraf HTTP input plugin to collect live metrics on Citi Bike stations in New York City. Live station data is available in JSON format directly from Citi Bike.

For the following example to work, configure influxdb_v2 output plugin. This plugin is what allows Telegraf to write the metrics to InfluxDB.

Configure the HTTP Input plugin in your Telegraf configuration file

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


The format of the data in the HTTP endpoints that Telegraf will ingest. For this example, use JSON.

Add parser information to your Telegraf configuration

Specify the following JSON-specific options. In this example, we use the objects subtable to gather data from JSON Objects.



To parse a JSON object, set the path option with a GJSON path. The result of the query should contain a JSON object or an array of objects. The GJSON playground is a very helpful tool in checking your query.


List of one or more JSON keys that should be added as tags. For this example, we’ll use the tag key station_id.


Key from the JSON file that creates the timestamp metric. In this case, we want to use the time that station data was last reported, or the last_reported. If you don’t specify a key, the time that Telegraf reads the data becomes the timestamp.


The format used to interpret the designated timestamp_key. The last_reported time in this example is reported in unix format.

Example configuration

# URL for NYC's Citi Bike station data in JSON format
urls = [""]

# Overwrite measurement name from default `http` to `citibikenyc`
name_override = "citibike"

# Exclude url and host items from tags
tagexclude = ["url", "host"]

# Data from HTTP in JSON format
data_format = "json_v2"

      # Add a subtable to use the `json_v2` parser

          # Add an object subtable for to parse a JSON object

              # Parse data in `data.stations` path only
              path = "data.stations"

              #Set station metadata as tags
              tags = ["station_id"]

              # Latest station information reported at `last_reported`
              timestamp_key = "last_reported"

              # Time is reported in unix timestamp format
              timestamp_format = "unix"

Start Telegraf and verify data appears

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):

telegraf -config ~/telegraf.conf -test

This command should return line protocol that looks similar to the following:

citibike,station_id=4703 eightd_has_available_keys=false,is_installed=1,is_renting=1,is_returning=1,legacy_id="4703",num_bikes_available=6,num_bikes_disabled=2,num_docks_available=26,num_docks_disabled=0,num_ebikes_available=0,station_status="active" 1641505084000000000
citibike,station_id=4704 eightd_has_available_keys=false,is_installed=1,is_renting=1,is_returning=1,legacy_id="4704",num_bikes_available=10,num_bikes_disabled=2,num_docks_available=36,num_docks_disabled=0,num_ebikes_available=0,station_status="active" 1641505084000000000
citibike,station_id=4711 eightd_has_available_keys=false,is_installed=1,is_renting=1,is_returning=1,legacy_id="4711",num_bikes_available=9,num_bikes_disabled=0,num_docks_available=36,num_docks_disabled=0,num_ebikes_available=1,station_status="active" 1641505084000000000

Now, you can explore and query the Citi Bike data in InfluxDB. The example below is an Flux query and visualization showing the number of available bikes over the past 15 minutes.

Citi Bike visualization

Was this page helpful?

Thank you for your feedback!

The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Flux is going into maintenance mode and will not be supported in InfluxDB 3.0. This was a decision based on the broad demand for SQL and the continued growth and adoption of InfluxQL. We are continuing to support Flux for users in 1.x and 2.x so you can continue using it with no changes to your code. If you are interested in transitioning to InfluxDB 3.0 and want to future-proof your code, we suggest using InfluxQL.

For information about the future of Flux, see the following: