A failed request is returned under the refId `__queryDataError`, so Grafana alerting reads "no data"

オープン
#221 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go, grafana

調査の方向性

The error keys are set in pkg/quickwit/elasticsearch.go (__queryDataError) and pkg/quickwit/quickwit.go (__qwQueryDataError). Start by reading how req.Queries and the RefID of each query are passed into those response builders, then reproduce the outage by checking the response map returned for a request. Done when every query in the request gets its own error response under its refId, and a test shows the error is keyed by refId in both code paths.

索引モデルが issue の本文から書いたものです。

説明

Summary

When Quickwit does not answer, the plugin returns the error under a fixed refId. It does not use the refId of the query. Grafana alerting finds no response for the query and reads the result as "no data". An alert rule then leaves the state Alerting, and it fires again when Quickwit is back.

Versions

  • Grafana 13.0.1
  • quickwit-quickwit-datasource 0.6.3
  • Quickwit 0.9.3

Reproduction

  1. Start Quickwit 0.9.3 and Grafana 13.0.1 with the plugin 0.6.3, for example with docker compose (GF_INSTALL_PLUGINS: "quickwit-quickwit-datasource 0.6.3").
  2. Create an index, add some documents, and add the datasource.
  3. Create an alert rule with one Quickwit query (refId A, metric Count, a date histogram). Add a Reduce expression and a Threshold expression. Set noDataState: OK and execErrState: KeepLast.
  4. Add documents that make the rule fire. The state is Alerting, and the contact point gets one message.
  5. Stop the Quickwit container.
  6. Wait for the next evaluation.

Observed

  • The state of the rule changes to Normal (NoData). The contact point gets a "resolved" message.
  • After Quickwit starts again, the rule fires again. The contact point gets the same alert a second time.
  • execErrState has no effect, because Grafana sees no error for the query.
  • The response of /api/ds/query in the outage: HTTP 400, with results.__queryDataError.error set, errorSource: plugin, status: 500, and frames: []. The response has no entry for the refId A.
  • The Grafana log has this line: Can't find response by refID. Return nodata responseRefIds=[__queryDataError].

A second case has the same cause. When Grafana restarts while Quickwit is down, the datasource cannot start. The plugin then returns the error under the refId __qwQueryDataError.

Cause

Two places in the code use a fixed key for the error response:

  • pkg/quickwit/elasticsearch.go: result.Responses["__queryDataError"] = backend.ErrDataResponse(...)
  • pkg/quickwit/quickwit.go: response.Responses["__qwQueryDataError"] = backend.ErrDataResponse(backend.StatusInternal, "Datasource initialization failed")

Proposed fix

Return the error under the refId of each query of the request. For each query in req.Queries, set Responses[query.RefID] to the error response. Grafana then sees an error for the query, and execErrState applies.

Workaround

Give the query of the alert rule the refId __queryDataError. Grafana then finds the error under the refId of the query, and execErrState: KeepLast keeps the state. This workaround does not cover the second case (__qwQueryDataError).

主要言語
TypeScript
スター
76
フォーク
45
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

quickwit-oss/quickwit-datasource のほかの issue

quickwit-oss/quickwit-datasource の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。