question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

$columns + ORDER BY ... WITH FILL ... not works

See original GitHub issue

Hello everyone,

I have an issue while trying to create alert rule on Grafana using this plugin. Issue is that different graphs are plotted using same query on “Create alert rule” and “Explore” sections. Because of this i am unable to create multi dimensional rule as described here.

In Explore section graph is plotted correctly and requests are grouped by status code as thay should.

Screenshot 2022-02-23 at 10 58 31

But, using same query in Create alert rule section i got strange grouping which i don’t understand.

Screenshot 2022-02-23 at 11 00 17

I have tried the same thing with InfluxDB as a source and graphs were indentical.

I am not sure why it is behaving like this so any insight is welcome.


Query:

SELECT 
    $timeSeries as t,
    sum(request) as request,
    status_code
FROM $table
WHERE
    $timeFilter
    AND status_code != 201 AND status_code != 0
GROUP BY t, status_code
ORDER BY t WITH FILL STEP 60000

ClickHouse: 21.11.6.7 (official build) Grafana version: v8.4.1 (53f5c6a44c) Plugin version: v2.4.2 Plugin was installed using grafana-cli command. ClickHouse and Grafana are installed on Debian 11

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:23

github_iconTop GitHub Comments

1reaction
kuri-mancommented, Mar 7, 2022

@Slach I’ve written an example below.

Create a timeseries with some category that we want to group on:

DROP TABLE IF EXISTS test_data

CREATE TABLE IF NOT EXISTS test_data
(
    timestamp DateTime,
    category LowCardinality(String),
    value UInt64
) ENGINE = MergeTree ORDER BY timestamp

INSERT INTO test_data VALUES
    (now(), 'A', 1),
    (now(), 'B', 2),
    (now() - INTERVAL 10 MINUTE, 'A', 2),
    (now() - INTERVAL 15 MINUTE, 'B', 5),
    (now() - INTERVAL 60 MINUTE, 'A', 4)

Produce a query:

$columns(category, sum(value) AS c)
FROM test_data
WHERE $timeFilter(timestamp)

Generated SQL:

SELECT t, groupArray((category, c)) AS groupArr FROM ( SELECT (intDiv(toUInt32(timestamp), 15) * 15) * 1000 AS t, category, sum(value) AS c FROM test_data
WHERE timestamp >= toDateTime(1646641819) AND timestamp <= toDateTime(1646663419) AND timestamp >= toDateTime(1646641819) AND timestamp <= toDateTime(1646663419)(timestamp) GROUP BY t, category ORDER BY t, category) GROUP BY t ORDER BY t

I’d like to create an alert for if the total of value over the last 30 minutes is >5 for any one of the series. I did this with a reduce + math expression. image

The sum by series appears to work correctly, but I notice that they’re each displayed by the query name rather than by the category. When I try to evaluate this, I get an error that @Enton-72 hit: image

When using a classic condition the alerting does work as expected. However, there are some limitations to that approach (any single label triggering the alert will prevent new alert updates when a second label would trigger it). I’m running plugin version 2.4.3, grafana 8.4.3.

0reactions
Slachcommented, Mar 4, 2022

@kuri-man could you provide your query and Generated SQL?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is column-fill property not working as expected with "auto"?
With this code, column-fill = auto do work as expected : The first column is fullfilled before the second. So the question is...
Read more >
column-fill - CSS: Cascading Style Sheets - MDN Web Docs
The column-fill CSS property controls how an element's contents are balanced when broken into columns.
Read more >
Fill values in a column - Power Query - Microsoft Learn
With Power Query, you can use the values in a column to fill down or fill up any empty spaces in the column....
Read more >
SQL ORDER BY | Basic SQL - Mode Analytics
You can order data by multiple columns, in ascending or descending order. ... another system or connected to certain types of databases, it...
Read more >
Ordering multiple columns not working, not doing anything
Use the order option to set the initial table order. The docs have an example of default ordering multiple columns. Also see this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found