### Start EMQX Broker Source: https://docs.emqx.com/en/neuronex/latest/configuration/north-apps/sparkplugb/cogent This command starts a local instance of the EMQX broker. Ensure EMQX is installed and accessible in your environment. ```bash ./bin/emqx start ``` -------------------------------- ### Install Plugin using install.sh (Bash) Source: https://docs.emqx.com/en/neuronex/latest/api/api-docs Example of an install.sh script for installing a plugin's dependencies. It checks for existing directories, creates them if necessary, installs packages like unzip, and handles configuration files. This script is part of a plugin's zip archive. ```bash dir=/usr/local/mysdk cur=$(dirname "$0") echo "Base path $cur" if [ -d "$dir" ]; then echo "SDK path $dir exists." else echo "Creating SDK path $dir" mkdir -p $dir echo "Created SDK path $dir" fi apt install --no-upgrade unzip if [ -d "$dir/lib" ]; then echo "SDK lib path $dir/lib exists." else echo "Unzip SDK lib to path $dir" unzip $cur/mysdk.zip -d $dir echo "Unzipped SDK lib to path $dir" fi if [ -f "/etc/ld.so.conf.d/myconfig.conf" ]; then echo "/etc/ld.so.conf.d/myconfig.conf exists" else echo "Copy conf file" cp $cur/myconfig.conf /etc/ld.so.conf.d/ echo "Copied conf file" fi ldconfig echo "Done" ``` -------------------------------- ### Install and Start NeuronEX (Debian/Ubuntu) Source: https://docs.emqx.com/en/neuronex/latest/best-practise/master-backup Installs the NeuronEX service from a .deb package, starts the service, and configures it to launch automatically on system boot. This is a prerequisite for setting up the master-backup mode. ```shell # Download NeuronEX installation package wget https://www.emqx.com/zh/downloads/neuronex/3.4.3/neuronex-3.4.3-linux-amd64.deb # Install NeuronEX sudo dpkg -i neuronex-3.4.3-linux-amd64.deb # Start NeuronEX sudo systemctl start neuronex # Set to start automatically on boot sudo systemctl enable neuronex ``` -------------------------------- ### Python Plugin Initialization Example Source: https://docs.emqx.com/en/neuronex/latest/streaming-processing/extension Example of initializing and starting a portable plugin in NeuronEX using Python. It demonstrates how to configure plugin components like JSON parsing, print sinks, and revert instances. ```python if __name__ == '__main__': c = PluginConfig("pysam", {"pyjson": lambda: PyJson()}, {"print": lambda: PrintSink()}, {"revert": lambda: revertIns}) plugin.start(c) ``` -------------------------------- ### Execute Plugin Installation Script Source: https://docs.emqx.com/en/neuronex/latest/streaming-processing/portable_python This shell script is executed automatically during plugin installation. It determines the plugin's base path and installs any Python dependencies listed in 'requirements.txt'. ```shell cur=$(dirname "$0") echo "Base path $cur" pip install -r $cur/requirements.txt echo "Done" ``` -------------------------------- ### Test AI Feature Startup with uv Source: https://docs.emqx.com/en/neuronex/latest/admin/sys-configuration This command tests if the AI features can start normally after installing dependencies using 'uv'. It synchronizes packages and then runs the main AI application entry point. Successful execution indicates that AI-related dependency libraries are correctly installed. ```bash uv sync && cd src/apps_entry && uv run main.py ``` -------------------------------- ### Install Python Dependencies for NeuronEX Source: https://docs.emqx.com/en/neuronex/latest/streaming-processing/portable_python Installs the necessary Python libraries, `ekuiper` and `pynng`, required for running Python portable plugins in EMQX Neuron. This is typically done in a Python 3 environment. ```shell pip install ekuiper pynng ``` -------------------------------- ### Install EMQX Neuron from .tar.gz package Source: https://docs.emqx.com/en/neuronex/latest/installation/targz Extracts the downloaded EMQX Neuron .tar.gz package and navigates into the extracted directory. This is a common installation step on Linux systems. ```bash tar -zxvf neuronex-3.7.0-linux-amd64.tar.gz cd neuronex-3.7.0-linux-amd64 ``` -------------------------------- ### Download EMQX Neuron using wget Source: https://docs.emqx.com/en/neuronex/latest/installation/ubuntu This command downloads the EMQX Neuron installation package (.deb file) from the EMQ website. Ensure you have wget installed and replace the version and architecture with your specific requirements. ```bash wget https://www.emqx.com/en/downloads/neuronex/3.7.0/neuronex-3.7.0-linux-amd64.deb ``` -------------------------------- ### Get Available Portable Plugins Source: https://docs.emqx.com/en/neuronex/latest/api/api-docs Retrieves a list of pre-built portable plugins available for installation based on the `pluginHosts` configuration. By default, it fetches from `https://packages.emqx.net`. ```HTTP GET /api/ekuiper/plugins/portables/prebuild HTTP/1.1 Host: localhost ``` -------------------------------- ### MQTT Plugin Start Function (C) Source: https://docs.emqx.com/en/neuronex/latest/dev-guide/sdk-tutorial/sdk-example/mqtt-example The `mqtt_plugin_start` function is invoked when a user initiates the MQTT plugin from the Neuron node page. It calls `plguin_start_running` to begin the plugin's operation and device connection process. If the configuration is invalid, it returns `NEU_ERR_NODE_SETTING_INVALID`. ```c static int mqtt_plugin_start(neu_plugin_t *plugin) { assert(NULL != plugin); int rc = plguin_start_running(plugin); if (0 != rc) { return NEU_ERR_NODE_SETTING_INVALID; } return NEU_ERR_SUCCESS; } ``` -------------------------------- ### Download EMQX Neuron using wget Source: https://docs.emqx.com/en/neuronex/latest/installation/targz Downloads the EMQX Neuron installation package (.tar.gz) from the EMQ website. This command is typically used in a Linux environment. ```bash wget https://www.emqx.com/en/downloads/neuronex/3.7.0/neuronex-3.7.0-linux-amd64.tar.gz ``` -------------------------------- ### Start EMQX Neuron Service Source: https://docs.emqx.com/en/neuronex/latest/installation/centos Starts the EMQX Neuron service using `systemctl`. This command requires root privileges (`sudo`) and assumes the service unit file is correctly configured. ```bash $ sudo systemctl start neuronex ``` -------------------------------- ### Get Available Source Plugins Source: https://docs.emqx.com/en/neuronex/latest/api/api-docs Retrieves a list of pre-built source plugins available for installation based on the `pluginHosts` configuration. By default, it fetches from `https://packages.emqx.net`. ```HTTP GET /api/ekuiper/plugins/sources/prebuild HTTP/1.1 Host: localhost ``` -------------------------------- ### Get available plugins Source: https://docs.emqx.com/en/neuronex/latest/api/api-docs Returns a list of plugins that can be installed locally, based on the `pluginHosts` configuration. By default, it fetches the list from `https://packages.emqx.net`. ```APIDOC ## Get the available plugins ### Description Returns a list of plugins that can be installed locally, based on the `pluginHosts` configuration. By default, it fetches the list from `https://packages.emqx.net`. ### Method GET ### Endpoint /api/ekuiper/plugins/{type}/prebuild ### Parameters #### Path Parameters - **type** (string) - Required - Type of plugins to retrieve (e.g., "sources", "sinks", "functions", "portables"). ### Request Body *This endpoint does not typically require a request body for the GET method. The provided schema might be for a different context or an older version.* ### Response #### Success Response (200) - **{key}** (string) - A URL pointing to a plugin zip file. The keys represent different plugin variants or targets. #### Response Example ```json { "file": "http://127.0.0.1:63767/kuiper-plugins/0.9.1/sinks/alpine/file_arm64.zip", "influx": "http://127.0.0.1:63767/kuiper-plugins/0.9.1/sinks/alpine/influx_arm64.zip", "zmq": "http://127.0.0.1:63768/kuiper-plugins/0.9.1/sinks/alpine/zmq_arm64.zip" } ``` ``` -------------------------------- ### Install and Run NeuronEX AI Docker Image Source: https://docs.emqx.com/en/neuronex/latest/best-practise/llm-portable-plugin These commands demonstrate how to download and run NeuronEX Docker images with AI functionality. It includes separate instructions for x86 and arm64 architectures, ensuring the container is set up for AI model interaction. ```shell # Download x86 image and run container docker pull emqx/neuronex:3.5.1-ai docker run -d --name neuronex -p 8085:8085 --log-opt max-size=100m --privileged=true emqx/neuronex:3.5.1-ai # Download arm64 image and run container docker pull emqx/neuronex:3.5.1-ai-amd64 docker run -d --name neuronex -p 8085:8085 --log-opt max-size=100m --privileged=true emqx/neuronex:3.5.1-ai-amd64 ``` -------------------------------- ### Get Available Sink Plugins Source: https://docs.emqx.com/en/neuronex/latest/api/api-docs Retrieves a list of pre-built sink plugins available for installation based on the `pluginHosts` configuration. By default, it fetches from `https://packages.emqx.net`. ```HTTP GET /api/ekuiper/plugins/sinks/prebuild HTTP/1.1 Host: localhost ``` -------------------------------- ### Start eKuiper Process API Source: https://docs.emqx.com/en/neuronex/latest/api/api-docs Starts the eKuiper process. ```APIDOC ## GET /api/process/ekuiper/start ### Description Starts the eKuiper process. ### Method GET ### Endpoint /api/process/ekuiper/start ### Response #### Success Response (200) - **(empty object)** #### Error Response (500) - **(empty object)** #### Response Example ```json { } ``` ``` -------------------------------- ### Python Portable Plugin Main Program (pysam.py) Source: https://docs.emqx.com/en/neuronex/latest/streaming-processing/portable_python The main executable file for the Python portable plugin. It initializes the plugin configuration, registers Source, Sink, and Function plugins, and starts the plugin service using the `ekuiper` library. ```python from ekuiper import plugin, PluginConfig from print import PrintSink from pyjson import PyJson from revert import revertIns if __name__ == '__main__': c = PluginConfig("pysam", {"pyjson": lambda: PyJson()}, {"print": lambda: PrintSink()}, {"revert": lambda: revertIns}) plugin.start(c) ``` -------------------------------- ### Get Available Function Plugins Source: https://docs.emqx.com/en/neuronex/latest/api/api-docs Retrieves a list of pre-built function plugins available for installation based on the `pluginHosts` configuration. By default, it fetches from `https://packages.emqx.net`. ```HTTP GET /api/ekuiper/plugins/functions/prebuild HTTP/1.1 Host: localhost ``` -------------------------------- ### Plugin Python Dependencies Source: https://docs.emqx.com/en/neuronex/latest/streaming-processing/portable_python This file lists the Python packages and their specific versions required by the plugin. It is used by the 'install.sh' script to install dependencies. ```shell numpy==1.22.3 scipy==1.8.0 ``` -------------------------------- ### Start Local HTTP Service with Python Flask Source: https://docs.emqx.com/en/neuronex/latest/streaming-processing/ex_func This Python script uses Flask to create a local HTTP server that listens on port 9876. It exposes an API endpoint '/api/test1' which accepts POST requests with JSON data containing 'a' and 'b' fields. The service returns the sum of 'a' and 'b' or an error message. ```python from flask import Flask, request, jsonify app = Flask(__name__) @app.route('/api/test1', methods=['POST']) def test1(): try: data = request.get_json() a = data['a'] b = data['b'] result = a + b return jsonify({'result': result}), 200 except Exception as e: return jsonify({'error': str(e)}), 400 if __name__ == '__main__': app.run(host='0.0.0.0', port=9876) ``` -------------------------------- ### Package Plugin into ZIP Archive Source: https://docs.emqx.com/en/neuronex/latest/streaming-processing/portable_python This command packages the plugin's files into a zip archive named 'pysam.zip'. It is executed in the directory containing 'pysam.json'. The resulting zip file is used for plugin installation in NeuronEx. ```shell zip -r pysam.zip ./* ``` -------------------------------- ### Start EMQX Neuron service Source: https://docs.emqx.com/en/neuronex/latest/installation/ubuntu This command starts the EMQX Neuron system service. It requires superuser privileges (sudo) and assumes the service is named 'neuronex'. ```bash sudo systemctl start neuronex ``` -------------------------------- ### Start NeuronEX as a Daemon (Shell) Source: https://docs.emqx.com/en/neuronex/latest/admin/conf-management The `start` command initiates NeuronEX in daemon mode, allowing it to run in the background. This command does not manage the lifecycle of Neuron or eKuiper and does not enable privilege authentication. ```shell ./bin/neuronex start ``` -------------------------------- ### Run All Functional Tests (Shell) Source: https://docs.emqx.com/en/neuronex/latest/dev-guide/dev-guide This script executes all functional tests for the Neuron project. It involves installing Mosquitto, starting the Mosquitto broker, updating pip, installing test requirements, and then running Robot Framework tests. ```shell sudo apt-get install -y mosquitto mosquitto -v & python3 -m pip install -U pip python3 -m pip install -r ft/requirements.txt python3 -m robot --maxerroelines=600 -P ft/ -d ft/reports ft ``` -------------------------------- ### Pull EMQX Neuron Docker Image Source: https://docs.emqx.com/en/neuronex/latest/quick-start/quick-start This command pulls the latest EMQX Neuron Docker image from Docker Hub. Ensure Docker is installed and running on your system. ```bash docker pull emqx/neuronex:latest ``` -------------------------------- ### Define SQL Stream with Protobuf Schema Source: https://docs.emqx.com/en/neuronex/latest/streaming-processing/stream This example demonstrates defining a SQL stream named 'demo' that subscribes to the MQTT topic 'test/' using the Protobuf format. It specifies a schema ID 'proto1.Book' for decoding the incoming data. The data is decoded according to the 'Book' definition in the specified Protobuf schema file. ```sql demo () WITH (DATASOURCE="test/", FORMAT="protobuf", SCHEMAID="proto1.Book"); ``` -------------------------------- ### Install EMQX Neuron using dpkg Source: https://docs.emqx.com/en/neuronex/latest/installation/ubuntu This command installs the downloaded EMQX Neuron deb package. It requires superuser privileges (sudo) and the correct filename for your downloaded package. ```bash sudo dpkg -i neuronex-3.7.0-linux-amd64.deb ``` -------------------------------- ### POST /api/ekuiper/rules/{id}/start Source: https://docs.emqx.com/en/neuronex/latest/api/api-docs Starts the execution of a rule. ```APIDOC ## POST /api/ekuiper/rules/{id}/start ### Description Starts the execution of a rule. ### Method POST ### Endpoint /api/ekuiper/rules/{id}/start ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the rule to start. ### Response #### Success Response (200) - An empty JSON object indicates the rule has started successfully. ### Response Example ```json {} ``` ``` -------------------------------- ### Get Rule Start Timestamp with RULE_START Source: https://docs.emqx.com/en/neuronex/latest/streaming-processing/sqls/functions/other_functions The RULE_START function returns the timestamp when the current rule started execution, in int64 format. This can be useful for measuring rule execution duration or for time-based analysis. ```text rule_start() ``` -------------------------------- ### Run NeuronEX with Configuration (Shell) Source: https://docs.emqx.com/en/neuronex/latest/admin/conf-management The `run` command starts NeuronEX on the console, displaying output in the terminal. It accepts a configuration file path and an option to disable eKuiper. The priority order for configuration is command line > environment variable > configuration file. ```shell # Command line options for the run command -c, --config string config file path (default "etc/neuronex.yaml") -k, --disable_kuiper select whether to disable ekuiper # Example usage ./bin/neuronex run -c etc/neuronex.yaml -k true ``` -------------------------------- ### OpenSSL Default Configuration File Example Source: https://docs.emqx.com/en/neuronex/latest/configuration/south-devices/opc-ua/policy A sample OpenSSL configuration file that sets up basic environment variables and defines sections for Object Identifiers (OIDs). This file can be used as a base for more specific configurations, such as those required for certificate generation. ```ini # # OpenSSL example configuration file. # This is mostly being used for generation of certificate requests. # # This definition stops the following lines choking if HOME isn't # defined. HOME = . RANDFILE = $ENV::HOME/.rnd # Extra OBJECT IDENTIFIER info: #oid_file = $ENV::HOME/.oid oid_section = new_oids # To use this configuration file with the "-extfile" option of the # "openssl x509" utility, name here the section containing the # X.509v3 extensions to use: # extensions = # (Alternatively, use a configuration file that has only # X.509v3 extensions in its main [= default] section.) [ new_oids ] # We can add new OIDs in here for use by 'ca', 'req' and 'ts'. # Add a simple OID like this: # testoid1=1.2.3.4 # Or use config file substitution like this: # testoid2=${testoid1}.5.6 ``` -------------------------------- ### Golang Simple Template Examples for Single Record Source: https://docs.emqx.com/en/neuronex/latest/streaming-processing/sink/data_template Demonstrates how to use Golang templates to format a single record in sendSingle=true mode. It shows how to print the entire record or specific fields, including adding quotes for string fields. ```text "dataTemplate": "{\"content\":{{json .}}}", ``` ```text "dataTemplate": "{\"content\":{{.ab}}}", ``` ```text "dataTemplate": "{\"content\":\"{{.ab}}\"}", ``` -------------------------------- ### Run EMQX Neuron Docker Container Source: https://docs.emqx.com/en/neuronex/latest/quick-start/quick-start This command starts a new Docker container for EMQX Neuron in detached mode. It maps port 8085 for access and sets a log rotation policy. ```bash docker run -d --name neuronex -p 8085:8085 --log-opt max-size=100m emqx/neuronex:latest ``` -------------------------------- ### NeuronEX Login Credentials Example Source: https://docs.emqx.com/en/neuronex/latest/streaming-processing/http_pull Example of the JSON request body for logging into NeuronEX, specifying the username and password. This is a common payload for authentication endpoints in many systems. Ensure the credentials are correct for successful login. ```json {"name":"admin","password":"0000"} ``` -------------------------------- ### Golang Simple Template Examples for Array of Records Source: https://docs.emqx.com/en/neuronex/latest/streaming-processing/sink/data_template Illustrates Golang template usage for arrays of records in sendSingle=false mode. Examples include printing the entire array, the first record, a specific field of the first record, and iterating through the array to format a field for each record into HTML. ```text "dataTemplate": "{\"content\":{{json .}}}", ``` ```text "dataTemplate": "{\"content\":{{json (index . 0)}}", ``` ```text "dataTemplate": "{\"content\":{{index . 0 \"ab\"}}}", ``` ```text "dataTemplate": "