grafadruid / druid-grafana

Connects Grafana to Druid
https://join.slack.com/t/grafadruid/shared_invite/zt-1qy0skzy8-axnZuyzaWRm9t8f0r9dUWQ
Apache License 2.0
65 stars 37 forks source link

Receive an error when create an alter #88

Open yuanpenc opened 3 years ago

yuanpenc commented 3 years ago

What happened:

When I was trying to create an alter and test rules, there seemed to be a bug. The request and response is as below.

  "firing": true,
  "state": "pending",
  "conditionEvals": " = true",
  "timeMs": "179.965ms",
  "error": "tsdb.HandleRequest() response error &{POST http://proxy.druid.ke.com/druid/v2 giving up after 6 attempt(s) POST http://proxy.druid.ke.com/druid/v2 giving up after 6 attempt(s) A <nil> [] [] 0xc001913e30}",
  "logs": [
    {
      "message": "Condition[0]: Query",
      "data": {
        "from": 1622531328676,
        "queries": [
          {
            "refId": "A",
            "model": {
              "builder": {
                "aggregations": [
                  {
                    "name": "all_cnt",
                    "type": "count"
                  }
                ],
                "dataSource": {
                  "name": "commerce_adx_digv_empty_log",
                  "type": "table"
                },
                "filter": {
                  "dimension": "ip",
                  "type": "selector",
                  "value": "10.26.12.246"
                },
                "granularity": "minute",
                "intervals": {
                  "intervals": [
                    "${__from:date:iso}/${__to:date:iso}"
                  ],
                  "type": "intervals"
                },
                "postAggregations": [],
                "queryType": "timeseries",
                "virtualColumns": []
              },
              "expr": "{\"builder\":{\"queryType\":\"timeseries\",\"dataSource\":{\"name\":\"commerce_adx_digv_empty_log\",\"type\":\"table\"},\"intervals\":{\"type\":\"intervals\",\"intervals\":[\"${__from:date:iso}/${__to:date:iso}\"]},\"granularity\":\"minute\",\"filter\":{\"dimension\":\"ip\",\"type\":\"selector\",\"value\":\"10.26.12.246\"},\"aggregations\":[{\"name\":\"all_cnt\",\"type\":\"count\"}],\"postAggregations\":[],\"virtualColumns\":[]},\"settings\":{}}",
              "hide": true,
              "refId": "A",
              "settings": {}
            },
            "datasource": {
              "id": 18,
              "name": "Druid-server-alert"
            },
            "maxDataPoints": 0,
            "intervalMs": 0
          }
        ],
        "to": 1622531628676
      }
    }
  ]
}

As you can see, the parameter "intervals" seems not work properly. At lease, I think, It should not be something like "${from:date:iso}/${to:date:iso}".

However, When I specified a certain time range like the pic below, the problem was solved. image

What you expected to happen: The alter works successfully without specifying the intervals.

For an instance, when I use official grafana-prometheus. The request of an alter is like this: image The interval is "" (nothing here, only "from/to" specify the time range )

How to reproduce it: Build an timeseries query without specifying the intervals. Then, create an alter and test rule. The error message will come out.

Environment:

jbguerraz commented 3 years ago

Hello @yuanpenc Thank you for this issue! :) Yes this issue is known, has been discussed here: https://grafadruid.slack.com/archives/C01EEPVTALW/p1621957357043800 We should replace the __from and __to variables from the backend, using those from and to fields from the alert query, and then apply the formaters over them (like date:iso or so: https://grafana.com/docs/grafana/latest/variables/variable-types/global-variables/#__from-and-__to ). If you feel it, feel free to join us on slack and maybe contribute this feature ? For short-term workaround you could use something relative to now to select the data (like now - 5 minutes or so) for your alerts.

yuanpenc commented 3 years ago

Hello @yuanpenc Thank you for this issue! :) Yes this issue is known, has been discussed here: https://grafadruid.slack.com/archives/C01EEPVTALW/p1621957357043800 We should replace the __from and __to variables from the backend, using those from and to fields from the alert query, and then apply the formaters over them (like date:iso or so: https://grafana.com/docs/grafana/latest/variables/variable-types/global-variables/#__from-and-__to ). If you feel it, feel free to join us on slack and maybe contribute this feature ? For short-term workaround you could use something relative to now to select the data (like now - 5 minutes or so) for your alerts.

Of course! I am 100% willing to contribute this feature. But the thing is I don't have too much experience in Typescript project. So, Could you please add some instructions of how to compile and zip this project in the readme? Thank you for you help.

jbguerraz commented 3 years ago

Hello @yuanpenc Awesome to read! This is more a contribution on the golang side of it. I'm fully available to help you with it, feel free to ping me on https://join.slack.com/t/grafadruid/shared_invite/zt-ryrcolyp-GQCiKcOF0WhnK~iqpkrqLA

saketbairoliya2 commented 1 year ago

Do we have any update on this? @jbguerraz / @yuanpenc

jbguerraz commented 1 year ago

nope @saketbairoliya2 If you're willing to work on it, feel free to ping me, I'll be happy to help!