Solutions
LE Sparkplug Edge Node
Environment Variables
5min
overview the le sparkplug edge node can be configured using environment variables passed during the docker run command this method is an alternative to using the configuration file (config json) , which is the recommended approach, especially for complex setups like tls if a config json file is mounted and environment variables are also set, the environment variables will take precedence variables the following environment variables are available variable name required status description default value edge api token required the api token for authenticating with the litmus edge rest api none group id required the sparkplug group id for this edge node instance none node id required the sparkplug node id for this specific edge node instance must be unique within the group id none mqtt servers required a json array string defining the mqtt broker(s) to connect to each object requires url user and password are optional tls fields can be added (see below) example '\[{"url" "tcp\ //broker 1883","user" "u","pass" "p"}]' none primary host support optional if true , the edge node waits for a primary host application (defined by primary host id ) to be online before sending data false primary host id conditionally req the sparkplug application id of the primary host required only if primary host support is set to true none le store and forward optional if true , enables the local buffering of data when the mqtt connection is down see related le variables below false le ttl duration optional time to live (in hours) for buffered messages when le store and forward is true 12 (hours) le max size mb optional maximum size (in megabytes) of the buffer database when le store and forward is true 1000 (mb) le max num entries optional maximum number of entries allowed in the buffer database when le store and forward is true 1000000 mqtt client id optional custom mqtt client id if blank, one is auto generated based on group/node id (auto generated) mqtt client id suffix optional a suffix appended to the mqtt client id (whether custom or auto generated) (blank) mqtt connect timeout optional maximum time (e g , "30s", "1m") to wait for an mqtt connection attempt 30s mqtt write timeout optional maximum time (e g , "3s") to wait for an mqtt publish operation 3s mqtt keepalive optional maximum interval (in seconds) between mqtt control packets sends pingreq if no other packets are sent 30 (seconds) le logging level optional sets the application's logging verbosity options debug , info , warn , error info edge hostname external only required only when running externally the hostname or ip address of the target litmus edge device for nats connection none nats url external only required only when running externally the nats connection string format tls\ //admin \<api account token>@\<edge hostname> 4222 (or nats\ // ) none mqtt servers json when providing the mqtt servers value as an environment variable, ensure the json string is properly escaped for your shell for tls configuration within this variable, see the tls certs docid 8gggoql nhxixhrfztgb7 guide configuration example (with tls and other options) docker run d name le sparkplug network host e edge api token="\<your litmus edge api token>" e primary host support=true e primary host id="\<your primary host id>" e le store and forward=false e group id="mygroup" e node id="myedgenode" e mqtt servers='\[{\\"url\\" \\"ssl //\<broker ip or hostname> 8883\\",\\"user\\" \\"\<mqtt username>\\",\\"password\\" \\"\<mqtt password>\\",\\"ca cert\\" \\"\<base64 ca cert>\\",\\"client cert\\" \\"\<base64 client cert>\\",\\"client key\\" \\"\<base64 client key>\\",\\"skip cert verify\\"\ false}]' e le logging level="debug" \<imgname> \<tagname> remember to replace placeholders and handle json escaping carefully { "edge api token" "0iriyynzv5xjac1aupqxm4j2tzuls5pf", // example token "group id" "le group", "node id" "le node", "primary host support" true, // enabled "primary host id" "le 97is6vf", // required if primary host support is true "le store and forward" false, // disabled by default "le logging level" "info", "mqtt" { "servers" \[ { "url" "ssl //mqtt secure com 8883", // example tls server "user" "myuser", "password" "mypassword", "ca cert" "ls0tls1crudjtibdrvjusuzjq0futck1jsuvkakndqwrzq0 ", // base64 encoded "client cert" "ls0tls1crudjtibsu0egufvcteldietfws0tprd0lc ", // base64 encoded "client key" "ls0tls1crudjtibsu0egufjjvkfursblrvktulcrxdf ", // base64 encoded "skip cert verify" false }, { "url" "tcp\ //mqtt insecure com 1883", // example non tls server "username" "admin", "password" "admin@" } ], "client id" "", // auto generated if blank "client id suffix" "le spb", // optional suffix "connect timeout" "30s", "write timeout" "3s", "keepalive" 30 } }