Labeling Logs with Folder Name

I am trying to label all logs that come out of a folder with the name of the folder. This is my current config. Basically I want the logs to be labeled with the name of the * value. I’ve tried different regex methods i’ve found but anything I try keeps Grafana Agent service from starting.

logs:
  positions_directory: C:\ProgramData\grafana-agent\log-positions
  configs:
    - name: default
      positions:
        filename: /tmp/positions.yaml
      scrape_configs:
        - job_name: BackgroundIndexer
          static_configs:
            - targets:
              - localhost
              labels:
                job: BackgroundIndexer
                __path__: L:\BackgroundIndexer\*\*.txt

Resolved it with help from this link

logs:
  positions_directory: C:\ProgramData\grafana-agent\log-positions
  configs:
    - name: default
      positions:
        filename: /tmp/positions.yaml
      scrape_configs:
        - job_name: BackgroundIndexer
          static_configs:
            - targets:
              - localhost
              labels:
                job: BackgroundIndexer
                __path__: L:\BackgroundIndexer\*\*
          pipeline_stages:
          - match:
              selector: '{job="BackgroundIndexer"}'
              stages:
              - regex:
                  source: filename
                  expression: 'L:\\BackgroundIndexer\\(?P<customer>[^\\]+)\\'
              - labels:
                  customer:
1 Like