Skip to main content

Service Logs

The "Service Logs" panel queries structured logs that HAP/HDP microservices push to the Ops Platform Loki. Logs are not pushed by default. The write switch must be enabled on the product service side.

Key Configuration

The variable to configure is ENV_LOKI_URL on the HAP/HDP service side. The Ops Platform side also has a variable with the same name, but they serve different purposes:

Where to ConfigurePurposeShould It Be Changed?
HAP/HDP service sideWrite switch. Empty by default. If not configured, service logs are not written to LokiConfigure this item
Ops Platform side (ops.yaml/ConfigMap)Query address. A default value already exists after deployment❌ No change required in standard topology

Only changing the Ops Platform side variable does not enable service log writing. The panel remains empty, and usually neither side reports an error.

Step 1: Fill in the Address by Deployment Form

A. Product Services and Ops Platform in the Same Kubernetes Cluster

ENV_LOKI_URL=http://ops-loki.<Ops-Platform-namespace>.svc.cluster.local:3100

Use the actual namespace where the Ops Platform is deployed (the default manifest uses hap-ops). Confirm it with:

kubectl get svc -A | grep ops-loki

The first column in the output is the namespace.

Do not use a node IP

The Ops Platform ops-loki is a ClusterIP Service and can be resolved only inside the cluster. Using the IP of the node where the Ops Platform runs may return 503 or connection failure. Use Service DNS instead.

B. Product Services and Ops Platform on the Same Host, Both Using Docker Compose

ENV_LOKI_URL=http://ops-loki:3100

Use the service name directly, provided that the product services and the Ops Platform are connected to the same Docker network.

C. Ops Platform Standalone Deployment (Docker Compose), Product Services on Another Host

ENV_LOKI_URL=http://<Ops-Platform-host-IP>:3100

ops-loki must expose the 3100:3100 port mapping. The bundled ops.yaml includes this mapping by default since 1.5.3; earlier versions require manual addition.

D. Ops Platform Cluster Deployment (Kubernetes), Product Services Outside the Cluster

First expose ops-loki through NodePort or Ingress (the default ClusterIP cannot be accessed from outside the cluster), and then set ENV_LOKI_URL to that external address.

Step 2: Restart Product Services After Modification

The variable is read at startup, so product services must be restarted for the change to take effect. For standalone deployment, modify docker-compose.yaml/.env. For cluster deployment, modify the corresponding ConfigMap (private deployment services are usually centralized in env-list).

Step 3: Confirm Connectivity

1. In any product service container, verify reachability with the configured address:

curl -s -o /dev/null -w '%{http_code}\n' <configured-ENV_LOKI_URL>/ready

200 means the address is reachable. 503 usually means the address is incorrect, such as using a node IP in scenario A.

2. Trigger a business operation (such as login or sending a verification code). Microservices write logs only after actual execution.

3. Refresh Log Search in the Ops Platform. The "Service Logs" panel should show content.

If the page remains empty, see FAQs.

Container Logs

The "Container Console" panel queries stdout/stderr from containers. It is independent from service logs above. The collector depends on deployment form:

Deployment FormCollectorConfiguration
Standalone (Docker Compose)ops-alloy collects Docker container logs through /var/run/docker.sockNo configuration required; enabled after deployment
Cluster · PVC (k8s-cluster/)alloy-logs in 50-daemonsets.yaml reads Pod logs through the Kubernetes APINo configuration required; deployed with the manifest
Cluster · hostPath (single-file ops.yaml)Not collected by default⚠️ Deploy alloy-logs separately, as described below
hostPath deployment cannot collect container logs without alloy-logs

The single-file ops.yaml contains only the Ops Platform itself and no Kubernetes collection components. ops-alloy collects Docker containers, while Kubernetes uses containerd, so it cannot collect any Pod logs in the cluster. Startup logs clearly state this and skip the collection section.

As a result, the "Container Console" panel has no data, and usually neither side reports an error. Install 40-alloy-logs.yaml from k8s-addons.tar.gz:

tar xzf k8s-addons.tar.gz
kubectl -n mdis-monitoring apply -f 00-namespace.yaml -f 40-alloy-logs.yaml

Before applying, edit ENV_LOKI_PUSH_URL in 40-alloy-logs.yaml:

  • Ops Platform in the same cluster: http://ops-loki.<Ops-Platform-namespace>.svc.cluster.local:3100/loki/api/v1/push
  • Ops Platform in another cluster: ops-loki is ClusterIP and cannot be accessed across clusters. Use the gateway http://<Ops-Platform-address>:30881/mdis/loki/api/v1/push, and set ENV_LOKI_PUSH_TOKEN to the Ops Platform ENV_OPS_TOKEN.

See Log Search for details about the two panels.