ansible / awx

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is one of the upstream projects for Red Hat Ansible Automation Platform.
Other
13.7k stars 3.38k forks source link

Grafana Notification => ValueError: invalid literal for int() with base 10: '' #12682

Open manuel-held opened 1 year ago

manuel-held commented 1 year ago

Please confirm the following

Bug Summary

Administration => Notification - Type Grafana.

Test failed when "ID of the dashboard (optional)" or/and "ID of the panel (optional)" is empty.

2022-08-18 10:11:57,916 ERROR [9170e756] awx.main.tasks.system Send Notification Failed invalid literal for int() with base 10: '' Traceback (most recent call last): File "/awx_devel/awx/main/tasks/system.py", line 290, in send_notifications sent = notification.notification_template.send(notification.subject, notification.body) File "/awx_devel/awx/main/models/notifications.py", line 182, in send backend_obj = self.notification_class(**notification_configuration) File "/awx_devel/awx/main/notifications/grafana_backend.py", line 58, in __init__ self.panelId = int(panelId) if panelId is not None else None ValueError: invalid literal for int() with base 10: ''

and

2022-08-18 10:09:46,302 ERROR [c7de9089] awx.main.tasks.system Send Notification Failed invalid literal for int() with base 10: '' Traceback (most recent call last): File "/awx_devel/awx/main/tasks/system.py", line 290, in send_notifications sent = notification.notification_template.send(notification.subject, notification.body) File "/awx_devel/awx/main/models/notifications.py", line 182, in send backend_obj = self.notification_class(**notification_configuration) File "/awx_devel/awx/main/notifications/grafana_backend.py", line 57, in __init__ self.dashboardId = int(dashboardId) if dashboardId is not None else None ValueError: invalid literal for int() with base 10: ''

The reason i think is that '' is not None so '' is passed to int() and triggers the Error

AWX Version: Ansible AWX 21.4.0 Grafana Version: v9.0.7

AWX version

21.4.0

Select the relevant components

Installation method

docker development environment

Modifications

no

Ansible version

2.10.8

Operating system

Ubuntu 22.04.1 LTS

Web browser

Firefox, Chrome

Steps to reproduce

Under Notification, add a Grafana Notification and leave the Fields ID of (dashboard, panel) empty. Hit the Test Button.

Expected results

Notification in Grafana

Actual results

The State changed to Failed. The log contains the Error above.

Additional information

No response

dmzoneill commented 5 months ago

I've opened a primary pull request that needs refinement, but the errors described here will be fixed in that PR.

refer: https://github.com/ansible/awx/pull/14802 refer: https://github.com/ansible/awx/issues/14675

mihai-satmarean commented 4 months ago

I am trying to set grafana notifications, but since documentation here https://docs.ansible.com/ansible-tower/latest/html/userguide/notifications.html#grafana does not specify a type of object the tower sends, trace, log, metric whatever, and we have no example dashboard, I let the fields empty, thus hitting this bug. any hint is apreciated

noesberger commented 1 month ago

I also tried today the notification to grafana from ansible and have the same error. When I need to create a dashboard and panel before, do you have any example or documentation how they need to be configured in grafana.