Skip to content

Environment variables in the configuration does not work for client url #8917

@dorinand

Description

@dorinand

From the DOC, I understand, that I can use environment variables in promtail config if I configure promtail with -config.expand-env=true and use variable as ${VAR}.

I configure Loki client url with environment variable as described below:

clients:
  - url: ${LOKI_ADDR}/loki/api/v1/push

I run it as Swarm service:

  promtail:
    image: grafana/promtail:2.6.1
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./promtail/config/config.yaml:/etc/promtail/config.yml
      - ./promtail/positions:/positions
    command: -config.file=/etc/promtail/config.yml -config.expand-env=true
    environment:
      - NODE_HOSTNAME={{.Node.Hostname}}
      - LOKI_ADDR="http://loki:3100"

But when I run it, container will not start and raise error:

Unable to parse config: /etc/promtail/config.yml: yaml: line 9: did not find expected key

This is exactly, where - url: ${LOKI_ADDR}/loki/api/v1/push is (I am able to run it when replace env variable for url).

I would expect, I am able to configure client url with environment variable.

I am using environment variables in other places in configuration and its working:

  - static_labels:
      hostname: ${NODE_HOSTNAME}

Promtail version 2.6.1.

I cannot tell, if this is some bug or feature - environment variable can be used in scrape_configs perhaps?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions