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

Some JSON alerts attributes should be optional #21

Closed
jnogol opened this issue Sep 11, 2017 · 5 comments
Closed

Some JSON alerts attributes should be optional #21

jnogol opened this issue Sep 11, 2017 · 5 comments
Assignees

Comments

@jnogol
Copy link
Collaborator

jnogol commented Sep 11, 2017

In the current version, the following values are parsed and returned in order to create the Teams message:

'alert_name': json_alerts_labels_attr['alertname'],
'alert_instance': json_alerts_labels_attr['instance'],
'alert_severity': json_alerts_labels_attr['severity'],
'alert_summary': json_alerts_annotations_attr['summary'],
'alert_description': json_alerts_annotations_attr['description'],
'alert_status': json_alerts_attr['status']

Problem is that, depending on the query and/or the alarm rule, instance, summary or description could not be sent by Prometheus. In case this happens, prom2teams fails to parser the input and won't forward the alarm to Microsoft Teams.

jnogol pushed a commit that referenced this issue Sep 14, 2017
jnogol pushed a commit that referenced this issue Sep 18, 2017
@lindhor
Copy link
Contributor

lindhor commented Nov 1, 2017

I also ran into this one, any guess when this fix might be merged and a new version including it tagged?

jnogol pushed a commit that referenced this issue Nov 2, 2017
@jnogol
Copy link
Collaborator Author

jnogol commented Nov 2, 2017

Hi Roger,

First of all, thanks for using Prom2Teams. We are working on it and will release the new version soon.

Regards,
Jose

jnogol pushed a commit that referenced this issue Nov 3, 2017
jnogol pushed a commit that referenced this issue Nov 3, 2017
jnogol pushed a commit that referenced this issue Nov 3, 2017
jnogol pushed a commit that referenced this issue Nov 3, 2017
jdvr added a commit that referenced this issue Nov 6, 2017
@jnogol
Copy link
Collaborator Author

jnogol commented Nov 7, 2017

Hi @lindhor,

We released a new version (1.1.3) that fixes this.

Regards,
Jose

@jnogol jnogol closed this as completed Nov 7, 2017
@lindhor
Copy link
Contributor

lindhor commented Nov 7, 2017

Thank you so much for your quick fix! I can confirm that it works and no longer gives an exception for mandatory fields. The list of mandatory attributes is however too strict, since it includes instance which is not always sent (for example if you have a rule like IF absent(container_cpu_load_average_10s{name='mycriticalcontainer}), i.e. alert if no instances of the container exists on any host).

Maybe the best approach would be to forward the information you receive and have default values for them instead? Something like:

alertname='unknown'
status='firing'
instance='unknown'
summary='no alert summary specified'

https://github.com/idealista/prom2teams/blob/master/prom2teams/message/parser.py#L8

@jnogol please reopen or do you want me to file a new issue?

@jnogol
Copy link
Collaborator Author

jnogol commented Nov 8, 2017

Hi again Roger,

Thank you for the interesting idea, feel free to open an issue and, if this something critical for you, make us a pull request and we will more than happy to include this feature in the next Prom2Teams release.

Regards,
Jose

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

No branches or pull requests

2 participants