Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attach Outputs to a subscription #209

Merged
merged 1 commit into from Aug 25, 2023

Conversation

mwdomino
Copy link
Contributor

This PR is a followup to the discussion in #198

It includes the ability to specify outputs under a subscription in configuration. If specified, all data from the subscription will be sent to the given output(s). If there are no outputs specified under a subscription then it will exhibit the current behavior and flood the messages out to each defined output.

I've tested this locally using containerized Arista (cEOS) switches with the following config file and all works as I expect:

username: admin
password: admin
insecure: true
subscribe-backoff: 1s

targets:
  localhost:6030:
    subscriptions:
      - arista_image
      - arista_arp
      - arista_ethernet_state
  localhost:6031:
    subscriptions:
      - arista_image
      - arista_arp
      - arista_ethernet_state

subscriptions:
  arista_ethernet_state:
    paths:
      - "/interfaces/interface/ethernet/state"
    mode: stream
    stream-mode: ON_CHANGE

  arista_image:
    paths:
      - "eos_native:/Eos/image"
    mode: stream
    stream-mode: ON_CHANGE
    outputs: 
      - prom1
      - prom2

  arista_arp:
    paths:
      - "eos_native:/Smash/arp/status/arpEntry"
    mode: stream
    stream-mode: ON_CHANGE
    outputs: 
      - prom3

outputs:
  prom1:
    type: prometheus
    listen: :9801
    path: /metrics
    metric-prefix: "prom1"
  prom2:
    type: prometheus
    listen: :9802
    path: /metrics
    metric-prefix: "prom2"
  prom3:
    type: prometheus
    listen: :9803
    path: /metrics
    metric-prefix: "prom3"

For this test I just used 3 prometheus outputs so that I could curl localhost:<port>/metrics to verify only expected messages were received.

In this example:

  • arista_arp - will only be sent to prom3
  • arista_image - will be sent to prom1 and prom2
  • arista_ethernet_state - will be sent to prom1, prom2, and prom3 as no output is specified (current behavior)

As this is my first time contributing to the project please let me know if there's anything you'd like me to change or if there is a different process to follow when opening up PRs like this!

This adds Outputs to SubscriptionConfig and modifies the collector to
prefer to Export to the Subscription's outut if provided, falling back
to the Target output as a default. This maintains the original behavior
unless overridden.
@google-cla
Copy link

google-cla bot commented Aug 25, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@mwdomino
Copy link
Contributor Author

I believe the re-scan after signing the CLA was successful.

@karimra
Copy link
Collaborator

karimra commented Aug 25, 2023

Thanks for the contribution!

@karimra karimra merged commit 7b826d8 into openconfig:main Aug 25, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants