Skip info field in protobuf alerts messages if it doesn't exist. (#12210)
* dont assume info field exists * add info field to documentation
Emmanuel Vasilakis committed
Feb 22, 2022 at 14:01 UTC
d70cedbf90ab99b9c3dd870d1f9c1a8a184d251f
2 files changed
+14
-3
database/sqlite/sqlite_aclk_alert.c
+5
-3
@@ -242,7 +242,9 @@ void aclk_push_alert_event(struct aclk_database_worker_config *wc, struct aclk_d
242
alarm_log.old_value = (calculated_number) sqlite3_column_double(res, 24);
243
244
alarm_log.updated = (sqlite3_column_int64(res, 8) & HEALTH_ENTRY_FLAG_UPDATED) ? 1 : 0;
245
- alarm_log.rendered_info = strdupz((char *)sqlite3_column_text(res, 18));
245
+ alarm_log.rendered_info = sqlite3_column_type(res, 18) == SQLITE_NULL ?
246
+ strdupz((char *)"") :
247
+ strdupz((char *)sqlite3_column_text(res, 18));
248
249
aclk_send_alarm_log_entry(&alarm_log);
250
@@ -714,7 +716,7 @@ void health_alarm_entry2proto_nolock(struct alarm_log_entry *alarm_log, ALARM_EN
716
alarm_log->utc_offset = host->utc_offset;
717
alarm_log->timezone = strdupz((char *)host->abbrev_timezone);
718
alarm_log->exec_path = ae->exec ? strdupz((char *)ae->exec) : strdupz((char *)host->health_default_exec);
717
- alarm_log->conf_source = ae->source ? strdupz((char *)ae->source) : "";
719
+ alarm_log->conf_source = ae->source ? strdupz((char *)ae->source) : strdupz((char *)"");
720
721
alarm_log->command = strdupz((char *)edit_command);
722
@@ -738,7 +740,7 @@ void health_alarm_entry2proto_nolock(struct alarm_log_entry *alarm_log, ALARM_EN
740
alarm_log->old_value = (!isnan(ae->old_value)) ? (calculated_number)ae->old_value : 0;
741
742
alarm_log->updated = (ae->flags & HEALTH_ENTRY_FLAG_UPDATED) ? 1 : 0;
741
- alarm_log->rendered_info = strdupz(ae->info);
743
+ alarm_log->rendered_info = ae->info ? strdupz(ae->info) : strdupz((char *)"");
744
745
freez(edit_command);
746
}
health/REFERENCE.md
+9
@@ -82,6 +82,7 @@ Netdata parses the following lines. Beneath the table is an in-depth explanation
82
| [`repeat`](#alarm-line-repeat) | no | The interval for sending notifications when an alarm is in WARNING or CRITICAL mode. |
83
| [`options`](#alarm-line-options) | no | Add an option to not clear alarms. |
84
| [`host labels`](#alarm-line-host-labels) | no | List of labels present on a host. |
85
+| [`info`](#alarm-line-info) | no | A brief description of the alarm. |
86
87
The `alarm` or `template` line must be the first line of any entity.
88
@@ -533,6 +534,14 @@ host labels: installed = 201*
534
535
See our [simple patterns docs](/libnetdata/simple_pattern/README.md) for more examples.
536
537
+#### Alarm line `info`
538
+
539
+The info field can contain a small piece of text describing the alarm or template. This will be rendered in notifications and UI elements whenever the specific alarm is in focus. An example for the `ram_available` alarm is:
540
+
541
+```yaml
542
+info: percentage of estimated amount of RAM available for userspace processes, without causing swapping
543
+```
544
+
545
## Expressions
546
547
Netdata has an internal [infix expression parser](/libnetdata/eval). This parses expressions and creates an internal