Self-hosting InfluxDB + Grafana

In this section we outline how you can deploy and host InfluxDB and Grafana on your own PC. We use Windows Docker Desktop in the guide, but the principles are similar on Linux. We recommend going through the cloud based guide before trying the below.

Note

Self-hosting of InfluxDB and Grafana is outside the scope of our support. This guide serves purely as a starting point



Install via Windows Docker Desktop

You can also install via Docker, though we only recommend this if you have experience with this.

  1. Download and install Docker Desktop
  2. Access Docker Desktop via the whale icon in the taskbar
  3. In Settings/General, enable “Start Docker Desktop when you log in”
  4. Open your command prompt and enter the below to start InfluxDB and Grafana:
docker network create influxdb
docker run -d --net=influxdb --name=grafana -p 3000:3000 grafana/grafana
docker run -d --net=influxdb --name=influxdb -p 8086:8086 --volume C:/influxdb:/var/lib/influxdb2 influxdb:2.0.8

Setup your InfluxDB instance

  1. Open http://localhost:8086 to manage your instance via your browser
  2. Fill out the basic ‘get started’ details and make sure to store your login details
  3. Create a new bucket via Data/Buckets
  4. Note down your Organization Id from your URL (similar to the cloud setup)
  5. Create a new API token and store this

Setup Grafana

  1. Open Grafana via http://localhost:3000.
  2. In Grafana/Data Sources add InfluxDB with below settings (Flux query language):
URL: http://influxdb:8086
Organization: <your_influxdb_org_id>
Token: <your_influxdb_token>
Default bucket: <your_influxdb_bucket_name>

Update the Python script

If you run the Python dashboard writer script from the same PC as you’re hosting the instances, you can use the below details to push data to your self-hosted InfluxDB instance:

influx_bucket = <your_influxdb_bucket_name>
token = <your_influxdb_token>
influx_url = "http://localhost:8086"
org_id = <your_influxdb_org_id>

Once you’ve pushed the data, you can verify that you’re able to see the data in Grafana by setting up a panel as described in the separate guide.


Additional documentation

In practice, you may want to only self-host InfluxDB and then expose port 8086 externally to allow access from the free Grafana Cloud. For more details on setting up InfluxDB and Grafana, we recommend the official documentation from Grafana and InfluxDB.