defaultNode does not work

I am using defaultNode set a default value for a missing field. Unfortunately this does not work, the field “usage” in the following example stays empty, not taking the value specified in the defaultNode.

batch
       |query('''
                  SELECT "usage"
                  FROM "rancher"."autogen".memory
                  '''
                  )
                  .period(1m)
                  .every(5s)
                  .align()
        |default()
                   .field('usage', 0)
        |last('usage')
               .as('usage')
         |influxDBOut()
             .... 

“rancher”.“autogen”.memory is not a valid data source, thus no values are received for usage. If I understand it right this should lead to the activation of the default node, giving the field “usage” a default value of 0.

However the value of usage is not set to 0. It still is not available. What am I doing wrong?

Can you share the output of the kapacitor show TASK?

Your script looks correct, something odd must be going on.

ID: rancherDefault
Error:
Template:
Type: batch
Status: enabled
Executing: true
Created: 10 Jan 18 08:06 UTC
Modified: 10 Jan 18 08:06 UTC
LastEnabled: 10 Jan 18 08:06 UTC
Databases Retention Policies: ["rancher_bootstrap_systems"."autogen"]
TICKscript:
batch
    |query('''
                  SELECT "usage"
                  FROM "rancher_bootstrap_systems"."autogen".docker_container_mem
                  WHERE "container_image" = 'rancher/serve3r'
                  ''')
        .period(1m)
        .every(5s)
        .align()
    |default()
        .field('usage', 0)
    |last('usage')
        .as('usage')
    |influxDBOut()
        .database('rancher_systems')
        .retentionPolicy('autogen')
        .measurement('Rancher')

DOT:
digraph rancherDefault {
graph [throughput="0.00 batches/s"];

query1 [avg_exec_time_ns="0s" batches_queried="0" errors="0" points_queried="0" working_cardinality="0" ];
query1 -> default2 [processed="0"];

default2 [avg_exec_time_ns="0s" errors="0" fields_defaulted="0" tags_defaulted="0" working_cardinality="0" ];
default2 -> last3 [processed="0"];

last3 [avg_exec_time_ns="0s" errors="0" working_cardinality="0" ];
last3 -> influxdb_out4 [processed="0"];

influxdb_out4 [avg_exec_time_ns="0s" errors="0" points_written="0" working_cardinality="0" write_errors="0" ];

stats5 [avg_exec_time_ns="0s" errors="0" working_cardinality="0" ];
stats5 -> derivative6 [processed="0"];

derivative6 [avg_exec_time_ns="0s" errors="0" working_cardinality="0" ];
derivative6 -> alert7 [processed="0"];

alert7 [alerts_triggered="0" avg_exec_time_ns="0s" crits_triggered="0" errors="0" infos_triggered="0" oks_triggered="0" warns_triggered="0" working_cardinality="0" ];
}

The output shows that the query has never received any data. Is it possible that the query is not correct?

Yes the query is not correct on purpose. I changed rancher/server to rancher/serve3r which does not exist. Thus no data is received. Shouldn’t the defaultNode activate in such situations?

No, the default node will set a default tag or field if its missing on point, but it will not create new points.

What is the larger goal? There may be another way to accomplish this.

InfluxDB sends a point containing a field only when there was an update for that field, is that right?

Sometimes the application that sends data to InfluxDB is not working. When that happens also no data will be sent from InfluxDB to Kapacitor. Thus the running Tickscripts get no data and nothing happens. Our goal is to recognize when Kapacitor receives no data and store this in a field, which is sent via influxDBOut() to InfluxDB.