• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
InfluxDB - Time series database under Windows
#1
Information 
Influx Data Time Series DB - InfluxDB


Installing InfluxDB on Windows

  1. Download InfluxDB runtime on the downloads page
    Open the link and cklick on the v1.*.* InfluxDB download button.

       

    In my case i use the following folder as my root directory: "c:\Program Files\InfluxDB"

  2. Extract the downloaded ZIP file
    There are no installers, all what you need is inside the ZIP file.       
    Create a folder called "executables" and extract the downloaded "influx.1.*.*_windows_amd64.zip" Zfile into the folder.

  3. Configure Influx DB
    We need to edit the "influxdb.conf" before we can execute InfluxDB.
    Create a folder called "data".
    This folder contains all the data that needs to be backed up. It will make upgading and backups easier.

    Change the META dir
    Open the file "influxdb.conf" and locate the tag "[meta]".
    Chage the "meta" directory:

    [ meta ] # Where the metadata/raft database is storeddir = "C:/Program Files/InfluxDB/data/meta"
  4. Change the DATA + WAL dir
    Locate the tag "[data]" and change the directories:

    [data]  # The directory where the TSM storage engine stores TSM files.  dir = "C:/Program Files/InfluxDB/data/data"...wal-dir = "C:/Program Files/InfluxDB/data/wal"
  5. Enable  HTTP endpoint
    Locate the tag "[data]" and change the directories:

    [http]# Determines whether HTTP endpoint is enabled.  enabled = true
  6. First run - Test the configuration

    Run the "influxd.exe" from the installation directory.

    If there are no errors in the started console, you can call a browser and navigate to "http://localhost:8086/query".

    All is fine, if the broser shows this message:
                                "{"error":"missing required parameter \"q\""}"

    Now the InfluxDB is running on your Windows PC.
    Here is an example Node-RED flow to create a database, delete, write value and read a value (consider to adapt the ip address settings to your local setup).

       
Code:
[{"id":"e1c52c5c.35463","type":"influxdb in","z":"107486a2.b32cb9","influxdb":"e68b7284.a1c8e","name":"CREATE DATABASE \"MyTest\"","query":"CREATE DATABASE MyTest","rawOutput":false,"precision":"","retentionPolicy":"","x":470,"y":600,"wires":[["e684ccca.27276"]]},{"id":"28c1de74.db3b62","type":"inject","z":"107486a2.b32cb9","name":"trigger","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":600,"wires":[["e1c52c5c.35463"]]},{"id":"e684ccca.27276","type":"debug","z":"107486a2.b32cb9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":690,"y":600,"wires":[]},{"id":"87f33759.13b298","type":"influxdb in","z":"107486a2.b32cb9","influxdb":"e68b7284.a1c8e","name":"DROP DATABASE \"MyTest\"","query":"DROP DATABASE MyTest","rawOutput":false,"precision":"","retentionPolicy":"","x":460,"y":700,"wires":[["ebc6df4c.c19d8"]]},{"id":"ebc6df4c.c19d8","type":"debug","z":"107486a2.b32cb9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":690,"y":700,"wires":[]},{"id":"65e4d10d.7aaf4","type":"influxdb in","z":"107486a2.b32cb9","influxdb":"e68b7284.a1c8e","name":"READ DATABASE","query":"SELECT value FROM myValue WHERE time > now() - 1h limit 1000;","rawOutput":false,"precision":"","retentionPolicy":"","x":430,"y":980,"wires":[["28aaeafe.920e76"]]},{"id":"28aaeafe.920e76","type":"debug","z":"107486a2.b32cb9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":690,"y":980,"wires":[]},{"id":"3427ec2d.332094","type":"inject","z":"107486a2.b32cb9","name":"trigger","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":700,"wires":[["87f33759.13b298"]]},{"id":"dfae07c1.b5a168","type":"inject","z":"107486a2.b32cb9","name":"write 0","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":800,"wires":[["71893c52.24f9f4"]]},{"id":"bcf61aaf.421348","type":"inject","z":"107486a2.b32cb9","name":"read from database","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":980,"wires":[["65e4d10d.7aaf4"]]},{"id":"6c43917c.d18bb","type":"comment","z":"107486a2.b32cb9","name":"Create a database","info":"","x":190,"y":560,"wires":[]},{"id":"e3d1d544.7e2388","type":"comment","z":"107486a2.b32cb9","name":"Delete a database","info":"","x":190,"y":660,"wires":[]},{"id":"b8e862e1.14967","type":"comment","z":"107486a2.b32cb9","name":"Write a value","info":"","x":170,"y":760,"wires":[]},{"id":"5795be2a.21b6d","type":"inject","z":"107486a2.b32cb9","name":"write 50","topic":"","payload":"50","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":840,"wires":[["71893c52.24f9f4"]]},{"id":"77ba500f.3c23b","type":"inject","z":"107486a2.b32cb9","name":"write 99","topic":"","payload":"99","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":880,"wires":[["71893c52.24f9f4"]]},{"id":"594532ee.6fec6c","type":"comment","z":"107486a2.b32cb9","name":"Read from database (return last 5 min)","info":"","x":250,"y":940,"wires":[]},{"id":"71893c52.24f9f4","type":"influxdb out","z":"107486a2.b32cb9","influxdb":"e68b7284.a1c8e","name":"Write value","measurement":"myValue","precision":"","retentionPolicy":"","x":410,"y":840,"wires":[]},{"id":"e68b7284.a1c8e","type":"influxdb","z":"","hostname":"10.11.5.52","port":"8086","protocol":"http","database":"MyTest","name":"","usetls":false,"tls":""}]
#2
I have extended the Patricks Node-RED flow by adding of a retention policy that instructs InfluxDB to keep the data stored for just 1 hour and then delete it. This prevents the database from getting infinitely large.

Code:
[{"id":"f78c897a.d454a8","type":"inject","z":"f5487ba0.0254f8","name":"set name \"MyTest\"","props":[{"p":"name","v":"MyTest","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":150,"y":100,"wires":[["b5b20513.1fab28"]]},{"id":"7892b299.bd5024","type":"inject","z":"f5487ba0.0254f8","name":"write \"myValue\" 0","props":[{"p":"payload"},{"p":"measurement","v":"myValue","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":140,"y":340,"wires":[["4a2324b5.4e70d4"]]},{"id":"270b8cd1.2fc59c","type":"inject","z":"f5487ba0.0254f8","name":"read \"myValue\", last 1h","props":[{"p":"measurement","v":"myValue","vt":"str"},{"p":"time","v":"1h","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":160,"y":500,"wires":[["8d3267f1.8cff"]]},{"id":"786ea798.df844","type":"comment","z":"f5487ba0.0254f8","name":"Create a database","info":"","x":130,"y":60,"wires":[]},{"id":"bd027800.af72f8","type":"comment","z":"f5487ba0.0254f8","name":"Delete a database","info":"","x":130,"y":220,"wires":[]},{"id":"929084f2.12f618","type":"comment","z":"f5487ba0.0254f8","name":"Write single value","info":"","x":120,"y":300,"wires":[]},{"id":"d48a0602.97048","type":"inject","z":"f5487ba0.0254f8","name":"write \"myValue\" 50","props":[{"p":"payload"},{"p":"measurement","v":"myValue","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"50","payloadType":"num","x":150,"y":380,"wires":[["4a2324b5.4e70d4"]]},{"id":"94830d6.07bd97","type":"comment","z":"f5487ba0.0254f8","name":"Read single value","info":"","x":130,"y":460,"wires":[]},{"id":"4a2324b5.4e70d4","type":"influxdb out","z":"f5487ba0.0254f8","influxdb":"e68b7284.a1c8e","name":"","measurement":"","precision":"","retentionPolicy":"","database":"","retentionPolicyV18Flux":"","org":"","bucket":"","x":800,"y":380,"wires":[]},{"id":"9c57c99b.38a048","type":"influxdb in","z":"f5487ba0.0254f8","influxdb":"e68b7284.a1c8e","name":"","query":"","rawOutput":false,"precision":"","retentionPolicy":"","org":"","x":810,"y":100,"wires":[["250801b7.22831e"]]},{"id":"832ae8e7.ef6698","type":"inject","z":"f5487ba0.0254f8","name":"set retention 1 hour","props":[{"p":"time","v":"1h","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":150,"y":180,"wires":[["9bb71bf4.147b38"]]},{"id":"250801b7.22831e","type":"debug","z":"f5487ba0.0254f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1030,"y":100,"wires":[]},{"id":"f5679d56.aca85","type":"comment","z":"f5487ba0.0254f8","name":"Set retention (optional)","info":"","x":140,"y":140,"wires":[]},{"id":"4430c83.7d1da38","type":"inject","z":"f5487ba0.0254f8","name":"write \"myValue\" timestamp","props":[{"p":"payload"},{"p":"measurement","v":"myValue","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":420,"wires":[["4a2324b5.4e70d4"]]},{"id":"a6d4ce75.e7de7","type":"catch","z":"f5487ba0.0254f8","name":"InfluxDB errors","scope":["178f825d.a11556","e794be16.79845","7ef6289e.8beaf","4a2324b5.4e70d4","9c57c99b.38a048","cee15196.68942","1c9634dc.6a29ab","bdf8c4fa.f1f8f8","748a06bd.675ed8"],"uncaught":false,"x":120,"y":760,"wires":[["5d7a3b51.aeb9e4"]]},{"id":"5d7a3b51.aeb9e4","type":"debug","z":"f5487ba0.0254f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":750,"y":760,"wires":[]},{"id":"748a06bd.675ed8","type":"influxdb batch","z":"f5487ba0.0254f8","influxdb":"e68b7284.a1c8e","precision":"","retentionPolicy":"","name":"","x":800,"y":580,"wires":[]},{"id":"bb5375a3.9309b8","type":"inject","z":"f5487ba0.0254f8","name":"trigger","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":110,"y":580,"wires":[["e67da851.7277f8"]]},{"id":"e67da851.7277f8","type":"function","z":"f5487ba0.0254f8","name":"multiple measurement points","func":"msg.payload = [\n    {\n        measurement: \"weather_sensor\",\n        fields: {\n            temp: 5.5,\n            light: 678,\n            humidity: 51\n        },\n        tags:{\n            location:\"garden\"\n        },\n        timestamp: new Date()\n    },\n    {\n        measurement: \"alarm_sensor\",\n        fields: {\n            proximity: 999,\n            temp: 19.5\n        },\n        tags:{\n            location:\"home\"\n        },\n        timestamp: new Date()\n    }\n];\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":460,"y":580,"wires":[["748a06bd.675ed8"]]},{"id":"6f7bef2c.8b301","type":"comment","z":"f5487ba0.0254f8","name":"Write multiple values","info":"","x":130,"y":540,"wires":[]},{"id":"eb5e0872.464518","type":"comment","z":"f5487ba0.0254f8","name":"Catch all errors","info":"","x":120,"y":720,"wires":[]},{"id":"8d3267f1.8cff","type":"template","z":"f5487ba0.0254f8","name":"query SELECT ... FROM","field":"query","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"SELECT value FROM {{measurement}} WHERE time > now() - {{time}} limit 1000;","output":"str","x":450,"y":500,"wires":[["9c57c99b.38a048"]]},{"id":"9bb71bf4.147b38","type":"template","z":"f5487ba0.0254f8","name":"query CREATE RETENTION","field":"query","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"CREATE RETENTION POLICY MyPolicy ON MyTest DURATION {{time}} REPLICATION 1 DEFAULT","output":"str","x":460,"y":180,"wires":[["9c57c99b.38a048"]]},{"id":"b5b20513.1fab28","type":"template","z":"f5487ba0.0254f8","name":"query CREATE DATABASE","field":"query","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"CREATE DATABASE {{name}}","output":"str","x":460,"y":100,"wires":[["9c57c99b.38a048"]]},{"id":"9ced152b.20be08","type":"inject","z":"f5487ba0.0254f8","name":"set name \"MyTest\"","props":[{"p":"name","v":"MyTest","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":150,"y":260,"wires":[["46a63814.dc161"]]},{"id":"46a63814.dc161","type":"template","z":"f5487ba0.0254f8","name":"query DROP DATABASE","field":"query","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"DROP DATABASE {{name}}","output":"str","x":450,"y":260,"wires":[["9c57c99b.38a048"]]},{"id":"bdcfd292.86c838","type":"comment","z":"f5487ba0.0254f8","name":"influxdb in node","info":"","x":760,"y":60,"wires":[]},{"id":"caa25891.978cd8","type":"comment","z":"f5487ba0.0254f8","name":"influxdb out node","info":"","x":760,"y":340,"wires":[]},{"id":"3bde303b.6138a8","type":"comment","z":"f5487ba0.0254f8","name":"influxdb batch node","info":"","x":770,"y":540,"wires":[]},{"id":"cb88011f.55c898","type":"inject","z":"f5487ba0.0254f8","name":"set variables, last 1h","props":[{"p":"measurement","v":"weather_sensor","vt":"str"},{"p":"location","v":"garden","vt":"str"},{"p":"time","v":"1h","vt":"str"},{"p":"field1","v":"temp","vt":"str"},{"p":"field2","v":"light","vt":"str"},{"p":"field3","v":"humidity","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":150,"y":660,"wires":[["b87f2a5b.237a08"]]},{"id":"b87f2a5b.237a08","type":"template","z":"f5487ba0.0254f8","name":"query SELECT ... FROM","field":"query","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"SELECT {{field1}},{{field2}},{{field3}} FROM {{measurement}} WHERE time > now() - {{time}} AND location='{{location}}' limit 1000;","output":"str","x":450,"y":660,"wires":[["9c57c99b.38a048"]]},{"id":"8915e6cf.702f9","type":"comment","z":"f5487ba0.0254f8","name":"Read multiple values","info":"","x":130,"y":620,"wires":[]},{"id":"e68b7284.a1c8e","type":"influxdb","hostname":"10.11.5.52","port":"8086","protocol":"http","database":"MyTest","name":"","usetls":false,"tls":"","influxdbVersion":"1.x","url":"","rejectUnauthorized":false}]
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)



Possibly Related Threads…
Thread Author Replies Views Last Post
  InfluxDB, Node-RED and Grafana Armin@netPI 0 1,255 January-6th-2021, 02:36 PM
Last Post: Armin@netPI
  [SOLVED] Storing data on a (remote) database MGharat 18 8,441 October-17th-2019, 07:53 AM
Last Post: Armin@netPI
  [INFO] Raspberry Pi Desktop under Windows Armin@netPI 0 829 January-24th-2019, 07:41 PM
Last Post: Armin@netPI

Forum Jump:


Users browsing this thread: 1 Guest(s)