Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.0.7 and Grafana v7.1.3: Error 400 - bad request #276

Closed
ADovgalyuk opened this issue Aug 10, 2020 · 2 comments · Fixed by #279
Closed

v2.0.7 and Grafana v7.1.3: Error 400 - bad request #276

ADovgalyuk opened this issue Aug 10, 2020 · 2 comments · Fixed by #279
Assignees

Comments

@ADovgalyuk
Copy link

Hi everyone.
I've got an error after plugin update from 1.9.5 to 2.0.7. My request:

  $rateColumns(
'Dir.'||toString(cgpn_dir)||', Serv.'||toString(sender_service) as key,
sum(count) as value)
FROM (
select cgpn_dir,sender_service, toStartOfMinute(event_time) as event_time,
count() as count
from $table
WHERE $timeFilter
and message_type=0
and status=1
and external_message_id=''
and (dictGetString('nodes', 'Node', tuple(host)) in ($Node) or lower(host) in lower($Node))
group by event_time, cgpn_dir,sender_service
)

On 1.9.5 generated sql request is:

SELECT t,
       arrayMap(a -> (a.1, a.2/runningDifference(t/1000)), groupArr)
FROM
  (SELECT t,
          groupArray((KEY, value)) AS groupArr
   FROM
     (SELECT (intDiv(toUInt32(event_time), 60) * 60) * 1000 AS t,
             'Dir.' || toString(cgpn_dir) || ', Serv.' || toString(sender_service) AS KEY,
                                                          sum(COUNT) AS value
      FROM
        (SELECT cgpn_dir,
                sender_service,
                toStartOfMinute(event_time) AS event_time,
                COUNT() AS COUNT
         FROM statistics.SMSC_cdr
         WHERE event_time BETWEEN toDateTime(1597039332) AND toDateTime(1597060874)
           AND event_time BETWEEN toDateTime(1597039332) AND toDateTime(1597060874)
           AND message_type=0
           AND status=1
           AND external_message_id=''
           AND (dictGetString('nodes', 'Node', tuple(HOST)) IN ('SMSUSSDC_01')
                OR lower(HOST) IN lower('SMSUSSDC_01'))
         GROUP BY event_time,
                  cgpn_dir,
                  sender_service)
      GROUP BY t,
               KEY
      ORDER BY t,
               KEY)
   GROUP BY t
   ORDER BY t)

v195

But on 2.0.7 its different and incorrect, part of subquery is lost:

SELECT t,
       arrayMap(a -> (a.1, a.2/runningDifference(t/1000)), groupArr)
FROM
  (SELECT t,
          groupArray((KEY, value)) AS groupArr
   FROM
     (SELECT (intDiv(toUInt32(event_time), 60) * 60) * 1000 AS t,
             'Dir.' || toString(cgpn_dir) || ', Serv.' || toString(sender_service) AS KEY,
                                                          sum(COUNT) AS value
      FROM statistics.SMSC_cdr
      WHERE event_time BETWEEN toDateTime(1597039533) AND toDateTime(1597061073)
        AND event_time BETWEEN toDateTime(1597039533) AND toDateTime(1597061073)
        AND message_type=0
        AND status=1
        AND external_message_id=''
        AND (dictGetString('nodes', 'Node', tuple(HOST)) IN ('SMSUSSDC_01')
             OR lower(HOST) IN lower('SMSUSSDC_01'))
      GROUP BY event_time,
               cgpn_dir,
               sender_service)
   GROUP BY t,
            KEY
   ORDER BY t,
            KEY)
GROUP BY t
ORDER BY t)

v207

Seems like a bug to me, but I didn't find anything similar in current open issues.

@Slach
Copy link
Collaborator

Slach commented Aug 10, 2020

Hello @ADovgalyuk thanks for detailed report I will check it and fix ASAP

@Slach
Copy link
Collaborator

Slach commented Aug 13, 2020

@ADovgalyuk could you check the latest master version of plugin?

Slach added a commit to Altinity/grafana-plugin-repository that referenced this issue Aug 13, 2020
# 2.1.0 (2020-08-13)

## Enhancement:
* add "Skip comments" checkbox to query editor to pass SQL comments to server, fix Altinity/clickhouse-grafana#265
* add setup notes for Grafana 7.x to README
* add SQL preprocessing logic on browser side with <% js code subset %>, Altinity/clickhouse-grafana#186, thanks @fgbogdan
* improve alerts query processing for use case when `query(query_name, from, to)` time range is less than visible dashboard time range, see Altinity/clickhouse-grafana#237
* improve alerts json parsing in golang part for case when we have string fields in response which interprets as series name, see Altinity/clickhouse-grafana#230
* properly parsing POST queries in golang part of plugin, Altinity/clickhouse-grafana#228, thanks @it1804

## Fixes:
* fix corner cases for $macro + subquery, see Altinity/clickhouse-grafana#276 and Altinity/clickhouse-grafana#277
* fix parallel query execution, see Altinity/clickhouse-grafana#273
* fix identifiers quotes, see Altinity/clickhouse-grafana#276, Altinity/clickhouse-grafana#277
* fix plugin.json for pass `grafana-plugin-repository` plugin validator
* fix multi-value variables behavior - Altinity/clickhouse-grafana#252
* add Vagrantfile for statefull environment and allow to upgrade scenario like  grafana 7.1.0 + grafana-cli upgrade-all
  * fix Altinity/clickhouse-grafana#244
  * fix Altinity/clickhouse-grafana#243
* add multiple dashboard examples for github issues:
  * fix Altinity/clickhouse-grafana#240
  * fix Altinity/clickhouse-grafana#135
  * fix Altinity/clickhouse-grafana#245
  * fix Altinity/clickhouse-grafana#238
  * fix Altinity/clickhouse-grafana#232
  * fix Altinity/clickhouse-grafana#127
  * fix Altinity/clickhouse-grafana#141

Signed-off-by: Eugene Klimov <eklimov@altinity.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants