|
| 1 | +# Example - Logging to Influx |
| 2 | + |
| 3 | +Example of logging to influx using python, as well as how to setup influxdb and grafana. Drawn from http://richardn.ca/2019/01/04/installing-influxdb-on-windows/ |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +## Installing nssm |
| 8 | +nssm is the "non-sucking service manager", it is a valuable tool for creating, configuring, and deploying services on windows. It is simply a .exe that is downloaded and then added to the PATH before it can be used from the CLI (Command line interface). |
| 9 | + |
| 10 | +* Download here: https://nssm.cc/download |
| 11 | + |
| 12 | +* Make a directory in program files called nssm and move the nssm.exe there |
| 13 | +* Add C:/Program Files/nssm to your path |
| 14 | + * start -> "Edit system environment variables" -> environment variables path -> edit -> new -> path-to-nssm |
| 15 | + |
| 16 | +* In console, enter `nssm` to ensure it is installed correctly |
| 17 | + |
| 18 | + |
| 19 | +## Setting Up Influxdb |
| 20 | + |
| 21 | +### Windows |
| 22 | +Download the V1.7.9 windows binaries here: <https://portal.influxdata.com/downloads/> |
| 23 | + |
| 24 | +Extract the contents of the zip to a folder called `influxdb`, and place that folder in program files (doesnt really matter where - I just used program files) |
| 25 | + |
| 26 | +Create another directory anywhere you want to store the influx data, its recommended you do not place this folder within the same directory as the binaries. I called mine **`influx-data`** |
| 27 | + |
| 28 | +Edit the following fields in the influx.conf file within the unzipped folder |
| 29 | +* [meta] - dir: C:/Path to influx-data/meta |
| 30 | +* [data] - dir: C:/Path to influx-data/data |
| 31 | +* [data] - wal-dir: C:/Path to influx-data/wal |
| 32 | + |
| 33 | +Next, we have to configure influx to run as a service. |
| 34 | +In an admin console: |
| 35 | +* `nssm install` |
| 36 | +* Then configure the following settings with the correct paths (may differ from mine depending on where you put them) : |
| 37 | + * Path: c:\Program Files\influxdb\influxd.exe |
| 38 | + * Startup Directory: c:\Program Files\influxdb\ |
| 39 | + * Arguments: -config "C:\Program Files\Iinfluxdb\influxdb.conf" |
| 40 | + * Service Name: influxdb |
| 41 | + |
| 42 | +Finally, launch the service |
| 43 | +``` |
| 44 | +nssm start influxdb |
| 45 | +``` |
| 46 | + |
| 47 | +If all has gone well, go to http://localhost:8086/query\ |
| 48 | +And you should see something like: |
| 49 | +``` |
| 50 | +{"error":"missing required parameter \"q\""} |
| 51 | +``` |
| 52 | +You can now enter the influx interactive shell by navigating to the influxdb folder containing `influx.exe` and running it (enter `influx` in console or double click the exe) |
| 53 | + |
| 54 | + |
| 55 | +## Setting Up Grafana |
| 56 | +### Windows |
| 57 | +This pretty much describes everything you need to know in a concise and visual form, no need to reinvent the wheel. |
| 58 | +<https://devconnected.com/how-to-install-grafana-on-windows-8-10/> |
| 59 | + |
| 60 | +Note: It is not necessary to use a custom .ini, the defaults are fine for most use cases! There will be a config file for the production grafana server that we will use, however for personal dev environments the defaults are fine. |
| 61 | + |
| 62 | +After getting grafana running as a service, you can login and import the dashboard by uploading the ` dashboard.json` file in this directory. |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
0 commit comments