Reporting Logs to LTS
Scenario
Log Tank Service (LTS) analyzes and processes massive amounts of log data to maximize the availability and performance of cloud services and applications. CCI 2.0 reports logs of containers in each pod to LTS.
- Log in to the LTS console and create a log group.
- Create a log stream in the created log group.
- Log in to the CCI 2.0 console. In the navigation pane, choose Workloads. On the Deployments tab, click Create from YAML.
- Edit the YAML file.
apiVersion: cci/v2 kind: Deployment metadata: name: test spec: replicas: 1 selector: matchLabels: app: test template: metadata: annotations: logconf.k8s.io/fluent-bit-log-type: lts # Where logs are reported logconfigs.logging.openvessel.io: "{\"default-config\":{\"container_files\":{\"container-0\":\"stdout.log;/root/out.log;/data/emptydir-volume/*.log\"},\"regulation\":\"/(?<log>\\\\d+-\\\\d+-\\\\d+ \\\\d+:\\\\d+:\\\\d+.*)/\",\"lts-log-info\":{\"349b50f7-f6ba-4768-86f9-e7f84ab677c0\":\"8a9e0589-c3b5-4ed1-b8cd-1e8a54612d0e\"}}}" # Log reporting configuration labels: app: test spec: containers: - image: centos:latest command: ['sh', '-c', "while true; do echo hello; touch /root/out.log; echo hello >> /root/out.log; touch /data/emptydir-volume/emptydir.log; echo hello >> /data/emptydir-volume/emptydir.log; sleep 10; done"] # Command used to simulate log writing volumeMounts: - name: emptydir-volume mountPath: /data/emptydir-volume - name: emptydir-memory-volume mountPath: /data/emptydir-memory-volume name: container-0 resources: limits: cpu: 100m memory: 100Mi requests: cpu: 100m memory: 100Mi volumes: - name: emptydir-volume emptyDir: {} - name: emptydir-memory-volume emptyDir: sizeLimit: 1Gi medium: Memory strategy: type: RollingUpdate rollingUpdate: maxSurge: 1 maxUnavailable: 0
In annotations, logconfigs.logging.openvessel.io specifies configuration items for log reporting, and the configuration items are in JSON format. The following describes each configuration item:
{ "default-config": { // Configuration name. You can change it as needed. "container_files": { // You can set the log collection paths of multiple containers. stdout.log indicates standard output. /root/out.log indicates the text logs in rootfs (volumes included). /data/emptydir-xxx/*.log indicates the directories in rootfs (volumes included). "container-0": "stdout.log;/root/out.log;/data/emptydir-volume/*.log", ... }, "regulation": "/(?<log>\\d+-\\d+-\\d+ \\d+:\\d+:\\d+.*)/", // Regular expression matching rule for collecting multi-line logs "lts-log-info": { // Only one log group and one log stream are allowed. "f938a11a-678e-4631-80a0-3667be1280f7": "a248c18b-61ed-4de2-8f7f-c042b78bb0fd" // Log group ID and log stream ID in the format of {log-group-ID}:{log-stream-ID} } }, "other-config": { // Other settings ... } }
- Wait until the workload enters the running state and click View Log in the Operation column to view the logs reported by the pod.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot