influxQL:`SELECT "usage_idle", "usage_guest_nice", "usage_system", "usage_guest" FROM "telegraf"."autogen"."cpu" WHERE time > :dashboardTime:`,
want:chronograf.QueryConfig{
Database:"telegraf",
Measurement:"cpu",
RetentionPolicy:"autogen",
Fields:[]chronograf.Field{
chronograf.Field{
Field:"usage_idle",
Funcs:[]string{},
},
chronograf.Field{
Field:"usage_guest_nice",
Funcs:[]string{},
},
chronograf.Field{
Field:"usage_system",
Funcs:[]string{},
},
chronograf.Field{
Field:"usage_guest",
Funcs:[]string{},
},
},
Tags:map[string][]string{},
GroupBy:chronograf.GroupBy{
Tags:[]string{},
},
},
},
{
name:"Test field function order",
influxQL:`SELECT mean("usage_idle"), median("usage_idle"), count("usage_guest_nice"), mean("usage_guest_nice") FROM "telegraf"."autogen"."cpu" WHERE time > :dashboardTime:`,
influxQL:`SELECT moving_average(mean("count"),14) FROM "usage_computed"."autogen".unique_clusters_by_day WHERE time > now() - 90d AND product = 'influxdb' group by time(1d)`,
RawText:`SELECT moving_average(mean("count"),14) FROM "usage_computed"."autogen".unique_clusters_by_day WHERE time > now() - 90d AND product = 'influxdb' group by time(1d)`,
influxQL:`SELECT count("event_id")/3 as "event_count_id" from discource.autogen.discourse_events where time > now() - 7d group by time(1d), "event_type"`,
RawText:`SELECT count("event_id")/3 as "event_count_id" from discource.autogen.discourse_events where time > now() - 7d group by time(1d), "event_type"`,
influxQL:`SELECT usage_user from telegraf.autogen.cpu where ("host" = 'myhost' or "this" = 'those') and ("howdy" != 'doody') and time > now() - 15m`,
RawText:`SELECT usage_user from telegraf.autogen.cpu where ("host" = 'myhost' or "this" = 'those') and ("howdy" != 'doody') and time > now() - 15m`,
want:chronograf.QueryConfig{
Fields:[]chronograf.Field{},
Tags:map[string][]string{},
GroupBy:chronograf.GroupBy{
Tags:[]string{},
},
},
},
{
name:"Test tags accepted",
influxQL:`SELECT usage_user from telegraf.autogen.cpu where ("host" = 'myhost' OR "host" = 'yourhost') and ("these" = 'those') and time > now() - 15m`,
influxQL:`SELECT "usage_idle", "usage_guest_nice", "usage_system", "usage_guest" FROM "telegraf"."autogen"."cpu" WHERE time > now() - 15m AND ("cpu"!='cpu-total' OR "cpu"!='cpu0') AND ("host"!='dev-052978d6-us-east-2-meta-0' OR "host"!='dev-052978d6-us-east-2-data-5' OR "host"!='dev-052978d6-us-east-2-data-4' OR "host"!='dev-052978d6-us-east-2-data-3')`,
want:chronograf.QueryConfig{
Database:"telegraf",
Measurement:"cpu",
RetentionPolicy:"autogen",
Fields:[]chronograf.Field{
chronograf.Field{
Field:"usage_idle",
Funcs:[]string{},
},
chronograf.Field{
Field:"usage_guest_nice",
Funcs:[]string{},
},
chronograf.Field{
Field:"usage_system",
Funcs:[]string{},
},
chronograf.Field{
Field:"usage_guest",
Funcs:[]string{},
},
},
Tags:map[string][]string{
"host":[]string{
"dev-052978d6-us-east-2-meta-0",
"dev-052978d6-us-east-2-data-5",
"dev-052978d6-us-east-2-data-4",
"dev-052978d6-us-east-2-data-3",
},
"cpu":[]string{
"cpu-total",
"cpu0",
},
},
GroupBy:chronograf.GroupBy{
Time:"",
Tags:[]string{},
},
AreTagsAccepted:false,
Range:&chronograf.DurationRange{
Lower:"now() - 15m",
},
},
},
{
name:"Complex Logic with tags accepted",
influxQL:`SELECT "usage_idle", "usage_guest_nice", "usage_system", "usage_guest" FROM "telegraf"."autogen"."cpu" WHERE time > now() - 15m AND ("cpu" = 'cpu-total' OR "cpu" = 'cpu0') AND ("host" = 'dev-052978d6-us-east-2-meta-0' OR "host" = 'dev-052978d6-us-east-2-data-5' OR "host" = 'dev-052978d6-us-east-2-data-4' OR "host" = 'dev-052978d6-us-east-2-data-3')`,