1

我正在尝试从我的 docker 容器中获取 stdout/stderr 到loki. 我有基本的工作,但我想用client我的docker-compose.yaml.

我的相关部分docker-compose.yml

  x-logging-defaults: &logging_defaults
    logging:
      driver: "fluentd"
      options:
        fluentd-address: 10.10.10.1:24224
        tag: docker.application
        labels: "client=the-client"     # here?
    labels:
      - client=the-client              # or here?

部分fluent.conf

<filter docker.**>
  @type record_transformer
  <record>
    hostname "#{Socket.gethostname}"

    # I think magic goes here, I've tried many variations
    # of the following examples
    client $.client
    client $.docker.label.client      
    client ${ record.dig("labels", "client") }
  </record>
</filter>

<match docker.**>
    @type loki
    url "http://loki.service.consul:3100"
    <label>
        client $.client   # more magic here?
    </label>
    extra_labels {
        "client": "or maybe here?"
    }
</match>
4

0 回答 0