Promtail relabel_configs issue

Hi, I found the configuration of relabel on GitHubhttps://github.com/grafana/loki/blob/main/production/ksonnet/promtail/scrape_config.libsonnet, I would like to know what this writing means and how should I use regex? What is the value of ‘$1’. Where can I find more examples of such relabel_configs? thanks~

      {
        source_labels: [pod_uid, '__meta_kubernetes_pod_container_name'],
        target_label: '__path__',
        separator: '/',
        replacement: '/var/log/pods/*$1/*.log',
      },

In addition, I deployed promtail in k8s, but I customized the log path, such as ‘/var/log/{namespace}/{appname}’, and according to the official writing method is to collect logs under the path of ‘/var/log/pods’; so I think By modifying the following configuration:

      - action: replace
        source_labels:
          - __meta_kubernetes_pod_container_name
        target_label: container
      - action: replace
        replacement: /var/log/pods/*$1/*.log
        separator: /
        source_labels:
          - __meta_kubernetes_pod_uid
          - __meta_kubernetes_pod_container_name
        target_label: __path__
      - action: replace
        replacement: /var/log/pods/*$1/*.log
        regex: true/(.*)
        separator: /
        source_labels:
          - __meta_kubernetes_pod_annotationpresent_kubernetes_io_config_hash
          - __meta_kubernetes_pod_annotation_kubernetes_io_config_hash
          - __meta_kubernetes_pod_container_name
        target_label: __path__

Is it feasible to change the path to my custom path? the configuration like follow:

     - action: replace
        replacement: /var/log/{namespace}/{appname}/*.log
        separator: /
        source_labels:
          - namespace   #This label is defined from the previous
          - app               #This label is defined from the previous
        target_label: __path__
      - action: replace
        replacement: /var/log/applog/*$1/*.log
        regex: true/(.*)
        separator: /
        source_labels:
          - __meta_kubernetes_pod_container_name
        target_label: __path__

What I want to do is to define ‘path’ according to ‘namespace’ and ‘appname’ tags to collect logs saved under this path. Is it possible to do this by modifying relabel_configs?