Solutions
Setup InfluxDB 2.x via Docker with Presets
14 min
overview how to deploy influxdb 2 x via docker with presets here is an example to run influxdb 2 x with presets with docker important litmus has currently verified version 2 5 1, which is why the docker run command will not use the "latest" tag if a user does decide to choose latest or a later version, the docker run command may have to be adopted in case the vendor influxdata has introduced changes to their product therefore, please consult the official https //hub docker com/ /influxdb page for potential changes note the example uses docker running on ubuntu, as we do not recommend to use litmus edge for this docker run itd p 8086 8086 v $pwd/data /var/lib/influxdb2 v $pwd/config /etc/influxdb2 e docker influxdb init mode=setup e docker influxdb init username=admin e docker influxdb init password=litmusedge s3cr3t! e docker influxdb init org=litmus e docker influxdb init bucket=tsdata e docker influxdb init retention=1w e docker influxdb init admin token=z0bsqi47j0ifnz6982mylpyo2f2r9lq9 influxdb 2 5 1 influxdb docker image is available at https //hub docker com/ /influxdb ⚠️ when using docker, the following environment variables can be set before running the container to presetup influxdb 2 x true 151,151,151,153 unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type there are additional options to for example persist data to the current working directory in the host file system v $pwd/data /var/lib/influxdb2 persist config to the current working directory in the host file system v $pwd/config /etc/influxdb2 (optional) how to add the influxdb 2 x via docker with presets solution to litmus edge manager marketplace note this is an optional way to deploy the influxdb 2 x with presets on a litmus edge which is not a recommended way of deploying a time series database for long term storage this should only be done for development or validation purposes and then replaced by an implementation in a data center or as saas this deployment requires that a litmus edge is connected to a deployed litmus edge manager the user also should have experience in https //docs litmus io/edgemanager/lem admin console/product features/docker registry to the lem marketplace step 1 download the file influxdb 2 x with presets json through the download button, to import the application to lem marketplace step 2 access the lem user ui via your browser step 3 access your company and project and select the features menu step 4 select the marketplace option step 5 select the catalog you want to use step 6 select the add or import an application icon step 7 import the downloaded json file step 8 the application is now part of the catalog (optional) how to deploy influxdb 2 x via docker with presets from litmus edge manager marketplace note this is an optional way to deploy the influxdb 2 x with presets on a litmus edge which is not a recommended way of deploying a time series database for long term storage this should only be done for development or validation purposes and then replaced by an implementation in a data center or as saas this deployment requires that a litmus edge is connected and that the solution has been added to a lem marketplace catalog previously it is expected, that users are knowledgeable about how applications and solutions are https //docs litmus io/edgemanager/deploy an application to edge devices from lem deploying influxdb 2 x with presets from lem requires a series of parameters to be provided true 151,151,151,153 unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type unhandled content type ⚠️ this implementation does not provide parameters for the persistent data and configuration how to access the newly deployed influxdb 2 x after the container is deployed (use docker ps a to check) a browser can be used to access the standard influx db 2 x ui step 1 open a browser and enter the url for the influxdb 2 x ui url http //\<ip of influx db> 8086 example http //192 168 2 54 8086 step 2 use the username and password from the docker run command to logon step 3 you will now log on to the organization provided in the docker run command how to publish data to the newly deploy influxdb 2 x there are several choices for users to send data from litmus edge directly to the newly deployed influxdb 2 x use the litmus edge datahub external option use the litmus edge integration for influx db 2 x use the litmus solution le native to influxdb v2 use the litmus solution le mqtt to influxdb v2 note all of them will require the api key used in the docker run command, as well as the organization and bucket used in the docker run command how to use fluxql to query data from influxdb 2 x https //docs influxdata com/flux/v0 x/ is the new query language developed by influxdata to access data from influxdb 2 x this is a query example taken from grafana from(bucket "tsdata") |> range(start v timerangestart, stop\ v timerangestop) |> filter(fn (r) => r measurement == "plc rc1 ccs 08 5477562d fea6 4d43 9376 8f77b01c21d9" and r field == "htr htg sctemp pv" ) to query data with fluxql, it is required to provide the bucket, which is the same bucket taken from the docker run command from(bucket "tsdata") the range is sued to query a specific time period and will depend on the application used in the example, the start and end time is set automatically set by grafana based on the time period set in the dashboard range(start v timerangestart, stop\ v timerangestop) the filter basically acts as an equivalent to the from and where clause from influxql where the r measurement is taking in the role of the from clause and basically can be understood as "table" from a relational db the r field is acting as a kind of where clause and could be seen as equivalent to "where tag = 'xyz'" filter(fn (r) => r measurement == "plc rc1 ccs 08 5477562d fea6 4d43 9376 8f77b01c21d9" and r field == "htr htg sctemp pv" ) note to assist with the development of fluxql queries, the influxdb 2 x ui offers a nice tool in the form of their data explorer this offers a simple way to navigate the time series and build queries using simple selecting of measurements and fields optional filters are possible the script editor then allows to show the actual fluxql query