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/LogDetails.tsx

194 lines
7.6 KiB

import { cx } from '@emotion/css';
import React, { PureComponent } from 'react';
import { CoreApp, DataFrame, Field, LinkModel, LogRowModel } from '@grafana/data';
import { Themeable2, withTheme2 } from '@grafana/ui';
import { calculateLogsLabelStats, calculateStats } from '../utils';
import { LogDetailsRow } from './LogDetailsRow';
import { getLogLevelStyles, LogRowStyles } from './getLogRowStyles';
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
import { getAllFields, createLogLineLinks } from './logParser';
export interface Props extends Themeable2 {
row: LogRowModel;
showDuplicates: boolean;
getRows: () => LogRowModel[];
wrapLogMessage: boolean;
className?: string;
hasError?: boolean;
app?: CoreApp;
styles: LogRowStyles;
onClickFilterLabel?: (key: string, value: string) => void;
onClickFilterOutLabel?: (key: string, value: string) => void;
getFieldLinks?: (field: Field, rowIndex: number, dataFrame: DataFrame) => Array<LinkModel<Field>>;
displayedFields?: string[];
onClickShowField?: (key: string) => void;
onClickHideField?: (key: string) => void;
}
class UnThemedLogDetails extends PureComponent<Props> {
render() {
const {
app,
row,
theme,
hasError,
onClickFilterOutLabel,
onClickFilterLabel,
getRows,
showDuplicates,
className,
onClickShowField,
onClickHideField,
displayedFields,
getFieldLinks,
wrapLogMessage,
styles,
} = this.props;
const levelStyles = getLogLevelStyles(theme, row.logLevel);
const labels = row.labels ? row.labels : {};
const labelsAvailable = Object.keys(labels).length > 0;
const fieldsAndLinks = getAllFields(row, getFieldLinks);
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
let fieldsWithLinks = fieldsAndLinks.filter((f) => f.links?.length);
const displayedFieldsWithLinks = fieldsWithLinks.filter((f) => f.fieldIndex !== row.entryFieldIndex).sort();
const hiddenFieldsWithLinks = fieldsWithLinks.filter((f) => f.fieldIndex === row.entryFieldIndex).sort();
const fieldsWithLinksFromVariableMap = createLogLineLinks(hiddenFieldsWithLinks);
// do not show the log message unless there is a link attached
const fields = fieldsAndLinks.filter((f) => f.links?.length === 0 && f.fieldIndex !== row.entryFieldIndex).sort();
const fieldsAvailable = fields && fields.length > 0;
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 fieldsWithLinksAvailable =
(displayedFieldsWithLinks && displayedFieldsWithLinks.length > 0) ||
(fieldsWithLinksFromVariableMap && fieldsWithLinksFromVariableMap.length > 0);
// If logs with error, we are not showing the level color
const levelClassName = hasError
? ''
: `${levelStyles.logsRowLevelColor} ${styles.logsRowLevel} ${styles.logsRowLevelDetails}`;
return (
<tr className={cx(className, styles.logDetails)}>
{showDuplicates && <td />}
<td className={levelClassName} aria-label="Log level" />
<td colSpan={4}>
<div className={styles.logDetailsContainer}>
<table className={styles.logDetailsTable}>
<tbody>
{(labelsAvailable || fieldsAvailable) && (
<tr>
<td colSpan={100} className={styles.logDetailsHeading} aria-label="Fields">
Fields
</td>
</tr>
)}
{Object.keys(labels)
.sort()
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
.map((key, i) => {
const value = labels[key];
return (
<LogDetailsRow
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
key={`${key}=${value}-${i}`}
parsedKeys={[key]}
parsedValues={[value]}
isLabel={true}
getStats={() => calculateLogsLabelStats(getRows(), key)}
onClickFilterOutLabel={onClickFilterOutLabel}
onClickFilterLabel={onClickFilterLabel}
onClickShowField={onClickShowField}
onClickHideField={onClickHideField}
row={row}
app={app}
wrapLogMessage={wrapLogMessage}
displayedFields={displayedFields}
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={false}
/>
);
})}
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
{fields.map((field, i) => {
const { keys, values, fieldIndex } = field;
return (
<LogDetailsRow
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
key={`${keys[0]}=${values[0]}-${i}`}
parsedKeys={keys}
parsedValues={values}
onClickShowField={onClickShowField}
onClickHideField={onClickHideField}
onClickFilterOutLabel={onClickFilterOutLabel}
onClickFilterLabel={onClickFilterLabel}
getStats={() => calculateStats(row.dataFrame.fields[fieldIndex].values.toArray())}
displayedFields={displayedFields}
wrapLogMessage={wrapLogMessage}
row={row}
app={app}
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={false}
/>
);
})}
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
{fieldsWithLinksAvailable && (
<tr>
<td colSpan={100} className={styles.logDetailsHeading} aria-label="Data Links">
Links
</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
{displayedFieldsWithLinks.map((field, i) => {
const { keys, values, links, fieldIndex } = field;
return (
<LogDetailsRow
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
key={`${keys[0]}=${values[0]}-${i}`}
parsedKeys={keys}
parsedValues={values}
links={links}
onClickShowField={onClickShowField}
onClickHideField={onClickHideField}
getStats={() => calculateStats(row.dataFrame.fields[fieldIndex].values.toArray())}
displayedFields={displayedFields}
wrapLogMessage={wrapLogMessage}
row={row}
app={app}
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={false}
/>
);
})}
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
{fieldsWithLinksFromVariableMap?.map((field, i) => {
const { keys, values, links, fieldIndex } = field;
return (
<LogDetailsRow
key={`${keys[0]}=${values[0]}-${i}`}
parsedKeys={keys}
parsedValues={values}
links={links}
onClickShowField={onClickShowField}
onClickHideField={onClickHideField}
getStats={() => calculateStats(row.dataFrame.fields[fieldIndex].values.toArray())}
displayedFields={displayedFields}
wrapLogMessage={wrapLogMessage}
row={row}
app={app}
disableActions={true}
/>
);
})}
{!fieldsAvailable && !labelsAvailable && !fieldsWithLinksAvailable && (
<tr>
<td colSpan={100} aria-label="No details">
No details available
</td>
</tr>
)}
</tbody>
</table>
</div>
</td>
</tr>
);
}
}
export const LogDetails = withTheme2(UnThemedLogDetails);
LogDetails.displayName = 'LogDetails';