Skip to content

Feature Request: Add support for filttering in consul loader #779

@amuntean-godaddy

Description

@amuntean-godaddy

I am registering the targets within the same service in Consul, and it would be convenient to have the consul loader being able to filter the targets as described in https://developer.hashicorp.com/consul/api-docs/features/filtering.

Here is an example of loader configuration I am expecting to have:

    loader:
      address: ${CONSUL_ADDRESS}
      token: ${CONSUL_HTTP_TOKEN}
      type: consul
      datacenter: dc1
      enable-metrics: true  
      services:
        - name: gnmi
          filter: Service.Meta.profile == "arista-dcs"
          config:
            username: ${SERVICE_ACCOUNT_USERNAME}
            password: ${SERVICE_ACCOUNT_PASSWORD}
            skip-verify: true
            tls-ca: /config/tls/tls.ca
            tls-cert: /config/tls/tls.crt
            tls-key: /config/tls/tls.key
            event-tags:
              assignment_group: "{{ .Meta.assignment_group }}"
              model: "{{ .Meta.model }}"
              network_environment: "{{ .Meta.network_environment }}"
              role: "{{ .Meta.role }}"
            subscriptions:
              - arista-dcs-system
              - arista-dcs-interfaces
        - name: gnmi
          filter: Service.Meta.profile == "juniper-ex"
          config:
            username: ${SERVICE_ACCOUNT_USERNAME}
            password: ${SERVICE_ACCOUNT_PASSWORD}
            skip-verify: true
            tls-ca: /config/tls/tls.ca
            tls-cert: /config/tls/tls.crt
            tls-key: /config/tls/tls.key
            event-tags:
              assignment_group: "{{ .Meta.assignment_group }}"
              model: "{{ .Meta.model }}"
              network_environment: "{{ .Meta.network_environment }}"
              role: "{{ .Meta.role }}"
            subscriptions:
              - juniper-ex-system
              - juniper-ex-interfaces 

This is how the targets are defined in consul:

[{
    'Address': 'X.X.X.X',
    'CreateIndex': 10583467,
    'Datacenter': 'us',
    'ID': '',
    'ModifyIndex': 10617416,
    'Node': 'assa1318-01.mgt.cgn1.gdg',
    'NodeMeta': { 'external-node': 'true' },
    'ServiceAddress': 'X.X.X.X',
    'ServiceConnect': {},
    'ServiceEnableTagOverride': False,
    'ServiceID': 'assa1318-01.mgt.cgn1.gdg',
    'ServiceKind': '',
    'ServiceLocality': None,
    'ServiceMeta': {
        'assignment_group': 'Networking',
        'model': 'CCS-720XP-48Y6',
        'network_environment': 'CGN1',
        'profile': 'arista-dcs',
        'role': 'Access Switch',
        'site': 'cgn1'
    },
    'ServiceName': 'gnmi',
    'ServicePort': 6030,
    'ServicePorts': None,
    'ServiceProxy': { 'Expose': {}, 'MeshGateway': {}, 'Mode': '' },
    'ServiceSocketPath': '',
    'ServiceTags': ['profile=arista-dcs'],
    'ServiceWeights': { 'Passing': 1, 'Warning': 1 },
    'TaggedAddresses': None
}]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions