Skip to content

Commit

Permalink
Get pattern data from datarows
Browse files Browse the repository at this point in the history
Signed-off-by: Eugene Lee <[email protected]>
  • Loading branch information
eugenesk24 committed Oct 27, 2022
1 parent b5c62d6 commit 6bb9986
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
5 changes: 0 additions & 5 deletions dashboards-observability/common/types/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,6 @@ export interface GetTooltipHoverInfoType {
tooltipText: string;
}

export interface PatternJSONData {
'count()': number;
patterns_field: string;
}

export interface PatternTableData {
count: number;
pattern: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { IField, PatternJSONData, PatternTableData } from 'common/types/explorer';
import { IField, PatternTableData } from 'common/types/explorer';
import { isEmpty, isUndefined } from 'lodash';
import PPLService from 'public/services/requests/ppl';
import { useRef } from 'react';
Expand Down Expand Up @@ -60,13 +60,13 @@ export const useFetchPatterns = ({ pplService, requestParams }: IFetchPatternsPa
fetchEvents(
{ query: statsQuery },
'jdbc',
(res: { jsonData: PatternJSONData[] }) => {
if (!isEmpty(res.jsonData)) {
const formatToTableData = res.jsonData.map((json: PatternJSONData) => {
(res: { datarows: any[] }) => {
if (!isEmpty(res.datarows)) {
const formatToTableData = res.datarows.map((row: any) => {
return {
count: json['count()'],
pattern: json.patterns_field,
sampleLog: json[`take(${patternField}, 1)`],
count: row[0],
pattern: row[2],
sampleLog: row[1][0],
} as PatternTableData;
});
// Fetch total number of events to divide count by for ratio
Expand Down

0 comments on commit 6bb9986

Please sign in to comment.