Query error in Kapacitor

Hi All,

Am trying to enable a tick script i have written to track to alert when my process is stopped.

SELECT count(“pid”) as query_value
FROM “telegraf.autogen.procstat”
.groupBy(time(1m), ‘process_name’, ‘host’)

|deadman(0.0, 1m)
    // Alert title.
    .id('Monitored processes - {{ index .Tags "process_name" }}')
    // Alert body.
    .message('Server:{{ index .Tags "host" }}|Process {{ index .Tags "process_name" }} STOPPED!')
    // Send notification when state changes only.
    // Send alerts to Slack
    // For Debugging purposes.

When i try to enable the task i get the below error:

```enabling task process_alert_batch: batch query is not allowed to request data from “”."`

Please advise

Queries in batch tasks must be fully qualified, meaning they specify the database and retention policy of the data. You have a slight error in your query syntax


FROM "telegraf.autogen.procstat"

should be

FROM "telegraf"."autogen"."procstat"
1 Like

Thanks @nathaniel :heart:

1 Like

@nathaniel I do get the alerts when the process is stopped and also when the process is started. But for both cases i get the same alert message,

Server:ip-172-31-14-178|Process httpd STOPPED!

I need alert message as below when process is started:
Server:ip-172-31-14-178|Process httpd STARTED!

is there a way for the same.

You can use if / else switch to check the status and change the message accordingly. Here is an example:

.message(’‘Server:{{ index .Tags “host” }}|Process {{ index .Tags “process_name” }} {{if eq .Level “OK”}} STARTED! {{else}} STOPPED! {{end}}.’)

I really don’t understand this limitation on batch queries. It basically limits the entire purpose of leveraging a template for batch tasks. Without this limitation I can have a generic template that tasks can specify which database and query to execute, but with this limitation that is impossible.

I understand the issue if there was multiple dbrps specified in the taskfile, but if there is only one than why can’t it just be inferred as the one to use in a batch query??

furthermore, which scenario is more common? Someone specifying multiple dbrps in a task definition? or someone wanting to leverage templates to allow specifying a single dbrp in a taskfile for batch queries.