# Continuous query not able to populate data

**URL:** https://community.influxdata.com/t/continuous-query-not-able-to-populate-data/8230
**Category:** Systems
**Tags:** influxql
**Created:** [January 21, 2019, 5:17pm UTC](https://community.influxdata.com/t/continuous-query-not-able-to-populate-data/8230 "2019-01-21T17:17:58Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![SYED\_ADIL\_ABBAS\_RIZV](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@SYED\_ADIL\_ABBAS\_RIZV](https://community.influxdata.com/u/SYED_ADIL_ABBAS_RIZV)
#### Post date: [January 21, 2019, 5:17pm UTC](https://community.influxdata.com/t/continuous-query-not-able-to-populate-data/8230/1 "2019-01-21T17:17:58Z")

</div>

i have created a continous query, for aggregrating data from cloudwatch, the query triggers successfully, but is not storing the data , but if i run the same query by capturing from the influx logs the query is writing the data, any help is appreciated

In the logs i can see the query  
ts=2019-01-21T17:24:00.207572Z lvl=info msg=“Executing query” log\_id=0D32u3iW000 service=query query=“SELECT mean(cpu\_utilization\_average) AS cpu\_utilization, mean(disk\_read\_ops\_average) AS disk\_read\_ops, mean(disk\_write\_ops\_average) AS disk\_write\_ops INTO monitoring\_bmp\_agg.bmp\_agg\_policy.ec2\_stats FROM monitoring\_bmp.bmp\_retention\_policy.cloudwatch\_aws\_ec2 WHERE cluster\_name != ‘’ AND time \>= ‘2019-01-21T17:18:00Z’ AND time \< ‘2019-01-21T17:24:00Z’ GROUP BY cluster\_name, time(6m)”

but the data doesn’t get inserted, if i copy and run the same query in the shell data gets inserted successfully

---

<div class="post-metadata">

### Author: ![MarcV](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/marcv/32/7676_2.png) [@MarcV](https://community.influxdata.com/u/MarcV)
#### Post date: [January 22, 2019, 1:57pm UTC](https://community.influxdata.com/t/continuous-query-not-able-to-populate-data/8230/2 "2019-01-22T13:57:54Z")

</div>

Hi ,  
can you share the script that you use to create the continues query ?  
best regards

---

<div class="post-metadata">

### Author: ![SYED\_ADIL\_ABBAS\_RIZV](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@SYED\_ADIL\_ABBAS\_RIZV](https://community.influxdata.com/u/SYED_ADIL_ABBAS_RIZV)
#### Post date: [January 23, 2019, 2:25pm UTC](https://community.influxdata.com/t/continuous-query-not-able-to-populate-data/8230/3 "2019-01-23T14:25:09Z")

</div>

Thanks for the reply MarcV, i changed the syntax of creating the continuous query from the basic group by time(), to the advance syntax by using the resample, with for and interval , it is running fine now

fyi  
old query (the problem one)  
CREATE CONTINUOUS QUERY ec2\_6\_minute\_stats ON monitoring\_bmp BEGIN SELECT mean(cpu\_utilization\_average) AS cpu\_utilization, mean(disk\_read\_ops\_average) AS disk\_read\_ops, mean(disk\_write\_ops\_average) AS disk\_write\_ops INTO monitoring\_bmp\_agg.bmp\_agg\_policy.ec2\_stats FROM monitoring\_bmp.bmp\_retention\_policy.cloudwatch\_aws\_ec2 where cluster\_name != ‘’ GROUP BY cluster\_name, time(6m) END

new query(running fine)  
CREATE CONTINUOUS QUERY ec2\_10\_minute\_stats ON monitoring\_bmp  
RESAMPLE EVERY 5m FOR 15m  
BEGIN  
SELECT mean(cpu\_utilization\_average) AS cpu\_utilization INTO  
monitoring\_bmp\_agg.bmp\_agg\_policy.ec2\_stats FROM  
monitoring\_bmp.bmp\_retention\_policy.cloudwatch\_aws\_ec2 where cluster\_name != ‘’ GROUP BY cluster\_name, time(5m) order by time desc  
END
