I am playing with Grafana and Promtail. I have the following setup:
version: "3.3"
networks:
  loki:
services:
  loki:
    image: grafana/loki:k88-c660a7e
    ports:
      - "3100:3100"
    command: -config.file=/etc/loki/local-config.yaml
    networks:
      - loki
  promtail:
    image: grafana/promtail:k88-c660a7e
    volumes:
      - /var/lib/docker/containers:/var/lib/docker/containers
      - /var/run/docker.sock:/var/run/docker.sock
      - ./promtail-config.yaml:/etc/promtail/promtail-config.yaml
    command: -config.file=/etc/promtail/promtail-config.yaml
    networks:
      - loki
  grafana:
    image: grafana/grafana:latest
    ports:
      - "3000:3000"
    volumes:
      - ./grafana-config.yaml:/etc/grafana/provisioning/datasources/default.yaml
    networks:
      - loki
  mycontainer: # Prints debug output to stdout
    build: .
    labels:
      - "mylabel=true"
    networks:
      - loki
What I want to achieve:
- Have Promtail ignore all other containers except ones that have the 
mylabel=true - Have Grafana display a label with the container name as label in the log explorer
 
My current promtail-config.yaml scrape-configs:
scrape_configs:
- job_name: containers
  docker_sd_configs:
    - host: unix:///var/run/docker.sock
  relabel_configs: # For some reason this drops all logs
    - source_labels: [__meta_docker_container_label_mylabel]
      regex: "true"
      action: keep
  static_configs:
  - targets:
      - localhost
    labels:
      job: containerlogs
      __path__:  /var/lib/docker/containers/*/*-json.log
  pipeline_stages:
    - docker:
How do I change it to achieve that?
EDIT: This is probably going to come up - support for docker_sd_configs option is not officially released yet, but I have confirmed with a contributor to the project that it is available and in fact running in their cloud.