Search code examples
kuberneteskubernetes-helmprometheus-alertmanagerkube-prometheus-stack

Changing timezone of alertmanager in kube-prometheus-stack helm chart


I am currently using emailing alerts for our application. One of the contents of the email is the start and end time of the alert but they are displaying as UTC+0000.

Tried using .Start.Local.Format but realized that the only time that alertmanager pod has it UTC+0000. Was wondering if there is a way I can set the pod timezone


Solution

  • You can change the timezone of pods by using volumes and volumeMounts to specify the timezone, like :

    volumeMounts:
        - name: tz-config
          mountPath: /etc/localtime
      volumes:
        - name: tz-config
          hostPath:
            path: /usr/share/zoneinfo/America/Chicago
    

    Or you can use the "TZ" environment variable in the container section inside the pod spec, to configure the desired time zone:

    spec:
     containers:
      - name:
      foo-bar
      image: foobar:latest
      imagePullPolicy: Always
      env:
       - name: TZ
       value: America/Chicago
    

    This changes the timezone displayed by the pod, which you can confirm using "kubectl exec POD date".

    The Default Dashboards Timezone is utc. Attaching the list of timezones for reference.