Promtail config to env

I am trying to deploy promtail to ECS but i cannot find the way to send the correct config with env.

Promtail support config from env ? or i need somehow to save the config and mount it?

$ promtail -config.expand-env -client.url http://loki:3100/loki/api/v1/push -scrape_configs.job_name journal -scrape_configs.journal.path:  /var/log/test

Error

flag provided but not defined: -scrape_configs.job_name

My config for promtail

scrape_configs:
  - job_name: system
    static_configs:
    - targets:
        - localhost
      labels:
        job: varlogs
        hostname: {{ hostname }}
        __path__:  /var/log/syslog

What does your ECS task definition look like?

I didn’t create yet ECS task, i am trying first inside the promtail container to check how i need to create the ECS task.

I try in container with different env parameters but get the same error. Not sure what env parameters to give for scrape_configs

export scrape_configs.job_name=journal
bash: export: `scrape_configs.job_name=journal': not a valid identifier

I’ve not used Promtail this way, there is a chance some of the configurations aren’t interchangeable with environment variables. I’d recommend you to read through the documentation again just to double check.

Personally I mount configuration into promtail container directly.

Thanks :slight_smile: How you get the metadata from promtail i cannot find the task-id or container-id ?

I am not sure how you would get the container-id for Promtail. Perhaps there is a creative solution I am not thinking of. Personally I’ve not found the need to uniquely identify the Promtail container. If you are going to run on ECS, you should run Promtail in DAEMON mode (one count per host), in which case you can uniquely identify the Promtail container through EC2 instance ID.

Sorry for the multiple questions :slight_smile: What you mean DAEMON mode? I run ECS with fargate and not EC2 type. I just mount the log folder from my application to promtail in task definition

If you are using fargate then you probably need to do the discovery yourself. Enable container metadata, then you can get the task ID from within the container itself. Then add a script to promtail image and populate the task ID somehow to promtail configuration (populating task ID to an environment variable should work).

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.