Skip to content

Latest commit

 

History

History
105 lines (64 loc) · 4.78 KB

DEVELOPMENT.md

File metadata and controls

105 lines (64 loc) · 4.78 KB

Local Development and Writing Code for Influxdb

Table of Contents

Quickstart

Docker

We've provided make targets that provide an "interactive" development experience using Docker.

make dshell

This command builds a development container image and puts you inside a container with all the tooling you require to develop and build InfluxDB. You can use the "Local" instructions once inside this container and work on the premise that you have everything installed.

Other container runtimes should work, but we've only tested with Docker and Podman (alias docker=podman).

Local

Assuming you have Go 1.13, Node LTS, and yarn installed, and some means of ingesting data locally (e.g. telegraf):

You'll need two terminal tabs to run influxdb from source: one to run the go application server, the other to run the development server that will listen for front-end changes, rebuild the bundle, serve the new bundle, then reload your webpage for you.

Tab 1:

go run ./cmd/influxd --assets-path=ui/build

Tab 2:

cd ui
yarn && yarn start

If there are no errors, hit localhost:8080 and follow the prompts to setup your username and password. Note the port difference: 8080 vs the production 8086

You're set up to develop Influx locally. Any changes you make to front-end code under the ui/ directory will be updated after the watcher process (that was initiated by running yarn start) sees them and rebuilds the bundle. Any changes to go code will need to be re-compiled by re-running the go run command above.

See Getting some Graphs for next steps.

Full-Length Guide

To get started with Influx, you'll need to install these tools if you don't already have them:

  1. Install go
  2. Install nodejs
  3. Install yarn

Yarn is a package manager for nodejs and an alternative to npm.

To run Influx locally, you'll need two terminal tabs: one to run the go application server, the other to run the development server that will listen for front-end changes, rebuild the bundle, serve the new bundle, then reload your webpage for you.

Tab 1:

go run ./cmd/influxd --assets-path=ui/build

This starts the influxdb application server. It handles API requests and can be reached via localhost:8086. Any changes to go code will need to be re-compiled by re-running the go run command above.

Tab 2:

cd ui
yarn install
yarn start

This installs front-end dependencies and starts the front-end build server. It will listen to changes to TypeScript and JavaScript files, rebuild the front-end bundle, serve that bundle, then auto reload any pages with changes. If everything went smoothly without errors, you should be able to go to localhost:8080. and follow the prompts to login or to setup your username and password.

If you're setting things up for the first time, be sure to check out the the official getting started guide to get make sure you configure everything properly.

Testing Changes

To make sure everything got wired up properly, we'll want to make a minor change on the frontend and see that it's added.

Add a newline and following log statement to the entry point to the app:

console.log('hello, world!')

Your browser should reload the page after you save your changes (sometimes this happens quickly and is hard to spot). Open your browser console and you should see your message after the page reloads.

Getting some Graphs

If you haven't set up telegraf yet, following the official telegraf documentation is the quickest and most straightforward and hassle-free way of getting some data into your local instance. The documentation there will be kept fresher and and more current than this tutorial.

Learning how to input Line protocol data is a great tool if you need to debug with arbitrary adhoc data. Check out a quick intro to the Line protocol, and learn how to input it via the ui. Since we're running influxd locally, you can skip step 1.

Getting Help

If you get stuck, the following resources might help: