Metricbeat supports templates for modules:

["source","yaml",subs="attributes"]
-------------------------------------------------------------------------------
metricbeat.autodiscover:
  providers:
    - type: jolokia
      interfaces:
      - name: br*
        interval: 5s
        grace_period: 10s
      - name: en*
      templates:
      - condition:
          contains:
            jolokia.server.product: "tomcat"
        config:
        - module: jolokia
          metricsets: ["jmx"]
          hosts: "${data.jolokia.url}"
          namespace: test
          jmx.mappings:
          - mbean: "java.lang:type=Runtime"
            attributes:
            - attr: Uptime
              field: uptime
-------------------------------------------------------------------------------

This configuration starts a jolokia module that collects the uptime of each
`tomcat` instance discovered. Discovery probes are sent using all interfaces
starting with `br` and `en`, for the `br` interfaces the `interval` and
`grace_period` is reduced to 5 and 10 seconds respectively.
