Skip to content

Commit

Permalink
feat: add visually highlight partial responses #142 (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
Loori-R authored Feb 19, 2024
1 parent d478ba4 commit 75899ee
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## tip
* FEATURE: add visually highlight partial responses. See [this issue](https://github.com/VictoriaMetrics/grafana-datasource/issues/142)

* BUGFIX: correct the queries for `Label Filters` and `Metrics Browser` for metrics with special characters. See [this issue](https://github.com/VictoriaMetrics/grafana-datasource/issues/140)

Expand Down
12 changes: 12 additions & 0 deletions src/result_transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
Labels,
MutableField,
PreferredVisualisationType,
QueryResultMetaNotice,
ScopedVars,
TIME_SERIES_TIME_FIELD_NAME,
TIME_SERIES_VALUE_FIELD_NAME,
Expand Down Expand Up @@ -261,6 +262,17 @@ export function transform(
const prometheusResult = response.data.data;
const traceResult = response.data?.trace

if (response.data.isPartial) {
const partialWarning = {
severity: "warning",
text: `The shown results are marked as PARTIAL. The result is marked as partial if one or more vmstorage nodes failed to respond to the query.`
} as QueryResultMetaNotice

Array.isArray(options.meta.notices)
? options.meta.notices.push(partialWarning)
: options.meta.notices = [partialWarning]
}

if (isExemplarData(prometheusResult)) {
return {
dataFrame: [],
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export interface PromDataSuccessResponse<T = PromData> {
status: 'success';
data: T;
trace?: TracingData;
isPartial?: boolean;
}

export interface PromDataErrorResponse<T = PromData> {
Expand Down

0 comments on commit 75899ee

Please sign in to comment.