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

feat: support tags/match filtering in push #913

Merged
merged 3 commits into from Apr 5, 2024

Conversation

vigneshshanmugam
Copy link
Member

@vigneshshanmugam vigneshshanmugam commented Apr 3, 2024

  • Part of Nice to have features for Control Plane team #910
  • Filtering in push via tags/match has been asked a lot both externally and internally as it makes it easier for the users to control the monitors getting pushed to Kibana. We have intentionally made the decision to not support it, mainly because monitors were deleted behind the scenes when users pushed monitors with different tags. We improved deletion flow and requires explicit approval from the user before all the monitors gets deleted, Also the monitors deleted are shown to the user if DEBUG=synthetics flag is enabled.
  • PR adds support for filtering monitors via --tags and --match CLI flags in addition to the undocumented --pattern field. It behaves similar to the journey test runner which is used for filtering the journeys when running locally.
// filter monitor names 
npx @elastic/synthetics --match "foo*"

// filter monitor with tags

npx @elastic/synthetics --tags "env:qa, env:staging"
  • Users can tag the monitors/journeys in different ways and its still supported and backwards compatible.
// tag on the journey level
journey({name: "using journey param", tags: ["env:qa"], async(){})

// tag using monitor.use API
journey("using monitor API", async(){
  monitor.use({ tags: ["env:qa"]})
  step("blah", () => {})
})

// global tags via Synthetics.config.ts
export default () => {
  return {
    monitor: {
      tags: ["env:dev"]
    }
  }
};

Lightweight monitors

heartbeat.monitors:
  - type: http
    enabled: true
    name: google.com
    id: google-1
    urls: ["google.com."]
    tags: ["env:qa"]

@rrxs
Copy link

rrxs commented Apr 3, 2024

would be very nice to have this feature

@ale-neto
Copy link

ale-neto commented Apr 3, 2024

nice bro, I'm currently going through a problem, and I believe this might be the solution.

@gsantoro
Copy link

gsantoro commented Apr 4, 2024

It works as expected!

Thanks

Copy link
Contributor

@devcorpio devcorpio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

tested both lightweight and browser.

Example of what the user will see if a deletion is triggered. I also set DEBUG=synthetics

Screenshot

Note for users: monitors created manually (this is to say, not using Project monitors) will not be deleted if their tags don't match to the ones used in the push command. The reason for this is that they are independent monitors.

@vigneshshanmugam vigneshshanmugam merged commit 13813d4 into elastic:main Apr 5, 2024
7 checks passed
@vigneshshanmugam vigneshshanmugam deleted the add-push-tags branch April 5, 2024 15:03
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

5 participants