Create Opsgenie alerts for JSM tickets created during weekend

Currently the option to directly specify time frames for only Saturdays and Sundays isn't available in the standard Opsgenie interface, you might need to approach this requirement with a combination of Jira Service Management automations and Opsgenie alert rules based on custom tags or fields that indicate the ticket was created on a weekend. 

1. Use JSM Automations to Tag Weekend Tickets

You can create an automation rule in JSM that adds a specific label or updates a custom field on tickets created during the weekend. This label or field can then be used to control the alert creation in Opsgenie.

Steps to set up automation in JSM:

  • Go to your JSM project.
  • Navigate to Project settings > Automation.
  • Click Create rule.
  • For the trigger, select Issue created.
  • Add a new condition to check if the day of creation is Saturday or Sunday. This might require JQL like: created > startOfWeek(-26h) AND created <= startOfWeek(1d) ORDER BY created DESC
  • For the action, choose Edit issue and set a label like "weekend" or modify a custom field to a value like "WeekendTicket".
Detailed steps
  1. Set Trigger:

    • Choose the trigger "Issue created" from the list of available triggers.
  2. Add Condition:

    • Add a new condition by clicking "New condition".
    • Select "JQL condition" 
    • Enter the JQL query: created > startOfWeek(-26h) AND created <= startOfWeek(1d) ORDER BY created DESC. This JQL ensures the rule triggers for tickets created from Friday 10 PM to Sunday midnight.
  3. Add Action:

    • Click on "New action" and choose "Edit issue".
    • Set the action to modify the labels field by adding "WeekendTicket".
  4. Set Rule Details:

    • Give your rule a name, e.g., "Add Label on Weekend Ticket".
    • Optionally, add a description which helps others understand the purpose of the rule.
  5. Save and Enable the Rule:

    • After configuring your rule, click "Save".
    • Enable the rule if it's not automatically enabled.

This setup will ensure that any ticket created during the specified weekend times will automatically have the "WeekendTicket" label added. Make sure your JQL times correctly match your team's definition of the weekend.


2. Configure Opsgenie to Use the Label/Field

Once you have your JSM tickets being tagged or field-updated based on the creation day, configure Opsgenie to only create alerts when these tags or fields are present.

Opsgenie Integration settings:

  • Navigate to Integrations and select your JSM integration.
  • Edit the incoming automation rule
  • Modify the integration filters or alert creation rules to include conditions that check for the "WeekendTicket" label.
    1. Rule Type: Select "Create alert" as the rule type.
    2. Add Conditions
      • Select “Match all conditions below”.
      • Under conditions, set:
        • Labels: Choose the condition where labels “contains” and enter "WeekendTicket".

This method leverages the flexibility of JSM automations and the specificity of Opsgenie alert rules to manage when alerts should be created, bypassing the need for specific time-frame settings directly within Opsgenie for weekend coverage.

Additional Reference:

JQL for After Hours and Weekends



Last modified on May 15, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.