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; enable writing on the product service side.
Configure ENV_LOKI_URL on the HAP/HDP service side. The Ops Platform also has a variable with the same name, but they serve different purposes:
| Configuration Location | Purpose | Configuration Requirement |
|---|---|---|
| HAP/HDP service side | Write switch; empty by default. Service logs are not written to Loki unless configured | Configure this item |
Ops Platform side (ops.yaml/ConfigMap) | Query address; a default value is provided after deployment | No change required in standard topology |
Changing only the Ops Platform variable does not enable service log writing. The panel remains empty, and usually neither side reports an error.
Step 1: Set the Address for the Deployment Topology
A. Product Services and Ops Platform in the Same Kubernetes Cluster
ENV_LOKI_URL=http://ops-loki.<运维平台所在命名空间>.svc.cluster.local:3100
Use the actual namespace where the Ops Platform is deployed (deployment configuration defaults to hap-ops). Confirm it with:
kubectl get svc -A | grep ops-loki
The first output column is the namespace.
The Ops Platform ops-loki is a ClusterIP Service and can be resolved only inside the cluster. Using the node IP
returns 503 or a connection failure. Use Service DNS even when the target machine is the Ops Platform node.
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 Ops Platform share the same Docker network.
C. Ops Platform on a Standalone Host (Docker Compose), Product Services on Another Host
ENV_LOKI_URL=http://运维平台主机IP:3100
Configure the 3100:3100 port mapping for ops-loki and restrict access to that port. The Docker Compose configuration example used here disables this mapping by default. Uncomment the corresponding configuration for cross-host access.
D. Ops Platform on Kubernetes, Product Services Outside the Cluster
Expose ops-loki through NodePort or Ingress first (the default ClusterIP is inaccessible outside the cluster), then set ENV_LOKI_URL
to the external address.
Step 2: Restart Product Services
For standalone deployment, modify docker-compose.yaml or .env; for cluster deployment, modify the corresponding ConfigMap (private deployment services usually centralize configuration in env-list). The variable is read at startup, so restart product services after modification.
Step 3: Confirm Connectivity
- In any product service container, verify reachability using the configured address:
curl -s -o /dev/null -w '%{http_code}\n' <你填的 ENV_LOKI_URL>/ready
200 indicates connectivity. 503 usually indicates an incorrect address, such as a node IP in scenario A.
-
Trigger a business operation, such as login or sending a verification code, to make microservices write logs.
-
Refresh Log Search in the Ops Platform and confirm that the "Service Logs" panel has content.
If the page remains empty, see FAQs.
Container Logs
The "Container Console" panel queries container stdout/stderr. Collection depends on deployment topology:
| Deployment Topology | Collection Method | Configuration Requirement |
|---|---|---|
| Standalone (Docker Compose) | ops-alloy collects Docker container logs through /var/run/docker.sock | No configuration required; enabled automatically after deployment |
Cluster · PVC (k8s-cluster/) | alloy-logs in 50-daemonsets.yaml reads Pod logs through the Kubernetes API | No configuration required; deployed with the manifests |
Cluster · hostPath (single-file ops.yaml) | No collection by default | Deploy alloy-logs separately, as described below |
The hostPath deployment manifest does not include Kubernetes container log collection components. The Docker log collection configuration in ops-alloy cannot collect Kubernetes Pod logs.
The "Container Console" panel will have no data, and usually neither side reports an error. Install
40-alloy-logs.yaml from k8s-addons.tar.gz. Before deployment, check the image address and version in this file and ensure that every node can pull the image; image versions in the package do not update automatically with site configuration. Modify the configuration according to the Ops Platform location:
- Ops Platform in the same cluster: use
http://ops-loki.<运维平台所在命名空间>.svc.cluster.local:3100/loki/api/v1/push, and leaveENV_LOKI_PUSH_TOKENempty - Ops Platform in another cluster:
ops-lokiis ClusterIP and inaccessible across clusters; use the gatewayhttp://<运维平台地址>:30881/mdis/loki/api/v1/pushand setENV_LOKI_PUSH_TOKENto the Ops Platform'sENV_OPS_TOKEN(the gateway write endpoint uses Bearer authentication and returns 401 without a token)
Incorrect values for these two settings usually produce no explicit error; the panel simply has no data.
After modification, deploy in the monitored cluster:
kubectl apply -f k8s-addons/00-namespace.yaml
kubectl apply -f k8s-addons/40-alloy-logs.yaml
See Log Search for details about both panels.