Docker Compose
This page describes deploying the Ops Platform with Docker Compose. Deployment on the same server as HAP/HDP is recommended. The following steps assume this arrangement; run all commands on that server.
Prerequisites
- Ensure at least 4 available CPU cores, 8 GB of memory, and 200 GB of disk space on the server.
- Ensure Docker and Docker Compose are installed and the Docker service is running normally.
- Confirm port
48881is available and accessible to clients. If mapping ports3100,4317, or4318, also check their availability and restrict access appropriately. - Prepare accounts for monitored middleware. For permissions, see Data Sources.
Check the Docker service:
docker info
Check the Docker Compose version. Either command below must print version information; if the first command is unavailable, try the second:
docker compose version
docker-compose --version
The example stores Ops Platform configuration and data in /data/mingdao/mdis/.
1. Prepare the Directory and Network
Create the deployment directory:
mkdir -p /data/mingdao/mdis
Sharing a Docker network with HAP/HDP allows the Ops Platform to access middleware and databases by container service name without exposing additional ports. HAP/HDP uses the script_default network by default. Confirm the network name:
docker network ls
The configuration below uses script_default. If HAP/HDP uses another network, replace it with the actual name after creating the configuration file. The network must already exist.
2. Obtain the Image
In online environments, pull the image with the following command. In offline environments, download and import the offline image package.
docker pull registry.cn-hangzhou.aliyuncs.com/mdpublic/ops-allinone:1.5.12
3. Create the Configuration File
Create and edit /data/mingdao/mdis/ops.yaml:
vim /data/mingdao/mdis/ops.yaml
Write the following content to the file. It configures the Ops Platform's services, network, and data directories. Add monitored targets on the Data Sources page after deployment.
# All services use the same image
x-ops-image: &ops_image registry.cn-hangzhou.aliyuncs.com/mdpublic/ops-allinone:1.5.12
x-common-env: &common_env
TZ: "Asia/Shanghai"
ENV_OPS_TOKEN: "your-ops-access-token-change-me" # Login token; replace with a strong password during deployment
ENV_ALERT_CRYPTO_KEY: "change-me-to-32-byte-secret" # Credential encryption key; replace with a random key during deployment and keep it safe
ENV_OPS_SUB_PATH: &ops_sub_path /mdis # Shared access sub-path; use "" for the root path
ENV_PROMETHEUS_SERVER: "http://ops-prometheus:9090" # Built-in Prometheus address
ENV_OPS_MONGODB_URI: "mongodb://ops-mongo:27017" # Ops Platform's own MongoDB address
ENV_MONGODB_COLLECTION_PREFIX: "mdis_" # Ops Platform MongoDB collection name prefix
services:
gateway:
image: *ops_image
restart: always
ports:
- "48881:48881" # Ops Platform access port
environment:
<<: *common_env
ROLE: gateway
depends_on:
- ops-prometheus
- ops-grafana
- ops-loki
- ops-tempo
- ops-alloy
- ops-mongo
ops-prometheus:
image: *ops_image
restart: always
volumes:
- ./volume/data/mdis/prometheus/:/data/mdis/prometheus/
environment:
<<: *common_env
ROLE: prometheus
ops-grafana:
image: *ops_image
restart: always
volumes:
- ./volume/data/mdis/grafana/:/data/mdis/grafana/
environment:
<<: *common_env
ROLE: grafana
GF_SECURITY_ALLOW_EMBEDDING: "true"
GF_AUTH_ANONYMOUS_ENABLED: "true"
GF_AUTH_ANONYMOUS_ORG_ROLE: Editor
GF_SECURITY_COOKIE_SAMESITE: lax
GF_USERS_DEFAULT_THEME: light
ops-loki:
image: *ops_image
restart: always
# Used for service log ingestion across hosts; ops-loki is directly accessible on a shared Docker network
# ports:
# - "3100:3100"
volumes:
- ./volume/data/mdis/loki/:/data/mdis/loki/
environment:
ROLE: loki
ENV_LOKI_RETENTION: "720h" # Retain logs for 30 days
ops-tempo:
image: *ops_image
restart: always
volumes:
- ./volume/data/mdis/tempo/:/data/mdis/tempo/
environment:
ROLE: tempo
ENV_TEMPO_RETENTION: "720h" # Retain trace data for 30 days
ops-alloy:
image: *ops_image
restart: always
# To receive OTLP through the host address, uncomment the port mapping for the required protocol
# ports:
# - "4317:4317" # OTLP gRPC receiving port
# - "4318:4318" # OTLP HTTP receiving port
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./volume/data/mdis/alloy/:/data/mdis/alloy/
environment:
ROLE: alloy
ENV_OPS_SUB_PATH: *ops_sub_path
ENV_TEMPO_GRPC_URL: "http://ops-tempo:4317"
ENV_PROMETHEUS_REMOTE_WRITE_URL: "http://ops-prometheus:9090/prometheus/server/api/v1/write"
ENV_LOKI_PUSH_URL: "http://ops-loki:3100/loki/api/v1/push"
# Stores Ops Platform data sources, alerts, slow-query history, and other data
ops-mongo:
image: *ops_image
restart: always
environment:
ROLE: mongo
volumes:
- ./volume/data/mdis/mongo/:/data/mdis/mongo
agent:
image: *ops_image
restart: always
environment:
<<: *common_env
ROLE: agent
nodeagent:
image: *ops_image
restart: always
volumes:
- /:/host:ro,rslave
network_mode: host
pid: host
environment:
<<: *common_env
ROLE: nodeagent
# Reuse the HAP/HDP Docker network; replace with the actual name if different
networks:
default:
external: true
name: script_default
Before saving the file, replace the example values of the following environment variables with actual values:
| Environment Variable | Description |
|---|---|
ENV_OPS_TOKEN | Ops Platform login token. Use a strong password |
ENV_ALERT_CRYPTO_KEY | Credential encryption key. Generate it separately and keep it safe. Changing it later makes existing encrypted credentials impossible to decrypt |
Run the following command twice to generate separate random values for the login token and credential encryption key, then enter them in the corresponding environment variables:
openssl rand -hex 16
The example stores monitoring metrics, logs, and Ops Platform MongoDB data in volume/data/mdis/ under the deployment directory.
Loki stores logs locally by default. Object Storage is also supported.
4. Start the Ops Platform
Validate the configuration file. Run one of the following commands according to the Docker Compose command available on the server. It exits normally if no configuration errors are found:
docker compose -f /data/mingdao/mdis/ops.yaml config --quiet
docker-compose -f /data/mingdao/mdis/ops.yaml config --quiet
Create the start script:
cat > /data/mingdao/mdis/start.sh <<'EOF'
#!/usr/bin/env bash
script_dir="$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")")"
if docker compose version >/dev/null 2>&1; then
docker compose -f "$script_dir/ops.yaml" up -d
else
docker-compose -f "$script_dir/ops.yaml" up -d
fi
EOF
Create the stop script:
cat > /data/mingdao/mdis/stop.sh <<'EOF'
#!/usr/bin/env bash
script_dir="$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")")"
if docker compose version >/dev/null 2>&1; then
docker compose -f "$script_dir/ops.yaml" down
else
docker-compose -f "$script_dir/ops.yaml" down
fi
EOF
Make the scripts executable:
chmod +x /data/mingdao/mdis/start.sh /data/mingdao/mdis/stop.sh
Start the services:
/data/mingdao/mdis/start.sh
To stop the Ops Platform later, run:
/data/mingdao/mdis/stop.sh
5. Access and Verify
Check container status:
docker ps -a
Once all Ops Platform containers show Up, open the following address in a browser:
http://部署服务器IP:48881/mdis/web/
Log in with ENV_OPS_TOKEN from the configuration file and confirm that the overview page displays correctly. If ENV_OPS_SUB_PATH was changed, replace /mdis in the access URL with the actual path.
The example uses YAML anchors to share the access sub-path among gateway, Grafana, Alloy, and other components. Keep these references when changing it; use "" for the root path.
If a container is not running normally, use its name from the docker ps -a output to check logs:
docker logs --tail 100 容器名称
Replace 容器名称 in the command with the actual container name. See FAQs for other troubleshooting methods.
Next Steps
After deployment, configure the following as needed:
- Add monitored hosts, middleware, or custom pages in Data Sources.
- Configure the log push address on HAP/HDP services to ingest Service Logs.
- To monitor other servers, deploy Node Exporter on each target server.
- To monitor a Kubernetes cluster, deploy the collection components in the target cluster.
The Ops Platform automatically collects container logs on its deployment server through Alloy. Tracing is supported only in HAP/HDP Kubernetes environments. See Tracing.