Relic Solution: Workaround recurring muting rules with GraphQL

I’ve heard many people asking about scheduling recurring muting rules for alerts. This is on our roadmap and will be available in a few months. But in the meantime, you can work around this by using our NerdGraph API to schedule a muting rule and then run it in a Cron job or use New Relic Synthetics to schedule it.

How to schedule a muting rule with GraphQL?
Single scheduler muting rule endpoint is available in GraphQL API. To create a muting rule we are going to use “alertsMutingRuleCreate” under “mutation” schema.
Below is an example to mute notification from one of my alerting condition between 1am to 7am Dublin time on September 1st. You can to and try it out:

mutation {
  alertsMutingRuleCreate(accountId: <YourAccountId>, rule: {
    	name: "condition mute rule", 
      description: "Mute alert condition", 
    	enabled: true, 
    	condition: {
        operator: AND, 
        conditions: [{
          attribute: "conditionId", 
          operator: EQUALS, 
          values: ["<yourConditionId>"]}]}, 
    	schedule: {
        endTime: "2020-09-01T08:00:00", 
        startTime: "2020-09-01T08:00:00", 
        timeZone: "Europe/Dublin"}}) 

You can also get the CURL or New Relic CLI from the GraphQL Tools.

More details about managing muting rules via GraphQL can be found in the below doc:

Or find out more pro-tips on muting rules in this post: Relic Solution: Muting Rules Pro-Tips

With that, you can write your cron job or Synthetic monitor to schedule a recurring muting rule.