### Start QuestDB Service (Linux/macOS) Source: https://hertzbeat.apache.org/docs/start/questdb-init Navigate to the QuestDB binary directory and start the QuestDB service. Ensure you are in the correct installation path. ```bash # For Linux/macOS: Navigate to the installation directory and start the service cd /opt/questdb/bin ./questdb start ``` -------------------------------- ### Start QuestDB Service (Windows) Source: https://hertzbeat.apache.org/docs/start/questdb-init Navigate to the QuestDB binary directory in the Command Prompt and start the QuestDB service. Adjust the path if you installed QuestDB in a custom location. ```batch # For Windows (Command Prompt): cd C:\questdb\bin questdb.exe start ``` -------------------------------- ### Install Dependencies and Start Development Server Source: https://hertzbeat.apache.org/docs/community/document Install Node.js dependencies and start the Docusaurus development server to preview the documentation. Ensure Node.js version 18.8.0 is installed. ```bash npm install ``` ```bash npm run start ``` ```bash npm run start-zh-cn ``` -------------------------------- ### Start HertzBeat Server Source: https://hertzbeat.apache.org/docs/start/package-deploy Execute the startup script from the installation directory. ```bash ./startup.sh ``` -------------------------------- ### Install QEMU and Required Packages Source: https://hertzbeat.apache.org/docs/help/risc-v Install the necessary QEMU packages and dependencies on an Ubuntu system. ```bash sudo apt update sudo apt install opensbi qemu-system-misc u-boot-qemu ``` -------------------------------- ### Install Netcat Source: https://hertzbeat.apache.org/docs/help/zookeeper Install the netcat utility required for the monitoring implementation. ```bash yum install -y nc ``` -------------------------------- ### Install Frontend Dependencies Source: https://hertzbeat.apache.org/docs/community/development Install project dependencies using pnpm, with an optional registry mirror. ```bash pnpm install ``` ```bash pnpm install --registry=https://registry.npmmirror.com ``` -------------------------------- ### Install HertzBeat Server Source: https://hertzbeat.apache.org/docs/community/how_to_release Install the HertzBeat server after compilation using Maven. ```bash mvn clean install ``` -------------------------------- ### Example: Multi-Layer CPU Information Source: https://hertzbeat.apache.org/docs/advanced/extend-http-default This example demonstrates the multi-layer JSON format for querying CPU information from multiple virtual machines, providing details for each instance. ```json [ { "hostname": "linux-1", "core": 1, "usage": 78.0, "allTime": 200, "runningTime": 100 }, { "hostname": "linux-2", "core": 3, "usage": 78.0, "allTime": 566, "runningTime": 34 }, { "hostname": "linux-3", "core": 4, "usage": 38.0, "allTime": 500, "runningTime": 20 } ] ``` -------------------------------- ### Install pnpm Source: https://hertzbeat.apache.org/docs/community/development Global installation of the pnpm package manager. ```bash npm install -g pnpm ``` -------------------------------- ### Install markdownlint-cli2 Source: https://hertzbeat.apache.org/docs/community/code_style_and_quality_guide Install the markdownlint-cli2 tool globally using npm. ```bash npm install markdownlint-cli2 --global ``` -------------------------------- ### Example: A Record Discovery Configuration Source: https://hertzbeat.apache.org/docs/help/dns_sd Configure HertzBeat to discover service instances using A records. This setup queries the specified DNS server for A records and suggests using Ping or Port monitoring for the discovered IP addresses. ```text DNS Host : 192.168.1.1 (Internal DNS server) DNS Port : 53 Record Type : Select A Record Name : services.example.com Monitoring Template : Select Ping or Port monitoring ``` -------------------------------- ### Start Frontend Development Server Source: https://hertzbeat.apache.org/docs/community/development Launch the frontend application in the web-app directory. ```bash pnpm start ``` -------------------------------- ### Verify Netcat Installation Source: https://hertzbeat.apache.org/docs/help/zookeeper Expected output upon successful installation. ```text Complete! ``` -------------------------------- ### Monitoring Metrics Expression Examples (PromQL) Source: https://hertzbeat.apache.org/docs/help/alert_threshold Examples of PromQL-style query and comparison expressions for monitoring metrics. ```promql cpu_usage ``` ```promql memory{__field__="field1"} ``` ```promql cpu_usage > 80 ``` ```promql memory_usage >= 90.5 ``` ```promql response_time < 1000 ``` -------------------------------- ### Example: Single-Layer CPU Information Source: https://hertzbeat.apache.org/docs/advanced/extend-http-default This example shows the single-layer JSON format for querying CPU information from a single virtual machine, including hostname, core count, and usage percentage. ```json { "hostname": "linux-1", "core": 1, "usage": 78.0, "allTime": 200, "runningTime": 100 } ``` -------------------------------- ### Install Dependencies and Run Document Format Inspection Source: https://hertzbeat.apache.org/docs/community/document Navigate to the `home` directory, install dependencies using pnpm, and then run the markdown-lint tool to inspect document formatting. Use `md-lint-fix` to automatically fix formatting issues. ```bash cd home && pnpm install pnpm md-lint # If the documentation is wrong, you can use pnpm md-lint-fix to fix it. pnpm md-lint-fix ``` -------------------------------- ### Verify Docker Installation Source: https://hertzbeat.apache.org/docs/start/influxdb-init Check the installed Docker version to ensure the environment is ready. ```bash $ docker -v Docker version 20.10.12, build e91ed57 ``` -------------------------------- ### Install PostgreSQL using Docker Source: https://hertzbeat.apache.org/docs/start/usecase/springboot-auto-practice Quickly install PostgreSQL service using Docker for metadata storage. Ensure the PostgreSQL Docker image is available. ```bash docker run -d --name postgresql -p 5432:5432 -v "$PWD/postgresql:/var/lib/postgresql/data" -e POSTGRES_USER=root -e POSTGRES_PASSWORD=123456 -e TZ=Asia/Shanghai postgres:15 ``` -------------------------------- ### Install VictoriaMetrics using Docker Source: https://hertzbeat.apache.org/docs/start/usecase/springboot-auto-practice Quickly install VictoriaMetrics service using Docker for metric storage. Ensure the VictoriaMetrics Docker image is available. ```bash docker run -d -p 8428:8428 -v "$PWD/victoria-metrics-data:/victoria-metrics-data" --name victoria-metrics victoriametrics/victoria-metrics:v1.95.1 ``` -------------------------------- ### Verify Java Installation Source: https://hertzbeat.apache.org/docs/start/package-deploy Use this command to confirm that the required JDK 17 environment is correctly installed and accessible. ```bash $ java -version java version "17.0.9" Java(TM) SE Runtime Environment 17.0.9 (build 17.0.9+8-LTS-237) Java HotSpot(TM) 64-Bit Server VM 17.0.9 (build 17.0.9+8-LTS-237, mixed mode) ``` -------------------------------- ### Enable Hive Metastore Source: https://hertzbeat.apache.org/docs/help/hive Start the Hive metastore service in the background. This is a prerequisite for monitoring. ```bash hive --service metastore & ``` -------------------------------- ### Monitoring Metrics Logical and Parenthesis Expression Examples (PromQL) Source: https://hertzbeat.apache.org/docs/help/alert_threshold Examples of logical and parenthesis expressions in PromQL for combining multiple monitoring conditions. ```promql cpu_usage > 80 and memory_usage > 70 ``` ```promql disk_usage > 90 or inode_usage > 85 ``` ```promql cpu_usage > 80 unless maintenance_mode == 1 ``` ```promql (cpu_usage > 80 or memory_usage > 90) and service_status == 1 ``` -------------------------------- ### API Response Example for Service Discovery Source: https://hertzbeat.apache.org/docs/help/http_sd Example response from a service management API returning a list of service instances. ```json [ { "target": [ "10.0.1.10:8080", "10.0.1.11:8080", "10.0.1.12:8080" ] } ] ``` -------------------------------- ### Configure RISC-V-Compatible JDK Source: https://hertzbeat.apache.org/docs/help/risc-v Install and set up the Temurin JDK 17 environment variables. ```bash # Install tools sudo apt update sudo apt install -y tar wget # Create installation directory sudo mkdir -p /usr/lib/jvm # Extract to system directory sudo tar -xzf OpenJDK17U-jdk_riscv64_linux_hotspot_17.0.15_6.tar.gz -C /usr/lib/jvm # Edit environment variables sudo nano /etc/profile.d/java.sh export JAVA_HOME=/usr/lib/jvm/jdk-17.0.15+6 export PATH=$JAVA_HOME/bin:$PATH # Apply configuration source /etc/profile.d/java.sh # Verify installation java -version ``` -------------------------------- ### Install MySQL via Docker Source: https://hertzbeat.apache.org/docs/start/mysql-change Run a MySQL container with persistent storage mapping. ```bash $ docker run -d --name mysql \ -p 3306:3306 \ -v /opt/data:/var/lib/mysql \ -e MYSQL_ROOT_PASSWORD=123456 \ --restart=always \ mysql:5.7 ``` -------------------------------- ### Method Naming Convention: Verb First Source: https://hertzbeat.apache.org/docs/community/code_style_and_quality_guide Example of a method name starting with a verb, indicating its action. ```java void computeVcores(Object parameter1); ``` -------------------------------- ### Boot Ubuntu on RISC-V via QEMU Source: https://hertzbeat.apache.org/docs/help/risc-v Decompress the image, resize the disk, and start the RISC-V virtual machine. ```bash # Decompress the image xz -dk ubuntu-24.04.2-preinstalled-server-riscv64.img.xz # Optional: Expand the disk size qemu-img resize -f raw ubuntu-24.04-preinstalled-server-riscv64.img +5G # Start the VM using u-boot-qemu qemu-system-riscv64 \ -machine virt -nographic -m 2048 -smp 4 \ -kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf \ -device virtio-net-device,netdev=eth0 -netdev user,id=eth0 \ -device virtio-rng-pci \ -drive file=ubuntu-24.04.2-preinstalled-server-riscv64.img,format=raw,if=virtio ``` -------------------------------- ### Example: SRV Record Discovery Configuration Source: https://hertzbeat.apache.org/docs/help/dns_sd Configure HertzBeat to discover HTTP service instances using SRV records. This setup queries the specified DNS server for SRV records and automatically creates Port monitoring for discovered instances. ```text Target Name : DNS-SRV-Discovery DNS Host : 8.8.8.8 DNS Port : 53 Record Type : Select SRV Record Name : _http._tcp.example.com Collection interval : 60 seconds Monitoring Template : Select Port monitoring (using the port from SRV record) ``` -------------------------------- ### Example: MX Record Discovery Configuration Source: https://hertzbeat.apache.org/docs/help/dns_sd Configure HertzBeat to discover mail servers using MX records. This setup queries the specified DNS server for MX records and suggests using Port monitoring on port 25 for discovered mail servers. ```text DNS Host : 8.8.8.8 Record Type : Select MX Record Name : example.com Monitoring Template : Select Port monitoring (port 25) ``` -------------------------------- ### Run HertzBeat Source: https://hertzbeat.apache.org/docs/help/risc-v Navigate to the bin directory and execute the startup script. ```bash cd apache-hertzbeat-1.7.2-incubating-bin/bin/ ./startup.sh ``` -------------------------------- ### Build Backend Project Source: https://hertzbeat.apache.org/docs/community/development Execute this command from the project root to compile the backend. ```bash mvn clean install -DskipTests ``` -------------------------------- ### Enable Hive Metastore Source: https://hertzbeat.apache.org/docs/help/iceberg Start the Hive metastore service. This is a prerequisite for monitoring Apache Iceberg. ```bash hive --service metastore & ``` -------------------------------- ### Download Candidate Release Version Source: https://hertzbeat.apache.org/docs/community/how_to_verify_release Use these commands to download the candidate release version to your local environment. Ensure you have `svn` or `wget` installed. Downloading may take time. ```bash #If there is svn locally, you can clone to the local $ svn co https://dist.apache.org/repos/dist/dev/hertzbeat/`release_version`-`rc_version`/ #or download the material file directly $ wget https://dist.apache.org/repos/dist/dev/hertzbeat/`release_version`-`rc_version`/xxx.xxx ``` -------------------------------- ### Build Frontend Package Source: https://hertzbeat.apache.org/docs/community/development Compile the frontend assets for production. ```bash pnpm package ``` -------------------------------- ### Import Public GPG Key Source: https://hertzbeat.apache.org/docs/community/how_to_verify_release Download the KEYS file and import it into your local GPG environment to verify signatures. This step is crucial for users verifying the release, not for the release manager. ```bash -curl https://downloads.apache.org/hertzbeat/KEYS > KEYS # Download KEYS gpg --import KEYS # Import KEYS to local ``` -------------------------------- ### Log Data Expression Examples Source: https://hertzbeat.apache.org/docs/help/alert_threshold Examples of expression rules for log alerts, demonstrating field matching and attribute access. ```plaintext equals(log.level,"ERROR") ``` ```plaintext contains(log.attributes.hostname,"server-01") ``` -------------------------------- ### Install IoTDB via Docker Source: https://hertzbeat.apache.org/docs/start/iotdb-init Run an Apache IoTDB standalone instance using Docker. Ensure to replace `/opt/iotdb/data` with your desired local data directory path for persistent storage. ```bash docker run -d -p 6667:6667 -p 31999:31999 -p 8181:8181 \ -v /opt/iotdb/data:/iotdb/data \ --name iotdb \ apache/iotdb:1.2.2-standalone ``` -------------------------------- ### Extract HertzBeat Installation Package Source: https://hertzbeat.apache.org/docs/start/usecase/springboot-auto-practice Extract the downloaded HertzBeat installation package to a host directory. This is the first step in setting up HertzBeat. ```bash tar zxvf apache-hertzbeat-xxx-incubating-bin.tar.gz ``` -------------------------------- ### Log Data SQL Query Examples Source: https://hertzbeat.apache.org/docs/help/alert_threshold Examples of SQL queries for analyzing log data, including counting errors and grouping by service. ```sql -- Query error log count SELECT COUNT(*) as error_count FROM hertzbeat_logs WHERE level = 'ERROR' AND timestamp >= NOW() - INTERVAL 5 MINUTE ``` ```sql -- Group by service to count errors SELECT service_name, COUNT(*) as error_count FROM hertzbeat_logs WHERE level = 'ERROR' GROUP BY service_name HAVING COUNT(*) > 10 ``` -------------------------------- ### Start HertzBeat Service Source: https://hertzbeat.apache.org/docs/start/usecase/springboot-auto-practice Start the HertzBeat service using the startup script. Access the web interface at http://localhost:1157 after successful startup. ```bash ./startup.sh ``` -------------------------------- ### Enable JMX in Kafka startup script Source: https://hertzbeat.apache.org/docs/help/kafka Append these environment variables to the kafka-server-start.sh file to expose JMX metrics. Ensure the IP address and port are updated to match your environment. ```bash export JMX_PORT=9999; export KAFKA_JMX_OPTS="-Djava.rmi.server.hostname=ip地址 -Dcom.sun.management.jmxremote.rmi.port=9999 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"; # Already Has exec $base_dir/kafka-run-class.sh $EXTRA_ARGS kafka.Kafka "$@" ``` -------------------------------- ### Install PostgreSQL via Docker Source: https://hertzbeat.apache.org/docs/start/postgresql-change Run a PostgreSQL container with the specified environment variables for user and password. ```bash docker run -d --name postgresql -p 5432:5432 -e POSTGRES_USER=root -e POSTGRES_PASSWORD=123456 -e TZ=Asia/Shanghai postgres:15 ``` -------------------------------- ### HertzBeat sureness.yml Configuration Example Source: https://hertzbeat.apache.org/docs/start/docker-deploy This is an example of the sureness.yml configuration file for HertzBeat. It is used to configure user information such as account passwords. Modify this file if you need to update accounts or passwords. ```yaml sureness: # user account and password configuration ``` -------------------------------- ### List existing monitors via AI Agent Source: https://hertzbeat.apache.org/docs/help/ai_agent Example interaction for retrieving a status summary of all currently configured monitors. ```text You: Show me all my current monitors AI Agent: Here are your current monitors: 1. **Linux Server** (ID: 1001) - Status: ✅ Online - Host: 192.168.1.100 - Last Check: 2 minutes ago 2. **MySQL Database** (ID: 1002) - Status: ⚠️ Warning - Host: db.example.com - Last Check: 30 seconds ago 3. **Website Monitor** (ID: 1003) - Status: ✅ Online - Host: https://example.com - Last Check: 1 minute ago Would you like details on any specific monitor? ``` -------------------------------- ### Alibaba Cloud SMS Message Template Example Source: https://hertzbeat.apache.org/docs/help/alert_sms This is an example format for a message template to be used with Alibaba Cloud SMS. It uses backticks for placeholders representing instance, priority, and content. ```text Monitor: `instance`, Alert Level: `priority`. Content: `content` ``` -------------------------------- ### Tencent Cloud SMS Message Template Example Source: https://hertzbeat.apache.org/docs/help/alert_sms This is an example format for a message template to be used with Tencent Cloud SMS. It includes placeholders for monitor name, alert level, and content. ```text Monitor: {1}, Alert Level: {2}. Content: {3} ``` -------------------------------- ### Navigate to Frontend Directory Source: https://hertzbeat.apache.org/docs/community/development Change the working directory to the web-app folder before running frontend commands. ```bash cd web-app ``` -------------------------------- ### Start HertzBeat Services with Docker Compose Source: https://hertzbeat.apache.org/docs/start/docker-compose-deploy Starts HertzBeat and its dependent services (PostgreSQL, VictoriaMetrics) in detached mode using Docker Compose. This command should be run from within the selected deployment directory. ```bash docker-compose up -d ```