Docker Grafana Deployment and Management API for Billing Systems - n8n Workflow

Use this powerful n8n workflow as an API backend for WHMCS/WISECP to automate Docker Grafana deployment, suspension, termination, resource scaling, and container control via secure SSH execution.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Hosting Providers: Companies utilizing WHMCS or WISECP that need to offer automated Grafana services based on Docker containers. DevOps Teams: Professionals seeking a robust n8n automation solution for remote server management and deployment orchestration.* n8n Automation Specialists: Users looking for advanced examples of integrating n8n with infrastructure management via SSH.

Overview

This specialized n8n templates solution solves the challenge of linking client billing actions (like 'Create Service' or 'Suspend') performed in WHMCS or WISECP directly to physical server management commands (like docker compose up or disk mounting/resizing). The entire process is abstracted behind a secure n8n webhook API. By leveraging the power of the n8n node ecosystem combined with dynamic Bash scripting, this n8n workflow ensures reliable deployment, resource management (CPU, RAM, Disk), container control (start/stop), and Nginx configuration updates on the target Docker server, making it an essential automation tool for offering managed Grafana hosting services.

How it Works

The automated process begins with the API n8n trigger (Webhook node) listening for POST requests carrying specific service commands (e.g., create, terminate) from the billing system.


  1. Validation and Initialization: After receiving the request, the Parametrs n8n node loads default configuration variables. An If n8n node performs a critical security check, validating the incoming server_domain against the expected domain. Invalid requests are immediately halted with a 422 error.

  2. Command Routing: The core logic uses several Switch n8n nodes (If1, Service Actions, Container Actions, Container Stat, Grafana) to route the request based on the requested command parameter.

  3. Script Generation: For the chosen action (e.g., Deploy, Suspend, Mount Disk), a dedicated Set n8n node dynamically constructs a comprehensive, idempotent Bash script, incorporating variables like the domain, disk size, and user credentials received from the n8n trigger input.

  4. Remote Execution: The dynamically generated Bash script is passed to the SSH n8n node, which executes it on the remote Docker server using predefined credentials.

  5. Response Handling: The Code1 n8n node receives the raw stdout/stderr output from the SSH session. It parses this output, standardizing it into a clean JSON format ({ "status": "success" } or { "status": "error", "message": "..." }).

  6. Final API Response: The API answer n8n node sends the standardized JSON result back to the calling billing system, confirming the outcome of the requested operation.

Installation Guide

To deploy this powerful n8n workflow template, follow these steps:


  1. Import: Import the provided n8n workflow JSON into your n8n instance.

  2. Webhook Credentials: Configure the API n8n node (Webhook) to use Basic Authentication. You must create and link a Basic Auth credential (IwjFGVb8SRb9Lm4u in the example, named 'Grafana') which will secure the API endpoint. The caller (WHMCS/WISECP module) must use these credentials.

  3. SSH Credentials: Configure the SSH n8n node. This requires a dedicated SSH Password or Key credential (Cyjy61UWHwD2Xcd8 in the example) that has sudo access to the remote Docker host where containers will be managed.

  4. Parameter Configuration: Navigate to the Parametrs n8n node and update the default values to match your server environment:

serverdomain: The domain name of the target server.
clients
dir: The root directory for client-specific Docker files.
* mount_dir: The base directory for disk mounts (e.g., /mnt).

  1. Activation: Ensure the n8n workflow is activated to enable the webhook listener and start receiving commands from your billing system.

Node Details

This n8n workflow relies on several core n8n node types to manage its complex logic:

API (Webhook Trigger): The starting point, acting as the secure API endpoint at /docker-grafana via POST method. This n8n trigger receives the core commands.
Parametrs (Set): Used for centralized configuration. Sets vital variables like serverdomain, clientsdir, and mount_dir for use across the entire n8n workflow.
If / Switch Nodes (If, If1, Service Actions, Container Actions, Container Stat, Grafana): These logic control n8n node types handle the complex routing, checking the input command value to direct the flow to the correct management script.
Deploy-docker-compose / nginx (Set): These nodes contain base configurations, specifically a dynamic Docker Compose YAML definition and Nginx configurations, which are injected into the SSH deployment script.
Deploy, Suspend, Terminated, ChangePackage, Start, Stop (Set): A series of Set n8n nodes dedicated to building specific, large Bash scripts (sh variable) for each lifecycle command. These scripts handle file system operations, fstab updates, Nginx proxy configuration, and docker compose execution.
SSH (SSH): The most critical n8n node. It securely executes the dynamically generated Bash script from the preceding Set node on the remote Docker host.
Code1 (Code): A utility n8n node responsible for parsing the text output received from the SSH command and converting it into a standardized JSON response format (success/error structure) before final output.
API answer (Respond to Webhook): The final n8n node, responsible for sending the HTTP response back to the client (WHMCS/WISECP) with the status of the operation.

Related n8n Workflows

Free

Nodes: 8 Nodes
Updated: December 26 2025
View all
Created by

PUQ sp. z o.o. is an international IT company building solutions to automate cloud and IT service sales. We created PUQcloud — a free, open-source platform for billing, automation, and IT business management. We also develop modules for WHMCS and WISECP, helping people start their own business without big tech. Our offices are in Poland and Canada, with a global team.

Featured*