Coding Global Background
Coding Global

How to fetch .env values to assign alertmanager.yml file (not a valid value)

Archived a year ago
1 messages
2 members
Created a year ago
Updated a year ago
Open in Discord
D
direct_x_34
Script Kiddie!
In my spring boot project, I connect alertmanager with prometheus and grafana but I cannot fetch properties values from .env and assign them to alertmanager.yml

Here is the alertmanager part of docker-compose.yml
      alertmanager:
        image: prom/alertmanager:latest
        container_name: alertmanager
        restart: unless-stopped
        ports:
          - "9093:9093"
        volumes:
          - ./data/alertmanager/config:/etc/alertmanager
        env_file:
          - .env
        command:
          - '--config.file=/etc/alertmanager/alertmanager.yml'
        networks:
          - pdfcompare_network


Here is the .env
    ALERT_RESOLVE_TIMEOUT=5m
    SMTP_SMARTHOST=smtp.gmail.com:587
    SMTP_FROM=gmail_email
    SMTP_AUTH_USERNAME=gmail_email
    SMTP_AUTH_PASSWORD=gmail_authentication_password
    SMTP_REQUIRE_TLS=true
    ALERT_EMAIL_TO=gmail_email


Here is alertmanager.yml
    global:
      resolve_timeout: ${ALERT_RESOLVE_TIMEOUT}
      smtp_smarthost: ${SMTP_SMARTHOST}
      smtp_from: ${SMTP_FROM}
      smtp_auth_username: ${SMTP_AUTH_USERNAME}
      smtp_auth_password: ${SMTP_AUTH_PASSWORD}
      smtp_require_tls: ${SMTP_REQUIRE_TLS}
    
    route:
      group_by: ['alertname']
      group_wait: 30s
      group_interval: 5m
      repeat_interval: 5m
      receiver: 'default'
    
    receivers:
      - name: 'default'
        webhook_configs:
          - url: 'http://grafana:3000'
        email_configs:
          - to: ${ALERT_EMAIL_TO}
            send_resolved: true


I got this error shown below
    level=ERROR source=coordinator.go:117 msg="Loading configuration file failed" component=configuration file=/etc/alertmanager/alertmanager.yml err="not a valid duration string: \"${ALERT_RESOLVE_TIMEOUT}\""

How can I fix it?