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

Add Support for Twilio Copilot #86

Merged
merged 10 commits into from
Apr 27, 2021
Merged

Conversation

cdmastercom
Copy link
Contributor

Per Twilio Docs add support for alerts using Copilot. Compability with the existing Twilio SMS alerting method is maintained.

  • Make 'twilio_from_number' optional
  • Add setting 'twilio_message_service_sid'
  • Add setting 'twilio_use_copilot', defaults to False

In case 'twilio_use_copilot' is False, 'twilio_from_number' is required. Otherwise, 'twilio_message_service_sid' is required.

I've tested this using an Elasticsearch 7.1.1 cluster, both SMS and Copilot alerting work.

Thanks to @nsano-rururu for letting me know that the yelp repository was abandoned.

Maintain compatibility with Twilio SMS API, validate new settings conditionally using the 'twilio_use_copilot' flag. Throws EAException in case of an incorrect combination of settings.
@nsano-rururu
Copy link
Collaborator

@cdmastercom

Wouldn't it be necessary to add to the documentation that twilio_from_number is no longer required, that twilio_message_service_sid and twilio_use_copilot have been added as an option, and that the default value for twilio_use_copilot is "False"?
https://github.com/jertel/elastalert2/blob/master/docs/source/ruletypes.rst#twilio

@cdmastercom
Copy link
Contributor Author

No problem @nsano-rururu, how does this look?

@nsano-rururu
Copy link
Collaborator

nsano-rururu commented Apr 26, 2021

@cdmastercom

Is it the following setting image?

For SMS

alert:
- "twilio"
twilio_account_sid: "xxxxxxx"
twilio_auth_token: "xxxxxxx"
twilio_to_number: "xxxxxxx"
twilio_from_number: "xxxxxxx"

For Copilot

alert:
- "twilio"
twilio_use_copilot: True
twilio_account_sid: "xxxxxxx"
twilio_auth_token: "xxxxxxx"
twilio_to_number: "xxxxxxx"
twilio_message_service_sid: "xxxxxxx"

Don't you add the two settings added to schema.yaml? .. If the type is different when executing the rule, an error will occur.

https://github.com/jertel/elastalert2/blob/master/elastalert/schema.yaml#L325

twilio_message_service_sid: {type: string}
twilio_use_copilot: {type: boolean}

@cdmastercom
Copy link
Contributor Author

cdmastercom commented Apr 26, 2021

Alright, added that now @nsano-rururu. Sorry I'm not too familiar with this project.

Is there anything else I missed?

@cdmastercom
Copy link
Contributor Author

Yes the way you wrote the settings is correct. Would it be better if this was split into two different Alerter classes?

@nsano-rururu
Copy link
Collaborator

nsano-rururu commented Apr 26, 2021

@cdmastercom

Yes the way you wrote the settings is correct. Would it be better if this was split into two different Alerter classes?

I think you can leave it as it is. I think it would be nice to write two setting examples as described in The Hive's documentation.
https://github.com/jertel/elastalert2/blob/master/docs/source/ruletypes.rst#thehive

@nsano-rururu
Copy link
Collaborator

nsano-rururu commented Apr 26, 2021

@cdmastercom

"Twilio>= 6.0.0,<6.1" is specified in setup.py and requirements.txt, but if you change it to "twilio>=6.0.0,<6.58", ask them to try it. Is it possible?

I want to know if there is no problem with updating the library or if it should be the same version.

@nsano-rururu
Copy link
Collaborator

@cdmastercom

If that is not possible, there is no problem if you answer that it is impossible.

@cdmastercom
Copy link
Contributor Author

@nsano-rururu

That worked. Pip was able to install the modified requirements, and SMS still worked as expected. The twilio module API for sending sms doesn't appear to have changed, so I think we can support the whole range of versions from 6.0 to 6.57.

@nsano-rururu
Copy link
Collaborator

@jertel

My review is over.
Is there anything else I can point out?

@jertel
Copy link
Owner

jertel commented Apr 26, 2021

@jertel

My review is over.
Is there anything else I can point out?

No, go ahead and approve and merge it. Thanks!

@ferozsalam
Copy link
Collaborator

@cdmastercom Could you also add a line to the changelog under the list of new features please?

@jertel
Copy link
Owner

jertel commented Apr 27, 2021

I'll update the changelog in a few mins.

@jertel jertel merged commit 9016d3b into jertel:master Apr 27, 2021
@cdmastercom cdmastercom deleted the twilio_copilot_3 branch April 27, 2021 23:00
@cdmastercom
Copy link
Contributor Author

Thanks guys.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants