terraform-provider-pagerduty icon indicating copy to clipboard operation
terraform-provider-pagerduty copied to clipboard

Add email_filters to pagerduty_service_integration of type generic_email_inbound_integration

Open suls opened this issue 6 years ago • 7 comments

Hi there,

I am using the generic_email_inbound_integration type of pagerduty_service_integration. Being as it is, I heavily depend on some email filtering.

The pagerduty API itself seems to be a bit underdocumented (can't find a schema for this) but below is roughly the response of my manually created service integration.

https://api.pagerduty.com/services/service/integrations/integration

{
  "integration": {
    "type": "generic_email_inbound_integration",
    // snip
    "email_incident_creation": "on_new_email_subject",
    "email_filter_mode": "and-rules-email",
    "email_filters": [
      {
        "subject_mode": "no-match",
        "subject_regex": "__insert regex here__",
        "body_mode": "always",
        "body_regex": null,
        "from_email_mode": "always",
        "from_email_regex": null,
        "id": "__id__"
      }
    ],
    "email_parsers": null,
    "email_parsing_fallback": null
  }
}

Would you be interested in adding email_filters into your PagerDuty provider?

Cheers, Mathias

suls avatar Jun 01 '18 02:06 suls

We were hit by this one as well. If there is support for this one, we might build it.

It might be nicer if the resource didn't have the email specific stuff at the top-level since it really only applies to the email thing. Maybe a specific email_integration resource would be a bit nicer?

paddie avatar Aug 10 '18 08:08 paddie

At the very least can we get the ability to set the Email Management config?

image

These are the values for email_incident_creation

  • Open a new alert for each trigger email. => "on_new_email"
  • Open a new alert for each new trigger email subject. => "on_new_email_subject"
  • Open a new alert only if an open incident does not already exist. => "only_if_no_open_incidents"
  • Accept all incoming email. => "use_rules",

I would also like to be able to set the custom emails rules. But looking at what is configured in the API I can appreciate how complicated the integration resource would become, all for one option, of one option, of an integration.

I think a dedicated email integration resource might be simpler.

cregkly avatar May 08 '19 02:05 cregkly

If it helps here is the payload I used for testing updating a custom rules via the API for my PRTG email integration

        'integration': {
            'type': 'generic_email_inbound_integration',
            'name': "Email",
            'email_incident_creation': "use_rules",
            'email_filter_mode': "all-email",
            'email_filters': [
                {
                    'subject_mode': "always",
                    'body_mode': "always",
                    'from_email_mode': "always",
                }
            ],
            'email_parsers': [
                {
                    'action': "resolve",
                    'match_predicate': {
                        'type': "any",
                        'children': [
                            {
                                'type': "contains",
                                'part': "subject",
                                'matcher': "Down ended"
                            },
                            {
                                'type': "contains",
                                'part': "subject",
                                'matcher': "Up"
                            },
                            {
                                'type': "contains",
                                'part': "subject",
                                'matcher': "Threshold not reached"
                            }
                        ]
                    },
                    'value_extractors': [
                        {
                            'type': "regex",
                            'value_name': "incident_key",
                            'part': "subject",
                            'regex': "([a-zA-Z0-9_\\-\\: ]*) ~ ([a-zA-Z0-9_\\-\\: ]*) ~ ([a-zA-Z0-9_\\-\\: ]*)"
                        }
                    ]

                },
                {
                    'action': "trigger",
                    'match_predicate': {
                        'type': "any",
                        'children': [
                            {
                                'type': "contains",
                                'part': "subject",
                                'matcher': "Down"
                            },
                            {
                                'type': "contains",
                                'part': "subject",
                                'matcher': "Threshold reached"
                            },
                            {
                                'type': "contains",
                                'part': "subject",
                                'matcher': "Warning"
                            }
                        ]
                    },
                    'value_extractors': [
                        {
                            'type': "regex",
                            'value_name': "incident_key",
                            'part': "subject",
                            'regex': "([a-zA-Z0-9_\\-\\: ]*) ~ ([a-zA-Z0-9_\\-\\: ]*) ~ ([a-zA-Z0-9_\\-\\: ]*)"
                        }
                    ]

                }
            ],
            'email_parsing_fallback': "open_new_incident"
        }
    }

cregkly avatar May 08 '19 02:05 cregkly

email_incident_creation for pagerduty_service_integration would indeed be useful to many orgs

mattsimonsen avatar Jun 12 '19 21:06 mattsimonsen

I'm trying to migrate my PRTG PagerDuty configuration to Terraform, I'm stuck on this as well. Any updates on this?

JanMinervum avatar Nov 15 '20 22:11 JanMinervum

Same here. It's painful to manually create PRTG integration for many services.

anhlqn avatar Nov 21 '20 16:11 anhlqn

Same here

toughrogrammer avatar Aug 23 '21 14:08 toughrogrammer