How to modify the timezone in the container to Asia/Shanghai for the LOKI installed by Helm?

My loki distributed cluster has been installed.

# kubectl get pod -n loki
NAME                                               READY   STATUS    RESTARTS   AGE
loki-distributed-distributor-546ccbbccc-xck9n      1/1     Running   0          55m
loki-distributed-gateway-6979b8cb47-rvdzx          1/1     Running   0          55m
loki-distributed-ingester-0                        1/1     Running   0          12m
loki-distributed-querier-0                         1/1     Running   0          55m
loki-distributed-query-frontend-7f979c674b-94v8h   1/1     Running   0          55m

But the time zone on my local server is inconsistent with the time zone inside the container:

[root@kubernetes-master-001 ~]# kubectl exec -it -n loki loki-distributed-ingester-0 -- date
Wed May  8 03:08:15 UTC 2024
[root@kubernetes-master-001 ~]# date
Wed May  8 11:08:18 CST 2024

Causing me to report an error in the time zone when collecting logs on Promtail:

error="server returned HTTP status 400 Bad Request (400): entry for stream '{filename=\"/var/server.log\", job=\"api\", stream=\"stdout\", time=\"2023-17-03 15:30:49,150\"}' 
has timestamp too new: 2023-17-07T14:30:49Z"

How can I adjust the time zone inside the container to Asia/Shanghai?

That’s usually not needed. Make sure you have synchronized times on the servers. All components should be using UTC internally (that’s that “Z” at the end of timestamp - “zero” timezone).

Also customize out of order writes on Loki for your needs:

I restarted Promtail once, and this error disappeared. I don’t know why.

The timing of collecting Loki’s logs is also correct,As expected, thank you!