Metricbeat have default parameter

Hi, Is there a way to set a config params as optional. I want to give our freedom to set the period (scrape interval) optionally. What I tried so far was this

templates:
            - condition.and:
              - equals:
                  kubernetes.annotations.prometheus.io/scrape: "true"
              - has_fields:
                  ["kubernetes.annotations.prometheus.io/scrape_interval"]
              config:
                - module: prometheus
                  metricsets: ["collector"]
                  hosts: ["${data.host}:${data.kubernetes.annotations.prometheus.io/port}"]
                  metrics_path: ${data.kubernetes.annotations.prometheus.io/path}
                  period: ${data.kubernetes.annotations.prometheus.io/scrape_interval}
            - condition.and:
              - equals:
                  kubernetes.annotations.prometheus.io/scrape: "true"
              - not:
                has_fields:
                  ["kubernetes.annotations.prometheus.io/scrape_interval"]
              config:
                - module: prometheus
                  metricsets: ["collector"]
                  hosts: ["${data.host}:${data.kubernetes.annotations.prometheus.io/port}"]
                  metrics_path: ${data.kubernetes.annotations.prometheus.io/path}
                  period: 30s

It does not seem to work however. Does someone have any idea on how to achieve this?

Using this seems to work

            - condition.and:
              - equals:
                  kubernetes.annotations.prometheus.io/scrape: "true"
              - not.has_fields:
                  ["kubernetes.annotations.prometheus.io/scrape_interval"]