|
8 | 8 | } from '@grafana/data';
|
9 | 9 |
|
10 | 10 | import { GreptimeDataTypes } from './types';
|
11 |
| -import { getColumnsByHint } from 'data/sqlGenerator'; |
| 11 | +import { getColumnsByHint, logColumnHintsToAlias } from 'data/sqlGenerator'; |
12 | 12 | import { ColumnHint, QueryBuilderOptions } from 'types/queryBuilder';
|
13 | 13 | import { CHQuery } from 'types/sql';
|
14 | 14 |
|
@@ -274,20 +274,14 @@ export function transformGreptimeDBLogs(sqlResponse: GreptimeResponse, query: CH
|
274 | 274 |
|
275 | 275 |
|
276 | 276 | if('builderOptions' in query) {
|
277 |
| - const timeColumn = query.builderOptions?.columns?.find(c => c.hint === 'time') |
278 |
| - const timeColumnName = timeColumn?.alias || timeColumn?.name |
279 |
| - const bodyColumn = query.builderOptions?.columns?.find(c => c.hint === 'log_message') |
280 |
| - const bodyColumnName = bodyColumn?.alias || bodyColumn?.name |
281 |
| - const severityColumn = query.builderOptions?.columns?.find(c => c.hint === 'log_level') |
282 |
| - const severityColumnName = severityColumn?.alias || severityColumn?.name |
283 | 277 |
|
284 | 278 | columnSchemas.forEach((schema, index) => {
|
285 | 279 | const lowerCaseName = schema.name.toLowerCase();
|
286 |
| - if (lowerCaseName === timeColumnName) { |
| 280 | + if (lowerCaseName === logColumnHintsToAlias.get(ColumnHint.Time)) { |
287 | 281 | timestampColumnIndex = index;
|
288 |
| - } else if (lowerCaseName === bodyColumnName) { |
| 282 | + } else if (lowerCaseName === logColumnHintsToAlias.get(ColumnHint.LogMessage)) { |
289 | 283 | bodyColumnIndex = index;
|
290 |
| - } else if (lowerCaseName === severityColumnName) { |
| 284 | + } else if (lowerCaseName === logColumnHintsToAlias.get(ColumnHint.LogLevel)) { |
291 | 285 | severityColumnIndex = index;
|
292 | 286 | } else if (contextColumns.includes(schema.name)) {
|
293 | 287 | contextColumnIndices[schema.name] = index;
|
|
0 commit comments