thatmattlove / hyperglass

hyperglass is the network looking glass that tries to make the internet better.
https://hyperglass.dev
BSD 3-Clause Clear License
594 stars 88 forks source link

Support for configuring specific query types #238

Closed KincaidYang closed 3 months ago

KincaidYang commented 3 months ago

Hi @thatmattlove , Does v2.0.0 support configuring specific query types? For instance, I only wish to support BGP Route and Traceroute. I couldn't find any relevant documentation on this, and attempting to use the parameters from v1.0.4 did not work.

thatmattlove commented 3 months ago

Yes, see these two pages:

https://v2.hyperglass.dev/configuration/directives

https://v2.hyperglass.dev/configuration/examples/add-your-own-command

It is possible you could filter the default directives to specific ones with something like:

devices:
  - name: Name
    directives:
      - __hyperglass_juniper_bgp_route__
      - __hyperglass_juniper_traceroute__

I'm not 100% sure if that would work, I'll need to test it later. You can look here for all the built-in directives and their IDs.

KincaidYang commented 3 months ago

They don't seem to be working properly. When I configure them like this, all query types are still being built:

devices:
  - name: Amsterdam, NL
    address: 78.142.xxx.xxx
    platform: bird
    credential:
      username: bird
      password: xxxxxxxxxxxxxxxxxxxxxxxxx
    attrs:
      source4: 0.0.0.0
      source6: ::0
    directives:
      - __hyperglass_bird_bgp_route__
      - __hyperglass_bird_traceroute__

image

So I tried adding the parameter builtins: false, but after that, it didn't support any query type:

devices:
  - name: Amsterdam, NL
    address: 78.142.xxx.xxx
    platform: bird
    credential:
      username: bird
      password: xxxxxxxxxxxxxxxxxxxxxxxxx
    attrs:
      source4: 0.0.0.0
      source6: ::0
    directives:
      - builtins: false
      - __hyperglass_bird_traceroute__
      - __hyperglass_bird_bgp_route__

image

thatmattlove commented 3 months ago

Ok. That was a guess, and I'm not surprised it didn't work. I will devise a way to selectively enable/disable built-in directives. In the mean time, you'll probably need to add your own custom directives.

thatmattlove commented 3 months ago

After looking at this in depth, this does already exist, this is how you do it:

devices:
  - name: Amsterdam, NL
    address: 78.142.xxx.xxx
    platform: bird
    credential:
      username: bird
      password: xxxxxxxxxxxxxxxxxxxxxxxxx
    attrs:
      source4: 0.0.0.0
      source6: ::0
    directives:
      - builtins: [traceroute, bgp_route] # no need to specify the full name of the directive

I'll update the docs.