Could you check the this questions?


#1

Hello,everyone.

I have created the following database↓

time value1 value2 value3 value4 timestamp


2019-02-28T02:03:00.607441767Z 12345678 12345 12345678901 10000 2019-02-26T14:43:59.812676+0900
2019-02-28T02:03:04.621629874Z 91011120 12345 23456789011 10001 2019-02-26T14:43:59.812752+0900
2019-02-28T02:03:00.607441767Z 12345678 12345 12345678901 10000 2019-02-26T14:43:59.812676+0900
2019-02-28T02:03:04.621629874Z 91011120 12345 23456789011 10001 2019-02-26T14:43:59.812752+0900

I want to create the next measurement by use the continuous query↓

time value1 value2 value4 timestamp


2019-02-28T02:03:00.607441767Z 24691356 12345 10000 2019-02-26T14:43:59.812676+0900
2019-02-28T02:03:04.621629874Z 182022240 12345 10001 2019-02-26T14:43:59.812752+0900

Do you know the best continuous queries??
Please let me us know.

best regrads.


#2

Hi ,you can achieve the result without using a continuous query …
A simple select into statement can select the fields you want , or are you planning to aggregate your data ?
The new measurement is not really needed because it will contain a subset of your first measurement … so it will only take space without having a reason to exist ? :slight_smile:

Continuous queries


#3

Hi,MarcV.

Thank you for your responce:grinning:

A simple select into statement can select the fields you want,or are you planning to aggregate your data ?

I’m planning that using continuous queries…
Execute is difficult?


#4

Continuous queries are not difficult to implement , is it only for testing and to learn Influxdb that you want to create a continuous query ?


#5

This is for work,Currntly is test Phase.
However,system implementation will start soon.:sweat_smile:


#6

your continuous query must have a function in the select statement , an INTO
and a GROUP BY TIME() clause.
Do you want to calculate averages for example ?


#7

Hi,MarcV

No,I’m not take calculate averages.
I would like to sum value1 for every value2 and value4.


#8

Hi , i think you need a kapacitor task to do that ,
something like this in a kapacitor tick script … ?

var numbers = stream
|from()
.measurement(‘time’)
|eval(lambda: “value2” + “value4”)
.as(‘value1’)

|influxDBOut()

this will make the sum of value2 and value4 and save it in value1 …

here are some examples :

Kapacitor as a Continuous Query engine


#9

Hi.MarcV.
Thank you quick responce!
I will give it a try!


#10

Maybe this is also interesting ?

> select * from time
name: time
time                value1 value2 value3 value4
----                ------ ------ ------ ------
1551697213974676426 4      6      9      8
1551698822749869390 4      71     9      41

> select ("value2" + "value4") as value1 into timesum from time where time > now() - 1h
name: result
time written
---- -------
0    2

> select * from timesum
name: timesum
time                value1
----                ------
1551697213974676426 14
1551698822749869390 112

#11

I’m sorry for the delay…

Thank you for teaching me!
I’ll try this command!

※Now,I’m work to another task…