sstrncpy (msg, th.missing_message, sizeof (msg));
status = ut_build_message (msg, sizeof (msg),
/* format = */ th.missing_message,
- &ds, /* ds index = */ 0,
+ &ds, /* ds index = */ -1,
&vl, ce->values_gauge,
&n, &th);
if (status != 0)
REPLACE_FIELD ("%{plugin_instance}", n->plugin_instance);
REPLACE_FIELD ("%{type}", n->type);
REPLACE_FIELD ("%{type_instance}", n->type_instance);
- REPLACE_FIELD ("%{data_source}", ds->ds[ds_index].name);
- /* This is the offending value, its equivalent to %{ds:value}, if
- * value is the data_source name. */
- FTOA(ftoa_temp,values[ds_index])
- REPLACE_FIELD ("%{value}", ftoa_temp);
+ /* ds_index is set to -1 if the value is missing (there is no data source /
+ * value we could reasonably use. */
+ if (ds_index >= 0)
+ {
+ REPLACE_FIELD ("%{data_source}", ds->ds[ds_index].name);
+
+ /* This is the offending value, its equivalent to %{ds:value}, if
+ * value is the data_source name. */
+ FTOA(ftoa_temp,values[ds_index])
+ REPLACE_FIELD ("%{value}", ftoa_temp);
+ }
/* Now replace all %{ds:<template>} like target_notification does */
rates_failed = 0;