Curious issue with Alert Transport mappings

I’m migrating from the legacy alert transports/templates across to the new implementation and running into an odd problem with the new Alert Transport mappings in Alert Rules.

I have a number of Alert Transports set up (mail, pushover, slack etc), and a single alert Transport Group. I initially had all my alerts set up to use the Transport Group which seemed to work fine from a DB perspective, but when I then edit a single alert rule to change from using the Transport Group for alerts, to one of the specific Alert Transports, all the rows in the alert_transport_map table appear to be deleted and replaced with a single row for the rule I have just edited.

Anyone else run into this problem?

SQL output from the alert_transport_map table below, before and after the Alert Rule edit.

Before:

MariaDB [librenms]> select * from alert_transport_map order by rule_id;
+-----+---------+-----------------------+-------------+
| id  | rule_id | transport_or_group_id | target_type |
+-----+---------+-----------------------+-------------+
| 117 |       1 |                     1 | group       |
| 118 |       2 |                     1 | group       |
| 119 |       4 |                     1 | group       |
| 120 |       5 |                     1 | group       |
| 121 |       6 |                     1 | group       |
| 122 |       7 |                     1 | group       |
| 123 |       8 |                     1 | group       |
| 124 |       9 |                     1 | group       |
| 125 |      12 |                     1 | group       |
| 126 |      13 |                     1 | group       |
| 127 |      14 |                     1 | group       |
| 128 |      15 |                     1 | group       |
| 129 |      16 |                     1 | group       |
| 130 |      17 |                     1 | group       |
| 131 |      18 |                     1 | group       |
| 132 |      19 |                     1 | group       |
| 133 |      20 |                     1 | group       |
| 134 |      21 |                     1 | group       |
| 135 |      22 |                     1 | group       |
| 136 |      23 |                     1 | group       |
| 137 |      24 |                     1 | group       |
| 138 |      25 |                     1 | group       |
| 139 |      26 |                     1 | group       |
| 140 |      27 |                     1 | group       |
| 141 |      28 |                     1 | group       |
| 142 |      29 |                     1 | group       |
| 143 |      31 |                     1 | group       |
| 144 |      32 |                     1 | group       |
| 145 |      33 |                     1 | group       |
| 146 |      34 |                     1 | group       |
| 147 |      35 |                     1 | group       |
| 148 |      36 |                     1 | group       |
| 149 |      37 |                     1 | group       |
| 150 |      38 |                     1 | group       |
| 151 |      39 |                     1 | group       |
+-----+---------+-----------------------+-------------+
35 rows in set (0.01 sec)

And after:

MariaDB [librenms]> select * from alert_transport_map order by rule_id;
+-----+---------+-----------------------+-------------+
| id  | rule_id | transport_or_group_id | target_type |
+-----+---------+-----------------------+-------------+
| 152 |      34 |                     1 | single      |
+-----+---------+-----------------------+-------------+
1 row in set (0.00 sec)
Component Version
LibreNMS 1.45
DB Schema 270
PHP 7.0.32
MySQL 5.5.60-MariaDB
RRDTool 1.4.8
SNMP NET-SNMP 5.7.2

Some further detail:

When I add a mix of Alert Transports to the Alert Rules, the alert_transport_map table fills up nicely:

MariaDB [librenms]> select * from alert_transport_map order by rule_id;
+-----+---------+-----------------------+-------------+
| id  | rule_id | transport_or_group_id | target_type |
+-----+---------+-----------------------+-------------+
| 153 |       1 |                     1 | group       |
| 154 |       2 |                     1 | single      |
| 155 |       4 |                     1 | group       |
| 156 |       5 |                     1 | group       |
| 157 |       6 |                     1 | group       |
| 158 |       7 |                     1 | group       |
| 159 |       8 |                     1 | group       |
| 160 |       9 |                     1 | group       |
| 161 |      13 |                     1 | group       |
| 162 |      14 |                     1 | group       |
| 163 |      15 |                     1 | group       |
| 164 |      16 |                     1 | single      |
| 165 |      17 |                     1 | single      |
| 166 |      18 |                     1 | single      |
| 167 |      19 |                     1 | single      |
| 168 |      20 |                     1 | group       |
| 169 |      21 |                     1 | group       |
| 170 |      22 |                     1 | group       |
| 171 |      23 |                     1 | group       |
| 172 |      24 |                     1 | group       |
| 173 |      25 |                     1 | single      |
| 174 |      26 |                     1 | group       |
| 175 |      27 |                     1 | group       |
| 176 |      28 |                     1 | group       |
| 177 |      29 |                     1 | group       |
| 178 |      31 |                     1 | group       |
| 152 |      34 |                     1 | single      |
+-----+---------+-----------------------+-------------+
27 rows in set (0.00 sec)

If I then delete the Alert Transport from (in the example above) rule_id 34, refreshing the alert_transport_map table shows that all the target_type “single” Alert Transport maps have vanished from the table??

MariaDB [librenms]> select * from alert_transport_map order by rule_id;
+-----+---------+-----------------------+-------------+
| id  | rule_id | transport_or_group_id | target_type |
+-----+---------+-----------------------+-------------+
| 153 |       1 |                     1 | group       |
| 155 |       4 |                     1 | group       |
| 156 |       5 |                     1 | group       |
| 157 |       6 |                     1 | group       |
| 158 |       7 |                     1 | group       |
| 159 |       8 |                     1 | group       |
| 160 |       9 |                     1 | group       |
| 161 |      13 |                     1 | group       |
| 162 |      14 |                     1 | group       |
| 163 |      15 |                     1 | group       |
| 168 |      20 |                     1 | group       |
| 169 |      21 |                     1 | group       |
| 170 |      22 |                     1 | group       |
| 171 |      23 |                     1 | group       |
| 172 |      24 |                     1 | group       |
| 174 |      26 |                     1 | group       |
| 175 |      27 |                     1 | group       |
| 176 |      28 |                     1 | group       |
| 177 |      29 |                     1 | group       |
| 178 |      31 |                     1 | group       |
| 179 |      32 |                     1 | group       |
| 180 |      33 |                     1 | group       |
| 181 |      34 |                     1 | group       |
+-----+---------+-----------------------+-------------+
23 rows in set (0.00 sec)

Following that by deleting the Transport Group from a single one of the remaining Alert Rules then removes all rows from the alert_transport_map table:

MariaDB [librenms]> select * from alert_transport_map order by rule_id;
Empty set (0.00 sec)

I am confused…

Hi,

Seems to be a bug.

Thanks for reporting it!

I’m currently working on it guys :wink:

1 Like

Brilliant, thanks :slight_smile:

You can try this patch:

https://p.libren.ms/view/raw/61760413