# Metricbeat have default parameter

**URL:** <https://discuss.elastic.co/t/metricbeat-have-default-parameter/250633>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [October 1, 2020, 9:46am UTC](https://discuss.elastic.co/t/metricbeat-have-default-parameter/250633 "2020-10-01T09:46:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonas27](https://avatars.discourse-cdn.com/v4/letter/j/b2d939/32.png) [@jonas27](https://discuss.elastic.co/u/jonas27)\
**Post date:** [October 1, 2020, 9:46am UTC](https://discuss.elastic.co/t/metricbeat-have-default-parameter/250633/1 "2020-10-01T09:46:48Z")

</div>

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

```auto
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?

---

<div class="post-metadata">

**Author:** ![jonas27](https://avatars.discourse-cdn.com/v4/letter/j/b2d939/32.png) [@jonas27](https://discuss.elastic.co/u/jonas27)\
**Post date:** [October 8, 2020, 6:51am UTC](https://discuss.elastic.co/t/metricbeat-have-default-parameter/250633/2 "2020-10-08T06:51:03Z")

</div>

Using this seems to work

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

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 5, 2020, 6:51am UTC](https://discuss.elastic.co/t/metricbeat-have-default-parameter/250633/3 "2020-11-05T06:51:05Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
