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

Bug 1913608: Query Browser: Fix bug where None table values were not cleared #7813

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 9 additions & 12 deletions frontend/public/components/monitoring/metrics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -706,16 +706,13 @@ const QueryTable_: React.FC<QueryTableProps> = ({
);
}

const { result, resultType } = data;

// Add any data series from `series` (those displayed in the graph) that are not already in `result`. This happens
// for filtering PromQL queries that exclude a series currently, but did not exclude that same series at some point
// during that graph's range.
_.each(series, (labels) => {
if (_.every(result, (r) => !_.isEqual(labels, r.metric))) {
result.push({ metric: labels });
}
});
// Add any data series from `series` (those displayed in the graph) that are not in `data.result`.
// This happens for queries that exclude a series currently, but included that same series at some
// point during the graph's range.
const expiredSeries = _.differenceWith(series, data.result, (s, r) => _.isEqual(s, r.metric));
const result = expiredSeries.length
? [...data.result, ...expiredSeries.map((metric) => ({ metric }))]
: data.result;

if (!result || result.length === 0) {
return (
Expand All @@ -733,7 +730,7 @@ const QueryTable_: React.FC<QueryTableProps> = ({
const buttonCell = (labels) => ({ title: <SeriesButton index={index} labels={labels} /> });

let columns, rows;
if (resultType === 'scalar') {
if (data.resultType === 'scalar') {
columns = ['', { title: 'Value', ...cellProps }];
rows = [[buttonCell({}), _.get(result, '[1]')]];
} else {
Expand All @@ -749,7 +746,7 @@ const QueryTable_: React.FC<QueryTableProps> = ({
];

let rowMapper;
if (resultType === 'matrix') {
if (data.resultType === 'matrix') {
rowMapper = ({ metric, values }) => [
'',
..._.map(allLabelKeys, (k) => metric[k]),
Expand Down