The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
grafana/public/app/features/logs/components/LogDetailsRow.tsx

335 lines
9.7 KiB

import { css, cx } from '@emotion/css';
import { isEqual } from 'lodash';
import memoizeOne from 'memoize-one';
import React, { PureComponent } from 'react';
import { CoreApp, Field, GrafanaTheme2, LinkModel, LogLabelStatsModel, LogRowModel } from '@grafana/data';
import { reportInteraction } from '@grafana/runtime';
import { ClipboardButton, DataLinkButton, IconButton, Themeable2, withTheme2 } from '@grafana/ui';
import { LogLabelStats } from './LogLabelStats';
import { getLogRowStyles } from './getLogRowStyles';
//Components
export interface Props extends Themeable2 {
Explore: Show log line if there is an interpolated link (#62926) * bring in source from database * bring in transformations from database * add regex transformations to scopevar * Consolidate types, add better example, cleanup * Add var only if match * Change ScopedVar to not require text, do not leak transformation-made variables between links * Add mappings and start implementing logfmt * Add mappings and start implementing logfmt * Remove mappings, turn off global regex * Add example yaml and omit transformations if empty * Fix the yaml * Add logfmt transformation * Cleanup transformations and yaml * add transformation field to FE types and use it, safeStringify logfmt values * Add tests, only safe stringify if non-string, fix bug with safe stringify where it would return empty string with false value * Add test for transformation field * Do not add null transformations object * Add provisioning (to be removed) and show log lines with links * Only display links if change to query was made * Break out transformation logic, add tests to backend code * Fix lint errors I understand 😅 * Fix the backend lint error * Remove unnecessary code and mark new Transformations object as internal * Add support for named capture groups * Remove type assertion * Remove variable name from transformation * Add test for overriding regexes * Add back variable name field, but change to mapValue * fix go api test * Change transformation types to enum, add better provisioning checks for bad type name and format * Change transformation types to enum, add better provisioning checks for bad type name and format * Check for expression with regex transformations * Remove isInterpolated variable, add option to always use format function * Add template variable check to links * Use new functions * Filter log line at render, remove extra createSpanLink imports * Add scrollable to long log messages * Remove test that is no longer accurate * Remove test correlation * Add tests, fix duplicate key issue * WIP: show log line links key/value pairs * Some not great style changes * Change LogDetailsRow for better multi value formatting * Cleanup * Add additional information around variable regex, implement PR feedback * Display name with fieldPath if applicable * Add variables with fieldPaths to test * Count empty string as undefined variable * Add better commented version of function, fix tests by removing new variable * Modify when links show * Remove sample yaml * If a link has no variables, set value to field name, and some formatting issues * Add comments and change variable names to be more clear, add back logic where needed, add test coverage for new scenario * Fix formatting of replaceInVariableRegex comment * Remove changes from Grafana-data, move logic into explore * Rename function and property to match similar format * Move types to type files and consolidate definitions, rename functions, change field definitions to accept arrays of keys/values, move function to parser, hide actions on multi key/value rows * Add tests to logParser’s new function
2 years ago
parsedValues: string[];
parsedKeys: string[];
disableActions: boolean;
wrapLogMessage?: boolean;
isLabel?: boolean;
onClickFilterLabel?: (key: string, value: string) => void;
onClickFilterOutLabel?: (key: string, value: string) => void;
links?: Array<LinkModel<Field>>;
getStats: () => LogLabelStatsModel[] | null;
displayedFields?: string[];
onClickShowField?: (key: string) => void;
onClickHideField?: (key: string) => void;
row: LogRowModel;
app?: CoreApp;
}
interface State {
showFieldsStats: boolean;
fieldCount: number;
fieldStats: LogLabelStatsModel[] | null;
}
const getStyles = memoizeOne((theme: GrafanaTheme2) => {
return {
wordBreakAll: css`
label: wordBreakAll;
word-break: break-all;
`,
copyButton: css`
& > button {
color: ${theme.colors.text.secondary};
padding: 0;
justify-content: center;
border-radius: 50%;
height: ${theme.spacing(theme.components.height.sm)};
width: ${theme.spacing(theme.components.height.sm)};
svg {
margin: 0;
}
span > div {
top: -5px;
& button {
color: ${theme.colors.success.main};
}
}
}
`,
Explore: Show log line if there is an interpolated link (#62926) * bring in source from database * bring in transformations from database * add regex transformations to scopevar * Consolidate types, add better example, cleanup * Add var only if match * Change ScopedVar to not require text, do not leak transformation-made variables between links * Add mappings and start implementing logfmt * Add mappings and start implementing logfmt * Remove mappings, turn off global regex * Add example yaml and omit transformations if empty * Fix the yaml * Add logfmt transformation * Cleanup transformations and yaml * add transformation field to FE types and use it, safeStringify logfmt values * Add tests, only safe stringify if non-string, fix bug with safe stringify where it would return empty string with false value * Add test for transformation field * Do not add null transformations object * Add provisioning (to be removed) and show log lines with links * Only display links if change to query was made * Break out transformation logic, add tests to backend code * Fix lint errors I understand 😅 * Fix the backend lint error * Remove unnecessary code and mark new Transformations object as internal * Add support for named capture groups * Remove type assertion * Remove variable name from transformation * Add test for overriding regexes * Add back variable name field, but change to mapValue * fix go api test * Change transformation types to enum, add better provisioning checks for bad type name and format * Change transformation types to enum, add better provisioning checks for bad type name and format * Check for expression with regex transformations * Remove isInterpolated variable, add option to always use format function * Add template variable check to links * Use new functions * Filter log line at render, remove extra createSpanLink imports * Add scrollable to long log messages * Remove test that is no longer accurate * Remove test correlation * Add tests, fix duplicate key issue * WIP: show log line links key/value pairs * Some not great style changes * Change LogDetailsRow for better multi value formatting * Cleanup * Add additional information around variable regex, implement PR feedback * Display name with fieldPath if applicable * Add variables with fieldPaths to test * Count empty string as undefined variable * Add better commented version of function, fix tests by removing new variable * Modify when links show * Remove sample yaml * If a link has no variables, set value to field name, and some formatting issues * Add comments and change variable names to be more clear, add back logic where needed, add test coverage for new scenario * Fix formatting of replaceInVariableRegex comment * Remove changes from Grafana-data, move logic into explore * Rename function and property to match similar format * Move types to type files and consolidate definitions, rename functions, change field definitions to accept arrays of keys/values, move function to parser, hide actions on multi key/value rows * Add tests to logParser’s new function
2 years ago
adjoiningLinkButton: css`
margin-left: ${theme.spacing(1)};
`,
wrapLine: css`
label: wrapLine;
white-space: pre-wrap;
`,
logDetailsStats: css`
padding: 0 ${theme.spacing(1)};
`,
logDetailsValue: css`
Explore: Show log line if there is an interpolated link (#62926) * bring in source from database * bring in transformations from database * add regex transformations to scopevar * Consolidate types, add better example, cleanup * Add var only if match * Change ScopedVar to not require text, do not leak transformation-made variables between links * Add mappings and start implementing logfmt * Add mappings and start implementing logfmt * Remove mappings, turn off global regex * Add example yaml and omit transformations if empty * Fix the yaml * Add logfmt transformation * Cleanup transformations and yaml * add transformation field to FE types and use it, safeStringify logfmt values * Add tests, only safe stringify if non-string, fix bug with safe stringify where it would return empty string with false value * Add test for transformation field * Do not add null transformations object * Add provisioning (to be removed) and show log lines with links * Only display links if change to query was made * Break out transformation logic, add tests to backend code * Fix lint errors I understand 😅 * Fix the backend lint error * Remove unnecessary code and mark new Transformations object as internal * Add support for named capture groups * Remove type assertion * Remove variable name from transformation * Add test for overriding regexes * Add back variable name field, but change to mapValue * fix go api test * Change transformation types to enum, add better provisioning checks for bad type name and format * Change transformation types to enum, add better provisioning checks for bad type name and format * Check for expression with regex transformations * Remove isInterpolated variable, add option to always use format function * Add template variable check to links * Use new functions * Filter log line at render, remove extra createSpanLink imports * Add scrollable to long log messages * Remove test that is no longer accurate * Remove test correlation * Add tests, fix duplicate key issue * WIP: show log line links key/value pairs * Some not great style changes * Change LogDetailsRow for better multi value formatting * Cleanup * Add additional information around variable regex, implement PR feedback * Display name with fieldPath if applicable * Add variables with fieldPaths to test * Count empty string as undefined variable * Add better commented version of function, fix tests by removing new variable * Modify when links show * Remove sample yaml * If a link has no variables, set value to field name, and some formatting issues * Add comments and change variable names to be more clear, add back logic where needed, add test coverage for new scenario * Fix formatting of replaceInVariableRegex comment * Remove changes from Grafana-data, move logic into explore * Rename function and property to match similar format * Move types to type files and consolidate definitions, rename functions, change field definitions to accept arrays of keys/values, move function to parser, hide actions on multi key/value rows * Add tests to logParser’s new function
2 years ago
display: flex;
align-items: center;
line-height: 22px;
.show-on-hover {
display: inline;
visibility: hidden;
}
&:hover {
.show-on-hover {
visibility: visible;
}
}
`,
buttonRow: css`
display: flex;
flex-direction: row;
gap: ${theme.spacing(0.5)};
margin-left: ${theme.spacing(0.5)};
`,
};
});
class UnThemedLogDetailsRow extends PureComponent<Props, State> {
state: State = {
showFieldsStats: false,
fieldCount: 0,
fieldStats: null,
};
componentDidUpdate() {
if (this.state.showFieldsStats) {
this.updateStats();
}
}
showField = () => {
Explore: Show log line if there is an interpolated link (#62926) * bring in source from database * bring in transformations from database * add regex transformations to scopevar * Consolidate types, add better example, cleanup * Add var only if match * Change ScopedVar to not require text, do not leak transformation-made variables between links * Add mappings and start implementing logfmt * Add mappings and start implementing logfmt * Remove mappings, turn off global regex * Add example yaml and omit transformations if empty * Fix the yaml * Add logfmt transformation * Cleanup transformations and yaml * add transformation field to FE types and use it, safeStringify logfmt values * Add tests, only safe stringify if non-string, fix bug with safe stringify where it would return empty string with false value * Add test for transformation field * Do not add null transformations object * Add provisioning (to be removed) and show log lines with links * Only display links if change to query was made * Break out transformation logic, add tests to backend code * Fix lint errors I understand 😅 * Fix the backend lint error * Remove unnecessary code and mark new Transformations object as internal * Add support for named capture groups * Remove type assertion * Remove variable name from transformation * Add test for overriding regexes * Add back variable name field, but change to mapValue * fix go api test * Change transformation types to enum, add better provisioning checks for bad type name and format * Change transformation types to enum, add better provisioning checks for bad type name and format * Check for expression with regex transformations * Remove isInterpolated variable, add option to always use format function * Add template variable check to links * Use new functions * Filter log line at render, remove extra createSpanLink imports * Add scrollable to long log messages * Remove test that is no longer accurate * Remove test correlation * Add tests, fix duplicate key issue * WIP: show log line links key/value pairs * Some not great style changes * Change LogDetailsRow for better multi value formatting * Cleanup * Add additional information around variable regex, implement PR feedback * Display name with fieldPath if applicable * Add variables with fieldPaths to test * Count empty string as undefined variable * Add better commented version of function, fix tests by removing new variable * Modify when links show * Remove sample yaml * If a link has no variables, set value to field name, and some formatting issues * Add comments and change variable names to be more clear, add back logic where needed, add test coverage for new scenario * Fix formatting of replaceInVariableRegex comment * Remove changes from Grafana-data, move logic into explore * Rename function and property to match similar format * Move types to type files and consolidate definitions, rename functions, change field definitions to accept arrays of keys/values, move function to parser, hide actions on multi key/value rows * Add tests to logParser’s new function
2 years ago
const { onClickShowField: onClickShowDetectedField, parsedKeys, row } = this.props;
if (onClickShowDetectedField) {
Explore: Show log line if there is an interpolated link (#62926) * bring in source from database * bring in transformations from database * add regex transformations to scopevar * Consolidate types, add better example, cleanup * Add var only if match * Change ScopedVar to not require text, do not leak transformation-made variables between links * Add mappings and start implementing logfmt * Add mappings and start implementing logfmt * Remove mappings, turn off global regex * Add example yaml and omit transformations if empty * Fix the yaml * Add logfmt transformation * Cleanup transformations and yaml * add transformation field to FE types and use it, safeStringify logfmt values * Add tests, only safe stringify if non-string, fix bug with safe stringify where it would return empty string with false value * Add test for transformation field * Do not add null transformations object * Add provisioning (to be removed) and show log lines with links * Only display links if change to query was made * Break out transformation logic, add tests to backend code * Fix lint errors I understand 😅 * Fix the backend lint error * Remove unnecessary code and mark new Transformations object as internal * Add support for named capture groups * Remove type assertion * Remove variable name from transformation * Add test for overriding regexes * Add back variable name field, but change to mapValue * fix go api test * Change transformation types to enum, add better provisioning checks for bad type name and format * Change transformation types to enum, add better provisioning checks for bad type name and format * Check for expression with regex transformations * Remove isInterpolated variable, add option to always use format function * Add template variable check to links * Use new functions * Filter log line at render, remove extra createSpanLink imports * Add scrollable to long log messages * Remove test that is no longer accurate * Remove test correlation * Add tests, fix duplicate key issue * WIP: show log line links key/value pairs * Some not great style changes * Change LogDetailsRow for better multi value formatting * Cleanup * Add additional information around variable regex, implement PR feedback * Display name with fieldPath if applicable * Add variables with fieldPaths to test * Count empty string as undefined variable * Add better commented version of function, fix tests by removing new variable * Modify when links show * Remove sample yaml * If a link has no variables, set value to field name, and some formatting issues * Add comments and change variable names to be more clear, add back logic where needed, add test coverage for new scenario * Fix formatting of replaceInVariableRegex comment * Remove changes from Grafana-data, move logic into explore * Rename function and property to match similar format * Move types to type files and consolidate definitions, rename functions, change field definitions to accept arrays of keys/values, move function to parser, hide actions on multi key/value rows * Add tests to logParser’s new function
2 years ago
onClickShowDetectedField(parsedKeys[0]);
}
reportInteraction('grafana_explore_logs_log_details_replace_line_clicked', {
datasourceType: row.datasourceType,
logRowUid: row.uid,
type: 'enable',
});
};
hideField = () => {
Explore: Show log line if there is an interpolated link (#62926) * bring in source from database * bring in transformations from database * add regex transformations to scopevar * Consolidate types, add better example, cleanup * Add var only if match * Change ScopedVar to not require text, do not leak transformation-made variables between links * Add mappings and start implementing logfmt * Add mappings and start implementing logfmt * Remove mappings, turn off global regex * Add example yaml and omit transformations if empty * Fix the yaml * Add logfmt transformation * Cleanup transformations and yaml * add transformation field to FE types and use it, safeStringify logfmt values * Add tests, only safe stringify if non-string, fix bug with safe stringify where it would return empty string with false value * Add test for transformation field * Do not add null transformations object * Add provisioning (to be removed) and show log lines with links * Only display links if change to query was made * Break out transformation logic, add tests to backend code * Fix lint errors I understand 😅 * Fix the backend lint error * Remove unnecessary code and mark new Transformations object as internal * Add support for named capture groups * Remove type assertion * Remove variable name from transformation * Add test for overriding regexes * Add back variable name field, but change to mapValue * fix go api test * Change transformation types to enum, add better provisioning checks for bad type name and format * Change transformation types to enum, add better provisioning checks for bad type name and format * Check for expression with regex transformations * Remove isInterpolated variable, add option to always use format function * Add template variable check to links * Use new functions * Filter log line at render, remove extra createSpanLink imports * Add scrollable to long log messages * Remove test that is no longer accurate * Remove test correlation * Add tests, fix duplicate key issue * WIP: show log line links key/value pairs * Some not great style changes * Change LogDetailsRow for better multi value formatting * Cleanup * Add additional information around variable regex, implement PR feedback * Display name with fieldPath if applicable * Add variables with fieldPaths to test * Count empty string as undefined variable * Add better commented version of function, fix tests by removing new variable * Modify when links show * Remove sample yaml * If a link has no variables, set value to field name, and some formatting issues * Add comments and change variable names to be more clear, add back logic where needed, add test coverage for new scenario * Fix formatting of replaceInVariableRegex comment * Remove changes from Grafana-data, move logic into explore * Rename function and property to match similar format * Move types to type files and consolidate definitions, rename functions, change field definitions to accept arrays of keys/values, move function to parser, hide actions on multi key/value rows * Add tests to logParser’s new function
2 years ago
const { onClickHideField: onClickHideDetectedField, parsedKeys, row } = this.props;
if (onClickHideDetectedField) {
Explore: Show log line if there is an interpolated link (#62926) * bring in source from database * bring in transformations from database * add regex transformations to scopevar * Consolidate types, add better example, cleanup * Add var only if match * Change ScopedVar to not require text, do not leak transformation-made variables between links * Add mappings and start implementing logfmt * Add mappings and start implementing logfmt * Remove mappings, turn off global regex * Add example yaml and omit transformations if empty * Fix the yaml * Add logfmt transformation * Cleanup transformations and yaml * add transformation field to FE types and use it, safeStringify logfmt values * Add tests, only safe stringify if non-string, fix bug with safe stringify where it would return empty string with false value * Add test for transformation field * Do not add null transformations object * Add provisioning (to be removed) and show log lines with links * Only display links if change to query was made * Break out transformation logic, add tests to backend code * Fix lint errors I understand 😅 * Fix the backend lint error * Remove unnecessary code and mark new Transformations object as internal * Add support for named capture groups * Remove type assertion * Remove variable name from transformation * Add test for overriding regexes * Add back variable name field, but change to mapValue * fix go api test * Change transformation types to enum, add better provisioning checks for bad type name and format * Change transformation types to enum, add better provisioning checks for bad type name and format * Check for expression with regex transformations * Remove isInterpolated variable, add option to always use format function * Add template variable check to links * Use new functions * Filter log line at render, remove extra createSpanLink imports * Add scrollable to long log messages * Remove test that is no longer accurate * Remove test correlation * Add tests, fix duplicate key issue * WIP: show log line links key/value pairs * Some not great style changes * Change LogDetailsRow for better multi value formatting * Cleanup * Add additional information around variable regex, implement PR feedback * Display name with fieldPath if applicable * Add variables with fieldPaths to test * Count empty string as undefined variable * Add better commented version of function, fix tests by removing new variable * Modify when links show * Remove sample yaml * If a link has no variables, set value to field name, and some formatting issues * Add comments and change variable names to be more clear, add back logic where needed, add test coverage for new scenario * Fix formatting of replaceInVariableRegex comment * Remove changes from Grafana-data, move logic into explore * Rename function and property to match similar format * Move types to type files and consolidate definitions, rename functions, change field definitions to accept arrays of keys/values, move function to parser, hide actions on multi key/value rows * Add tests to logParser’s new function
2 years ago
onClickHideDetectedField(parsedKeys[0]);
}
reportInteraction('grafana_explore_logs_log_details_replace_line_clicked', {
datasourceType: row.datasourceType,
logRowUid: row.uid,
type: 'disable',
});
};
filterLabel = () => {
Explore: Show log line if there is an interpolated link (#62926) * bring in source from database * bring in transformations from database * add regex transformations to scopevar * Consolidate types, add better example, cleanup * Add var only if match * Change ScopedVar to not require text, do not leak transformation-made variables between links * Add mappings and start implementing logfmt * Add mappings and start implementing logfmt * Remove mappings, turn off global regex * Add example yaml and omit transformations if empty * Fix the yaml * Add logfmt transformation * Cleanup transformations and yaml * add transformation field to FE types and use it, safeStringify logfmt values * Add tests, only safe stringify if non-string, fix bug with safe stringify where it would return empty string with false value * Add test for transformation field * Do not add null transformations object * Add provisioning (to be removed) and show log lines with links * Only display links if change to query was made * Break out transformation logic, add tests to backend code * Fix lint errors I understand 😅 * Fix the backend lint error * Remove unnecessary code and mark new Transformations object as internal * Add support for named capture groups * Remove type assertion * Remove variable name from transformation * Add test for overriding regexes * Add back variable name field, but change to mapValue * fix go api test * Change transformation types to enum, add better provisioning checks for bad type name and format * Change transformation types to enum, add better provisioning checks for bad type name and format * Check for expression with regex transformations * Remove isInterpolated variable, add option to always use format function * Add template variable check to links * Use new functions * Filter log line at render, remove extra createSpanLink imports * Add scrollable to long log messages * Remove test that is no longer accurate * Remove test correlation * Add tests, fix duplicate key issue * WIP: show log line links key/value pairs * Some not great style changes * Change LogDetailsRow for better multi value formatting * Cleanup * Add additional information around variable regex, implement PR feedback * Display name with fieldPath if applicable * Add variables with fieldPaths to test * Count empty string as undefined variable * Add better commented version of function, fix tests by removing new variable * Modify when links show * Remove sample yaml * If a link has no variables, set value to field name, and some formatting issues * Add comments and change variable names to be more clear, add back logic where needed, add test coverage for new scenario * Fix formatting of replaceInVariableRegex comment * Remove changes from Grafana-data, move logic into explore * Rename function and property to match similar format * Move types to type files and consolidate definitions, rename functions, change field definitions to accept arrays of keys/values, move function to parser, hide actions on multi key/value rows * Add tests to logParser’s new function
2 years ago
const { onClickFilterLabel, parsedKeys, parsedValues, row } = this.props;
if (onClickFilterLabel) {
Explore: Show log line if there is an interpolated link (#62926) * bring in source from database * bring in transformations from database * add regex transformations to scopevar * Consolidate types, add better example, cleanup * Add var only if match * Change ScopedVar to not require text, do not leak transformation-made variables between links * Add mappings and start implementing logfmt * Add mappings and start implementing logfmt * Remove mappings, turn off global regex * Add example yaml and omit transformations if empty * Fix the yaml * Add logfmt transformation * Cleanup transformations and yaml * add transformation field to FE types and use it, safeStringify logfmt values * Add tests, only safe stringify if non-string, fix bug with safe stringify where it would return empty string with false value * Add test for transformation field * Do not add null transformations object * Add provisioning (to be removed) and show log lines with links * Only display links if change to query was made * Break out transformation logic, add tests to backend code * Fix lint errors I understand 😅 * Fix the backend lint error * Remove unnecessary code and mark new Transformations object as internal * Add support for named capture groups * Remove type assertion * Remove variable name from transformation * Add test for overriding regexes * Add back variable name field, but change to mapValue * fix go api test * Change transformation types to enum, add better provisioning checks for bad type name and format * Change transformation types to enum, add better provisioning checks for bad type name and format * Check for expression with regex transformations * Remove isInterpolated variable, add option to always use format function * Add template variable check to links * Use new functions * Filter log line at render, remove extra createSpanLink imports * Add scrollable to long log messages * Remove test that is no longer accurate * Remove test correlation * Add tests, fix duplicate key issue * WIP: show log line links key/value pairs * Some not great style changes * Change LogDetailsRow for better multi value formatting * Cleanup * Add additional information around variable regex, implement PR feedback * Display name with fieldPath if applicable * Add variables with fieldPaths to test * Count empty string as undefined variable * Add better commented version of function, fix tests by removing new variable * Modify when links show * Remove sample yaml * If a link has no variables, set value to field name, and some formatting issues * Add comments and change variable names to be more clear, add back logic where needed, add test coverage for new scenario * Fix formatting of replaceInVariableRegex comment * Remove changes from Grafana-data, move logic into explore * Rename function and property to match similar format * Move types to type files and consolidate definitions, rename functions, change field definitions to accept arrays of keys/values, move function to parser, hide actions on multi key/value rows * Add tests to logParser’s new function
2 years ago
onClickFilterLabel(parsedKeys[0], parsedValues[0]);
}
reportInteraction('grafana_explore_logs_log_details_filter_clicked', {
datasourceType: row.datasourceType,
filterType: 'include',
logRowUid: row.uid,
});
};
filterOutLabel = () => {
Explore: Show log line if there is an interpolated link (#62926) * bring in source from database * bring in transformations from database * add regex transformations to scopevar * Consolidate types, add better example, cleanup * Add var only if match * Change ScopedVar to not require text, do not leak transformation-made variables between links * Add mappings and start implementing logfmt * Add mappings and start implementing logfmt * Remove mappings, turn off global regex * Add example yaml and omit transformations if empty * Fix the yaml * Add logfmt transformation * Cleanup transformations and yaml * add transformation field to FE types and use it, safeStringify logfmt values * Add tests, only safe stringify if non-string, fix bug with safe stringify where it would return empty string with false value * Add test for transformation field * Do not add null transformations object * Add provisioning (to be removed) and show log lines with links * Only display links if change to query was made * Break out transformation logic, add tests to backend code * Fix lint errors I understand 😅 * Fix the backend lint error * Remove unnecessary code and mark new Transformations object as internal * Add support for named capture groups * Remove type assertion * Remove variable name from transformation * Add test for overriding regexes * Add back variable name field, but change to mapValue * fix go api test * Change transformation types to enum, add better provisioning checks for bad type name and format * Change transformation types to enum, add better provisioning checks for bad type name and format * Check for expression with regex transformations * Remove isInterpolated variable, add option to always use format function * Add template variable check to links * Use new functions * Filter log line at render, remove extra createSpanLink imports * Add scrollable to long log messages * Remove test that is no longer accurate * Remove test correlation * Add tests, fix duplicate key issue * WIP: show log line links key/value pairs * Some not great style changes * Change LogDetailsRow for better multi value formatting * Cleanup * Add additional information around variable regex, implement PR feedback * Display name with fieldPath if applicable * Add variables with fieldPaths to test * Count empty string as undefined variable * Add better commented version of function, fix tests by removing new variable * Modify when links show * Remove sample yaml * If a link has no variables, set value to field name, and some formatting issues * Add comments and change variable names to be more clear, add back logic where needed, add test coverage for new scenario * Fix formatting of replaceInVariableRegex comment * Remove changes from Grafana-data, move logic into explore * Rename function and property to match similar format * Move types to type files and consolidate definitions, rename functions, change field definitions to accept arrays of keys/values, move function to parser, hide actions on multi key/value rows * Add tests to logParser’s new function
2 years ago
const { onClickFilterOutLabel, parsedKeys, parsedValues, row } = this.props;
if (onClickFilterOutLabel) {
Explore: Show log line if there is an interpolated link (#62926) * bring in source from database * bring in transformations from database * add regex transformations to scopevar * Consolidate types, add better example, cleanup * Add var only if match * Change ScopedVar to not require text, do not leak transformation-made variables between links * Add mappings and start implementing logfmt * Add mappings and start implementing logfmt * Remove mappings, turn off global regex * Add example yaml and omit transformations if empty * Fix the yaml * Add logfmt transformation * Cleanup transformations and yaml * add transformation field to FE types and use it, safeStringify logfmt values * Add tests, only safe stringify if non-string, fix bug with safe stringify where it would return empty string with false value * Add test for transformation field * Do not add null transformations object * Add provisioning (to be removed) and show log lines with links * Only display links if change to query was made * Break out transformation logic, add tests to backend code * Fix lint errors I understand 😅 * Fix the backend lint error * Remove unnecessary code and mark new Transformations object as internal * Add support for named capture groups * Remove type assertion * Remove variable name from transformation * Add test for overriding regexes * Add back variable name field, but change to mapValue * fix go api test * Change transformation types to enum, add better provisioning checks for bad type name and format * Change transformation types to enum, add better provisioning checks for bad type name and format * Check for expression with regex transformations * Remove isInterpolated variable, add option to always use format function * Add template variable check to links * Use new functions * Filter log line at render, remove extra createSpanLink imports * Add scrollable to long log messages * Remove test that is no longer accurate * Remove test correlation * Add tests, fix duplicate key issue * WIP: show log line links key/value pairs * Some not great style changes * Change LogDetailsRow for better multi value formatting * Cleanup * Add additional information around variable regex, implement PR feedback * Display name with fieldPath if applicable * Add variables with fieldPaths to test * Count empty string as undefined variable * Add better commented version of function, fix tests by removing new variable * Modify when links show * Remove sample yaml * If a link has no variables, set value to field name, and some formatting issues * Add comments and change variable names to be more clear, add back logic where needed, add test coverage for new scenario * Fix formatting of replaceInVariableRegex comment * Remove changes from Grafana-data, move logic into explore * Rename function and property to match similar format * Move types to type files and consolidate definitions, rename functions, change field definitions to accept arrays of keys/values, move function to parser, hide actions on multi key/value rows * Add tests to logParser’s new function
2 years ago
onClickFilterOutLabel(parsedKeys[0], parsedValues[0]);
}
reportInteraction('grafana_explore_logs_log_details_filter_clicked', {
datasourceType: row.datasourceType,
filterType: 'exclude',
logRowUid: row.uid,
});
};
updateStats = () => {
const { getStats } = this.props;
const fieldStats = getStats();
const fieldCount = fieldStats ? fieldStats.reduce((sum, stat) => sum + stat.count, 0) : 0;
if (!isEqual(this.state.fieldStats, fieldStats) || fieldCount !== this.state.fieldCount) {
this.setState({ fieldStats, fieldCount });
}
};
showStats = () => {
const { isLabel, row, app } = this.props;
const { showFieldsStats } = this.state;
if (!showFieldsStats) {
this.updateStats();
}
this.toggleFieldsStats();
reportInteraction('grafana_explore_logs_log_details_stats_clicked', {
dataSourceType: row.datasourceType,
fieldType: isLabel ? 'label' : 'detectedField',
type: showFieldsStats ? 'close' : 'open',
logRowUid: row.uid,
app,
});
};
toggleFieldsStats() {
this.setState((state) => {
return {
showFieldsStats: !state.showFieldsStats,
};
});
}
Explore: Show log line if there is an interpolated link (#62926) * bring in source from database * bring in transformations from database * add regex transformations to scopevar * Consolidate types, add better example, cleanup * Add var only if match * Change ScopedVar to not require text, do not leak transformation-made variables between links * Add mappings and start implementing logfmt * Add mappings and start implementing logfmt * Remove mappings, turn off global regex * Add example yaml and omit transformations if empty * Fix the yaml * Add logfmt transformation * Cleanup transformations and yaml * add transformation field to FE types and use it, safeStringify logfmt values * Add tests, only safe stringify if non-string, fix bug with safe stringify where it would return empty string with false value * Add test for transformation field * Do not add null transformations object * Add provisioning (to be removed) and show log lines with links * Only display links if change to query was made * Break out transformation logic, add tests to backend code * Fix lint errors I understand 😅 * Fix the backend lint error * Remove unnecessary code and mark new Transformations object as internal * Add support for named capture groups * Remove type assertion * Remove variable name from transformation * Add test for overriding regexes * Add back variable name field, but change to mapValue * fix go api test * Change transformation types to enum, add better provisioning checks for bad type name and format * Change transformation types to enum, add better provisioning checks for bad type name and format * Check for expression with regex transformations * Remove isInterpolated variable, add option to always use format function * Add template variable check to links * Use new functions * Filter log line at render, remove extra createSpanLink imports * Add scrollable to long log messages * Remove test that is no longer accurate * Remove test correlation * Add tests, fix duplicate key issue * WIP: show log line links key/value pairs * Some not great style changes * Change LogDetailsRow for better multi value formatting * Cleanup * Add additional information around variable regex, implement PR feedback * Display name with fieldPath if applicable * Add variables with fieldPaths to test * Count empty string as undefined variable * Add better commented version of function, fix tests by removing new variable * Modify when links show * Remove sample yaml * If a link has no variables, set value to field name, and some formatting issues * Add comments and change variable names to be more clear, add back logic where needed, add test coverage for new scenario * Fix formatting of replaceInVariableRegex comment * Remove changes from Grafana-data, move logic into explore * Rename function and property to match similar format * Move types to type files and consolidate definitions, rename functions, change field definitions to accept arrays of keys/values, move function to parser, hide actions on multi key/value rows * Add tests to logParser’s new function
2 years ago
generateClipboardButton(val: string) {
const { theme } = this.props;
const styles = getStyles(theme);
return (
<div className={cx('show-on-hover', styles.copyButton)}>
<ClipboardButton
getText={() => val}
title="Copy value to clipboard"
fill="text"
variant="secondary"
icon="copy"
size="md"
/>
</div>
);
}
generateMultiVal(value: string[], showCopy?: boolean) {
return (
<table>
<tbody>
{value?.map((val, i) => {
return (
<tr key={`${val}-${i}`}>
<td>
{val}
{showCopy && val !== '' && this.generateClipboardButton(val)}
</td>
</tr>
);
})}
</tbody>
</table>
);
}
render() {
const {
theme,
Explore: Show log line if there is an interpolated link (#62926) * bring in source from database * bring in transformations from database * add regex transformations to scopevar * Consolidate types, add better example, cleanup * Add var only if match * Change ScopedVar to not require text, do not leak transformation-made variables between links * Add mappings and start implementing logfmt * Add mappings and start implementing logfmt * Remove mappings, turn off global regex * Add example yaml and omit transformations if empty * Fix the yaml * Add logfmt transformation * Cleanup transformations and yaml * add transformation field to FE types and use it, safeStringify logfmt values * Add tests, only safe stringify if non-string, fix bug with safe stringify where it would return empty string with false value * Add test for transformation field * Do not add null transformations object * Add provisioning (to be removed) and show log lines with links * Only display links if change to query was made * Break out transformation logic, add tests to backend code * Fix lint errors I understand 😅 * Fix the backend lint error * Remove unnecessary code and mark new Transformations object as internal * Add support for named capture groups * Remove type assertion * Remove variable name from transformation * Add test for overriding regexes * Add back variable name field, but change to mapValue * fix go api test * Change transformation types to enum, add better provisioning checks for bad type name and format * Change transformation types to enum, add better provisioning checks for bad type name and format * Check for expression with regex transformations * Remove isInterpolated variable, add option to always use format function * Add template variable check to links * Use new functions * Filter log line at render, remove extra createSpanLink imports * Add scrollable to long log messages * Remove test that is no longer accurate * Remove test correlation * Add tests, fix duplicate key issue * WIP: show log line links key/value pairs * Some not great style changes * Change LogDetailsRow for better multi value formatting * Cleanup * Add additional information around variable regex, implement PR feedback * Display name with fieldPath if applicable * Add variables with fieldPaths to test * Count empty string as undefined variable * Add better commented version of function, fix tests by removing new variable * Modify when links show * Remove sample yaml * If a link has no variables, set value to field name, and some formatting issues * Add comments and change variable names to be more clear, add back logic where needed, add test coverage for new scenario * Fix formatting of replaceInVariableRegex comment * Remove changes from Grafana-data, move logic into explore * Rename function and property to match similar format * Move types to type files and consolidate definitions, rename functions, change field definitions to accept arrays of keys/values, move function to parser, hide actions on multi key/value rows * Add tests to logParser’s new function
2 years ago
parsedKeys,
parsedValues,
isLabel,
links,
displayedFields,
wrapLogMessage,
onClickFilterLabel,
onClickFilterOutLabel,
Explore: Show log line if there is an interpolated link (#62926) * bring in source from database * bring in transformations from database * add regex transformations to scopevar * Consolidate types, add better example, cleanup * Add var only if match * Change ScopedVar to not require text, do not leak transformation-made variables between links * Add mappings and start implementing logfmt * Add mappings and start implementing logfmt * Remove mappings, turn off global regex * Add example yaml and omit transformations if empty * Fix the yaml * Add logfmt transformation * Cleanup transformations and yaml * add transformation field to FE types and use it, safeStringify logfmt values * Add tests, only safe stringify if non-string, fix bug with safe stringify where it would return empty string with false value * Add test for transformation field * Do not add null transformations object * Add provisioning (to be removed) and show log lines with links * Only display links if change to query was made * Break out transformation logic, add tests to backend code * Fix lint errors I understand 😅 * Fix the backend lint error * Remove unnecessary code and mark new Transformations object as internal * Add support for named capture groups * Remove type assertion * Remove variable name from transformation * Add test for overriding regexes * Add back variable name field, but change to mapValue * fix go api test * Change transformation types to enum, add better provisioning checks for bad type name and format * Change transformation types to enum, add better provisioning checks for bad type name and format * Check for expression with regex transformations * Remove isInterpolated variable, add option to always use format function * Add template variable check to links * Use new functions * Filter log line at render, remove extra createSpanLink imports * Add scrollable to long log messages * Remove test that is no longer accurate * Remove test correlation * Add tests, fix duplicate key issue * WIP: show log line links key/value pairs * Some not great style changes * Change LogDetailsRow for better multi value formatting * Cleanup * Add additional information around variable regex, implement PR feedback * Display name with fieldPath if applicable * Add variables with fieldPaths to test * Count empty string as undefined variable * Add better commented version of function, fix tests by removing new variable * Modify when links show * Remove sample yaml * If a link has no variables, set value to field name, and some formatting issues * Add comments and change variable names to be more clear, add back logic where needed, add test coverage for new scenario * Fix formatting of replaceInVariableRegex comment * Remove changes from Grafana-data, move logic into explore * Rename function and property to match similar format * Move types to type files and consolidate definitions, rename functions, change field definitions to accept arrays of keys/values, move function to parser, hide actions on multi key/value rows * Add tests to logParser’s new function
2 years ago
disableActions,
} = this.props;
const { showFieldsStats, fieldStats, fieldCount } = this.state;
const styles = getStyles(theme);
const style = getLogRowStyles(theme);
Explore: Show log line if there is an interpolated link (#62926) * bring in source from database * bring in transformations from database * add regex transformations to scopevar * Consolidate types, add better example, cleanup * Add var only if match * Change ScopedVar to not require text, do not leak transformation-made variables between links * Add mappings and start implementing logfmt * Add mappings and start implementing logfmt * Remove mappings, turn off global regex * Add example yaml and omit transformations if empty * Fix the yaml * Add logfmt transformation * Cleanup transformations and yaml * add transformation field to FE types and use it, safeStringify logfmt values * Add tests, only safe stringify if non-string, fix bug with safe stringify where it would return empty string with false value * Add test for transformation field * Do not add null transformations object * Add provisioning (to be removed) and show log lines with links * Only display links if change to query was made * Break out transformation logic, add tests to backend code * Fix lint errors I understand 😅 * Fix the backend lint error * Remove unnecessary code and mark new Transformations object as internal * Add support for named capture groups * Remove type assertion * Remove variable name from transformation * Add test for overriding regexes * Add back variable name field, but change to mapValue * fix go api test * Change transformation types to enum, add better provisioning checks for bad type name and format * Change transformation types to enum, add better provisioning checks for bad type name and format * Check for expression with regex transformations * Remove isInterpolated variable, add option to always use format function * Add template variable check to links * Use new functions * Filter log line at render, remove extra createSpanLink imports * Add scrollable to long log messages * Remove test that is no longer accurate * Remove test correlation * Add tests, fix duplicate key issue * WIP: show log line links key/value pairs * Some not great style changes * Change LogDetailsRow for better multi value formatting * Cleanup * Add additional information around variable regex, implement PR feedback * Display name with fieldPath if applicable * Add variables with fieldPaths to test * Count empty string as undefined variable * Add better commented version of function, fix tests by removing new variable * Modify when links show * Remove sample yaml * If a link has no variables, set value to field name, and some formatting issues * Add comments and change variable names to be more clear, add back logic where needed, add test coverage for new scenario * Fix formatting of replaceInVariableRegex comment * Remove changes from Grafana-data, move logic into explore * Rename function and property to match similar format * Move types to type files and consolidate definitions, rename functions, change field definitions to accept arrays of keys/values, move function to parser, hide actions on multi key/value rows * Add tests to logParser’s new function
2 years ago
const singleKey = parsedKeys == null ? false : parsedKeys.length === 1;
const singleVal = parsedValues == null ? false : parsedValues.length === 1;
const hasFilteringFunctionality = !disableActions && onClickFilterLabel && onClickFilterOutLabel;
const isMultiParsedValueWithNoContent =
!singleVal && parsedValues != null && !parsedValues.every((val) => val === '');
const toggleFieldButton =
Explore: Show log line if there is an interpolated link (#62926) * bring in source from database * bring in transformations from database * add regex transformations to scopevar * Consolidate types, add better example, cleanup * Add var only if match * Change ScopedVar to not require text, do not leak transformation-made variables between links * Add mappings and start implementing logfmt * Add mappings and start implementing logfmt * Remove mappings, turn off global regex * Add example yaml and omit transformations if empty * Fix the yaml * Add logfmt transformation * Cleanup transformations and yaml * add transformation field to FE types and use it, safeStringify logfmt values * Add tests, only safe stringify if non-string, fix bug with safe stringify where it would return empty string with false value * Add test for transformation field * Do not add null transformations object * Add provisioning (to be removed) and show log lines with links * Only display links if change to query was made * Break out transformation logic, add tests to backend code * Fix lint errors I understand 😅 * Fix the backend lint error * Remove unnecessary code and mark new Transformations object as internal * Add support for named capture groups * Remove type assertion * Remove variable name from transformation * Add test for overriding regexes * Add back variable name field, but change to mapValue * fix go api test * Change transformation types to enum, add better provisioning checks for bad type name and format * Change transformation types to enum, add better provisioning checks for bad type name and format * Check for expression with regex transformations * Remove isInterpolated variable, add option to always use format function * Add template variable check to links * Use new functions * Filter log line at render, remove extra createSpanLink imports * Add scrollable to long log messages * Remove test that is no longer accurate * Remove test correlation * Add tests, fix duplicate key issue * WIP: show log line links key/value pairs * Some not great style changes * Change LogDetailsRow for better multi value formatting * Cleanup * Add additional information around variable regex, implement PR feedback * Display name with fieldPath if applicable * Add variables with fieldPaths to test * Count empty string as undefined variable * Add better commented version of function, fix tests by removing new variable * Modify when links show * Remove sample yaml * If a link has no variables, set value to field name, and some formatting issues * Add comments and change variable names to be more clear, add back logic where needed, add test coverage for new scenario * Fix formatting of replaceInVariableRegex comment * Remove changes from Grafana-data, move logic into explore * Rename function and property to match similar format * Move types to type files and consolidate definitions, rename functions, change field definitions to accept arrays of keys/values, move function to parser, hide actions on multi key/value rows * Add tests to logParser’s new function
2 years ago
displayedFields && parsedKeys != null && displayedFields.includes(parsedKeys[0]) ? (
<IconButton variant="primary" tooltip="Hide this field" name="eye" onClick={this.hideField} />
) : (
<IconButton tooltip="Show this field instead of the message" name="eye" onClick={this.showField} />
);
return (
<>
<tr className={cx(style.logDetailsValue)}>
<td className={style.logsDetailsIcon}>
<div className={styles.buttonRow}>
{hasFilteringFunctionality && (
<IconButton name="search-plus" tooltip="Filter for value" onClick={this.filterLabel} />
)}
{hasFilteringFunctionality && (
<IconButton name="search-minus" tooltip="Filter out value" onClick={this.filterOutLabel} />
)}
Explore: Show log line if there is an interpolated link (#62926) * bring in source from database * bring in transformations from database * add regex transformations to scopevar * Consolidate types, add better example, cleanup * Add var only if match * Change ScopedVar to not require text, do not leak transformation-made variables between links * Add mappings and start implementing logfmt * Add mappings and start implementing logfmt * Remove mappings, turn off global regex * Add example yaml and omit transformations if empty * Fix the yaml * Add logfmt transformation * Cleanup transformations and yaml * add transformation field to FE types and use it, safeStringify logfmt values * Add tests, only safe stringify if non-string, fix bug with safe stringify where it would return empty string with false value * Add test for transformation field * Do not add null transformations object * Add provisioning (to be removed) and show log lines with links * Only display links if change to query was made * Break out transformation logic, add tests to backend code * Fix lint errors I understand 😅 * Fix the backend lint error * Remove unnecessary code and mark new Transformations object as internal * Add support for named capture groups * Remove type assertion * Remove variable name from transformation * Add test for overriding regexes * Add back variable name field, but change to mapValue * fix go api test * Change transformation types to enum, add better provisioning checks for bad type name and format * Change transformation types to enum, add better provisioning checks for bad type name and format * Check for expression with regex transformations * Remove isInterpolated variable, add option to always use format function * Add template variable check to links * Use new functions * Filter log line at render, remove extra createSpanLink imports * Add scrollable to long log messages * Remove test that is no longer accurate * Remove test correlation * Add tests, fix duplicate key issue * WIP: show log line links key/value pairs * Some not great style changes * Change LogDetailsRow for better multi value formatting * Cleanup * Add additional information around variable regex, implement PR feedback * Display name with fieldPath if applicable * Add variables with fieldPaths to test * Count empty string as undefined variable * Add better commented version of function, fix tests by removing new variable * Modify when links show * Remove sample yaml * If a link has no variables, set value to field name, and some formatting issues * Add comments and change variable names to be more clear, add back logic where needed, add test coverage for new scenario * Fix formatting of replaceInVariableRegex comment * Remove changes from Grafana-data, move logic into explore * Rename function and property to match similar format * Move types to type files and consolidate definitions, rename functions, change field definitions to accept arrays of keys/values, move function to parser, hide actions on multi key/value rows * Add tests to logParser’s new function
2 years ago
{!disableActions && displayedFields && toggleFieldButton}
{!disableActions && (
<IconButton
variant={showFieldsStats ? 'primary' : 'secondary'}
name="signal"
tooltip="Ad-hoc statistics"
className="stats-button"
disabled={!singleKey}
onClick={this.showStats}
/>
)}
</div>
</td>
{/* Key - value columns */}
Explore: Show log line if there is an interpolated link (#62926) * bring in source from database * bring in transformations from database * add regex transformations to scopevar * Consolidate types, add better example, cleanup * Add var only if match * Change ScopedVar to not require text, do not leak transformation-made variables between links * Add mappings and start implementing logfmt * Add mappings and start implementing logfmt * Remove mappings, turn off global regex * Add example yaml and omit transformations if empty * Fix the yaml * Add logfmt transformation * Cleanup transformations and yaml * add transformation field to FE types and use it, safeStringify logfmt values * Add tests, only safe stringify if non-string, fix bug with safe stringify where it would return empty string with false value * Add test for transformation field * Do not add null transformations object * Add provisioning (to be removed) and show log lines with links * Only display links if change to query was made * Break out transformation logic, add tests to backend code * Fix lint errors I understand 😅 * Fix the backend lint error * Remove unnecessary code and mark new Transformations object as internal * Add support for named capture groups * Remove type assertion * Remove variable name from transformation * Add test for overriding regexes * Add back variable name field, but change to mapValue * fix go api test * Change transformation types to enum, add better provisioning checks for bad type name and format * Change transformation types to enum, add better provisioning checks for bad type name and format * Check for expression with regex transformations * Remove isInterpolated variable, add option to always use format function * Add template variable check to links * Use new functions * Filter log line at render, remove extra createSpanLink imports * Add scrollable to long log messages * Remove test that is no longer accurate * Remove test correlation * Add tests, fix duplicate key issue * WIP: show log line links key/value pairs * Some not great style changes * Change LogDetailsRow for better multi value formatting * Cleanup * Add additional information around variable regex, implement PR feedback * Display name with fieldPath if applicable * Add variables with fieldPaths to test * Count empty string as undefined variable * Add better commented version of function, fix tests by removing new variable * Modify when links show * Remove sample yaml * If a link has no variables, set value to field name, and some formatting issues * Add comments and change variable names to be more clear, add back logic where needed, add test coverage for new scenario * Fix formatting of replaceInVariableRegex comment * Remove changes from Grafana-data, move logic into explore * Rename function and property to match similar format * Move types to type files and consolidate definitions, rename functions, change field definitions to accept arrays of keys/values, move function to parser, hide actions on multi key/value rows * Add tests to logParser’s new function
2 years ago
<td className={style.logDetailsLabel}>{singleKey ? parsedKeys[0] : this.generateMultiVal(parsedKeys)}</td>
<td className={cx(styles.wordBreakAll, wrapLogMessage && styles.wrapLine)}>
<div className={styles.logDetailsValue}>
Explore: Show log line if there is an interpolated link (#62926) * bring in source from database * bring in transformations from database * add regex transformations to scopevar * Consolidate types, add better example, cleanup * Add var only if match * Change ScopedVar to not require text, do not leak transformation-made variables between links * Add mappings and start implementing logfmt * Add mappings and start implementing logfmt * Remove mappings, turn off global regex * Add example yaml and omit transformations if empty * Fix the yaml * Add logfmt transformation * Cleanup transformations and yaml * add transformation field to FE types and use it, safeStringify logfmt values * Add tests, only safe stringify if non-string, fix bug with safe stringify where it would return empty string with false value * Add test for transformation field * Do not add null transformations object * Add provisioning (to be removed) and show log lines with links * Only display links if change to query was made * Break out transformation logic, add tests to backend code * Fix lint errors I understand 😅 * Fix the backend lint error * Remove unnecessary code and mark new Transformations object as internal * Add support for named capture groups * Remove type assertion * Remove variable name from transformation * Add test for overriding regexes * Add back variable name field, but change to mapValue * fix go api test * Change transformation types to enum, add better provisioning checks for bad type name and format * Change transformation types to enum, add better provisioning checks for bad type name and format * Check for expression with regex transformations * Remove isInterpolated variable, add option to always use format function * Add template variable check to links * Use new functions * Filter log line at render, remove extra createSpanLink imports * Add scrollable to long log messages * Remove test that is no longer accurate * Remove test correlation * Add tests, fix duplicate key issue * WIP: show log line links key/value pairs * Some not great style changes * Change LogDetailsRow for better multi value formatting * Cleanup * Add additional information around variable regex, implement PR feedback * Display name with fieldPath if applicable * Add variables with fieldPaths to test * Count empty string as undefined variable * Add better commented version of function, fix tests by removing new variable * Modify when links show * Remove sample yaml * If a link has no variables, set value to field name, and some formatting issues * Add comments and change variable names to be more clear, add back logic where needed, add test coverage for new scenario * Fix formatting of replaceInVariableRegex comment * Remove changes from Grafana-data, move logic into explore * Rename function and property to match similar format * Move types to type files and consolidate definitions, rename functions, change field definitions to accept arrays of keys/values, move function to parser, hide actions on multi key/value rows * Add tests to logParser’s new function
2 years ago
{singleVal ? parsedValues[0] : this.generateMultiVal(parsedValues, true)}
{singleVal && this.generateClipboardButton(parsedValues[0])}
<div className={cx((singleVal || isMultiParsedValueWithNoContent) && styles.adjoiningLinkButton)}>
{links?.map((link, i) => (
<span key={`${link.title}-${i}`}>
<DataLinkButton link={link} />
</span>
))}
</div>
</div>
</td>
</tr>
Explore: Show log line if there is an interpolated link (#62926) * bring in source from database * bring in transformations from database * add regex transformations to scopevar * Consolidate types, add better example, cleanup * Add var only if match * Change ScopedVar to not require text, do not leak transformation-made variables between links * Add mappings and start implementing logfmt * Add mappings and start implementing logfmt * Remove mappings, turn off global regex * Add example yaml and omit transformations if empty * Fix the yaml * Add logfmt transformation * Cleanup transformations and yaml * add transformation field to FE types and use it, safeStringify logfmt values * Add tests, only safe stringify if non-string, fix bug with safe stringify where it would return empty string with false value * Add test for transformation field * Do not add null transformations object * Add provisioning (to be removed) and show log lines with links * Only display links if change to query was made * Break out transformation logic, add tests to backend code * Fix lint errors I understand 😅 * Fix the backend lint error * Remove unnecessary code and mark new Transformations object as internal * Add support for named capture groups * Remove type assertion * Remove variable name from transformation * Add test for overriding regexes * Add back variable name field, but change to mapValue * fix go api test * Change transformation types to enum, add better provisioning checks for bad type name and format * Change transformation types to enum, add better provisioning checks for bad type name and format * Check for expression with regex transformations * Remove isInterpolated variable, add option to always use format function * Add template variable check to links * Use new functions * Filter log line at render, remove extra createSpanLink imports * Add scrollable to long log messages * Remove test that is no longer accurate * Remove test correlation * Add tests, fix duplicate key issue * WIP: show log line links key/value pairs * Some not great style changes * Change LogDetailsRow for better multi value formatting * Cleanup * Add additional information around variable regex, implement PR feedback * Display name with fieldPath if applicable * Add variables with fieldPaths to test * Count empty string as undefined variable * Add better commented version of function, fix tests by removing new variable * Modify when links show * Remove sample yaml * If a link has no variables, set value to field name, and some formatting issues * Add comments and change variable names to be more clear, add back logic where needed, add test coverage for new scenario * Fix formatting of replaceInVariableRegex comment * Remove changes from Grafana-data, move logic into explore * Rename function and property to match similar format * Move types to type files and consolidate definitions, rename functions, change field definitions to accept arrays of keys/values, move function to parser, hide actions on multi key/value rows * Add tests to logParser’s new function
2 years ago
{showFieldsStats && singleKey && singleVal && (
<tr>
<td>
<IconButton
variant={showFieldsStats ? 'primary' : 'secondary'}
name="signal"
tooltip="Hide ad-hoc statistics"
onClick={this.showStats}
/>
</td>
<td colSpan={2}>
<div className={styles.logDetailsStats}>
<LogLabelStats
stats={fieldStats!}
Explore: Show log line if there is an interpolated link (#62926) * bring in source from database * bring in transformations from database * add regex transformations to scopevar * Consolidate types, add better example, cleanup * Add var only if match * Change ScopedVar to not require text, do not leak transformation-made variables between links * Add mappings and start implementing logfmt * Add mappings and start implementing logfmt * Remove mappings, turn off global regex * Add example yaml and omit transformations if empty * Fix the yaml * Add logfmt transformation * Cleanup transformations and yaml * add transformation field to FE types and use it, safeStringify logfmt values * Add tests, only safe stringify if non-string, fix bug with safe stringify where it would return empty string with false value * Add test for transformation field * Do not add null transformations object * Add provisioning (to be removed) and show log lines with links * Only display links if change to query was made * Break out transformation logic, add tests to backend code * Fix lint errors I understand 😅 * Fix the backend lint error * Remove unnecessary code and mark new Transformations object as internal * Add support for named capture groups * Remove type assertion * Remove variable name from transformation * Add test for overriding regexes * Add back variable name field, but change to mapValue * fix go api test * Change transformation types to enum, add better provisioning checks for bad type name and format * Change transformation types to enum, add better provisioning checks for bad type name and format * Check for expression with regex transformations * Remove isInterpolated variable, add option to always use format function * Add template variable check to links * Use new functions * Filter log line at render, remove extra createSpanLink imports * Add scrollable to long log messages * Remove test that is no longer accurate * Remove test correlation * Add tests, fix duplicate key issue * WIP: show log line links key/value pairs * Some not great style changes * Change LogDetailsRow for better multi value formatting * Cleanup * Add additional information around variable regex, implement PR feedback * Display name with fieldPath if applicable * Add variables with fieldPaths to test * Count empty string as undefined variable * Add better commented version of function, fix tests by removing new variable * Modify when links show * Remove sample yaml * If a link has no variables, set value to field name, and some formatting issues * Add comments and change variable names to be more clear, add back logic where needed, add test coverage for new scenario * Fix formatting of replaceInVariableRegex comment * Remove changes from Grafana-data, move logic into explore * Rename function and property to match similar format * Move types to type files and consolidate definitions, rename functions, change field definitions to accept arrays of keys/values, move function to parser, hide actions on multi key/value rows * Add tests to logParser’s new function
2 years ago
label={parsedKeys[0]}
value={parsedValues[0]}
rowCount={fieldCount}
isLabel={isLabel}
/>
</div>
</td>
</tr>
)}
</>
);
}
}
export const LogDetailsRow = withTheme2(UnThemedLogDetailsRow);
LogDetailsRow.displayName = 'LogDetailsRow';