prometheus / prometheus/alertmanager

docker image does not recognise timezone appropriately

Open
#3,810 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stale
Dominant language
Go
Stars
8.6k
Forks
2.5k
Avg merge
2d 6h
Merged PRs (30d)
61

Description

What did you do?
My compose.yaml file looks like this:

services:
  alertmanager:
    image: quay.io/prometheus/alertmanager:latest
    container_name: alertmanager
    hostname: alertmanager
    privileged: true
    command: --config.file=/etc/alertmanager/alertmanager.yaml --log.level=info
    ports:
      - 9093:9093 # web ui
    environment:
      - TZ=America/Edmonton
      - BOT_TOKEN=${BOT_TOKEN}
      - CHAT_ID=${CHAT_ID}
    volumes:
      - ${DIRECTORY_DATA}:/data
      - ${DIRECTORY_ETCALERTMANAGER}:/etc/alertmanager
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped

What did you expect to see?
The time in the container to represent the timezone passed by the compose file.

What did you see instead? Under which circumstances?
Using the following commands:

$ docker exec alertmanager date
Mon Apr 15 17:00:34 UTC 2024

$ docker exec alertmanager cat /etc/timezone
America/Edmonton

The timezone is available to the container but is not being recognised.

Environment

  • System information:

    Linux 6.1.0-18-amd64 x86_64

  • Alertmanager version:

$ docker exec alertmanager alertmanager --version
alertmanager, version 0.27.0 (branch: HEAD, revision: 0aa3c2aad14cff039931923ab16b26b7481783b5)
build user:       root@22cd11f671e9
  build date:       20240228-11:51:20
  go version:       go1.21.7
  platform:         linux/amd64
  tags:             netgo
  • Prometheus version:
$ docker exec prometheus prometheus --version
prometheus, version 2.51.2 (branch: HEAD, revision: b4c0ab52c3e9b940ab803581ddae9b3d9a452337)
  build user:       root@b63f02a423d9
  build date:       20240410-14:05:54
  go version:       go1.22.2
  platform:         linux/amd64
  tags:             netgo,builtinassets,stringlabels
  • Alertmanager configuration file:
global:
  resolve_timeout: 10m

route:
  group_by: ['alertname']
  group_wait: 30s
  group_interval: 30s
  repeat_interval: 5m
  receiver: 'telegram'

receivers:
- name: 'telegram'
  telegram_configs:
  - send_resolved: true
    api_url: https://api.telegram.org
    bot_token: $BOT_TOKEN
    chat_id: $CHAT_ID
    parse_mode: HTML
  • Prometheus configuration file:
    n/a

  • Logs:

alertmanager  | ts=2024-03-20T15:40:52.935Z caller=main.go:181 level=info msg="Starting Alertmanager" version="(version=0.27.0, branch=HEAD, revision=0aa3c2aad14cff039931923ab16b26b7481783b5)"
alertmanager  | ts=2024-03-20T15:40:52.935Z caller=main.go:182 level=info build_context="(go=go1.21.7, platform=linux/amd64, user=root@22cd11f671e9, date=20240228-11:51:20, tags=netgo)"
alertmanager  | ts=2024-03-20T15:40:52.936Z caller=cluster.go:186 level=info component=cluster msg="setting advertise address explicitly" addr=192.168.93.141 port=9094
alertmanager  | ts=2024-03-20T15:40:52.937Z caller=cluster.go:683 level=info component=cluster msg="Waiting for gossip to settle..." interval=2s
alertmanager  | ts=2024-03-20T15:40:53.008Z caller=coordinator.go:113 level=info component=configuration msg="Loading configuration file" file=/etc/alertmanager/alertmanager.yaml
alertmanager  | ts=2024-03-20T15:40:53.009Z caller=coordinator.go:126 level=info component=configuration msg="Completed loading of configuration file" file=/etc/alertmanager/alertmanager.yaml
alertmanager  | ts=2024-03-20T15:40:53.013Z caller=tls_config.go:313 level=info msg="Listening on" address=[::]:9093
alertmanager  | ts=2024-03-20T15:40:53.013Z caller=tls_config.go:316 level=info msg="TLS is disabled." http2=false address=[::]:9093
alertmanager  | ts=2024-03-20T15:40:54.938Z caller=cluster.go:708 level=info component=cluster msg="gossip not settled" polls=0 before=0 now=1 elapsed=2.000347913s
alertmanager  | ts=2024-03-20T15:41:02.940Z caller=cluster.go:700 level=info component=cluster msg="gossip settled; proceeding" elapsed=10.002336569s

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with compose.yaml and reproduce the container behavior using docker exec alertmanager date, then compare the TZ environment variable with the mounted /etc/timezone and /etc/localtime files. Inspect the Alertmanager image build configuration to determine how timezone data is provided; done means the container date command reflects America/Edmonton when rebuilt and run with this configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, docker-compose, go
Domain
devops, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.