Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion dashboards-observability/common/utils/query_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
PPL_INDEX_INSERT_POINT_REGEX,
PPL_INDEX_REGEX,
PPL_NEWLINE_REGEX,
PPL_STATS_REGEX,
} from '../../common/constants/shared';

/**
Expand Down Expand Up @@ -67,7 +68,9 @@ export const preprocessQuery = ({
finalQuery = finalQuery + ` | sort - ${timeField}`;
}

finalQuery = buildPatternsQuery(finalQuery, selectedPatternField, patternRegex, filteredPattern);
// if a pattern is selected as filter, build it into finalQuery
if (selectedPatternField && filteredPattern)
finalQuery = buildPatternsQuery(finalQuery, selectedPatternField, patternRegex, filteredPattern);

return finalQuery;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { PatternTableData } from 'common/types/explorer';
import { reduce, round } from 'lodash';
import React from 'react';
import { useSelector } from 'react-redux';
import { SELECTED_PATTERN_REGEX } from '../../../../../common/constants/explorer';
import { FILTERED_PATTERN } from '../../../../../common/constants/explorer';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this works too, can you remove the regex?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are more unused variables, will clean up in a separate PR

import { PPL_DOCUMENTATION_URL } from '../../../../../common/constants/shared';
import { selectPatterns } from '../../redux/slices/patterns_slice';

Expand All @@ -30,7 +30,6 @@ interface PatternsTableProps {
export function PatternsTable(props: PatternsTableProps) {
const { tableData, tabId, onPatternSelection, query } = props;
const patternsData = useSelector(selectPatterns)[tabId];
const selectedPattern = query.rawQuery.match(SELECTED_PATTERN_REGEX)?.groups?.pattern || '';

const tableColumns = [
{
Expand Down Expand Up @@ -123,7 +122,7 @@ export function PatternsTable(props: PatternsTableProps) {
onPatternSelection(pattern);
}
},
isSelected: pattern === selectedPattern,
isSelected: pattern === query[FILTERED_PATTERN],
};
};

Expand Down